私はmavensettings.xmlを次の場所に持っています:
/home/u123/.m2/settings.xml
ここで、リモートMavenリポジトリを指定します。
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<profiles>
<profile>
<id>default</id>
<repositories>
<repository>
<id>my.repo</id>
<url>http://myrepo/ </url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>default</activeProfile>
</activeProfiles>
</settings>
このリポジトリでは、アーティファクトをデプロイしました。実際には、そのgradleプラグインです。
次に、以下のbuild.gradleファイルを使用して、このプラグイン/アーティファクトを使用する必要がある別のプロジェクトをビルドしようとします。
apply plugin: 'java'
apply plugin: 'maven'
buildscript {
dependencies {
classpath 'com.test:my-gradle-plugin:1.0.0-SNAPSHOT'
}
}
しかし、ビルドは失敗します:
...
> Could not find group:com.test, module:my-gradle-plugin, version:1.0.0-SNAPSHOT.
...
上記のsettings.xmlファイルがリモートのMavenリポジトリを指しているのに、Gradleがmy-gradle-pluginを見つけることができません。
代わりに、build.gradleファイル内のリポジトリを指定すると、次のように機能します。
buildscript {
repositories {
maven {
url "http://myrepo/"
}
}
dependencies {
classpath 'com.test:my-gradle-plugin:1.0.0-SNAPSHOT'
}
}
この投稿に基づく:
http://forums.gradle.org/gradle/topics/have_mavenlocal_check_m2_home_conf_settings_xml
gradleはsettings.xmlファイルを考慮しているようですが、何が問題になっていますか?