LoginSignup
1
0

More than 5 years have passed since last update.

Gradle で自作のライブラリを ivy リポジトリとしてアップロードして参照する

Posted at

社内で共有のライブラリとかを作る場合, こんな感じ。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
        }
    }
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0