社内で共有のライブラリとかを作る場合, こんな感じ。sources も一緒に作りましょう。
// build.gradle (library)
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
def releaseDir = file(releaseRepositoryDir).absolutePath
uploadArchives {
repositories {
add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
name = "release"
m2compatible = true
addIvyPattern "${releaseDir}/[organisation]/[module]/[revision]/[module]-[revision].ivy"
addArtifactPattern "${releaseDir}/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
}
}
}
これを参照するだけ。今回は単純にリポジトリを VCS 上で管理してチェックアウトして参照してます。
// build.gradle
repositories {
mavenCentral()
maven {
url "https://repository.jboss.org/nexus/content/groups/public-jboss/"
}
ivy {
url file(repositoryDir).absolutePath
layout "pattern", {
ivy "[organisation]/[module]/[revision]/[module]-[revision].ivy"
artifact "/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
m2compatible = true
}
}
}