SharedCode
(Java)モジュールと、Android
モジュールに依存する(Androidライブラリ)モジュールを持つプロジェクトがありSharedCode
ます。モジュールから成果物を公開し、モジュールjar
から成果物を公開したいと考えています。タスクの実行時に両方のモジュールが Artifactory に公開されるようにファイルを構成する方法がわかりません。現時点では、モジュールのみがアーティファクトを Artifactory に発行します。SharedCode
aar
Android
build.gradle
artifactoryPublish
SharedCode
私のbuild.gradle
ファイルは以下の通りです。タスクを実行すると、両方のモジュールのアーティファクトがローカルの Maven フォルダー (つまり) に表示されるためmaven-publish
、ファイルの側面build.gradle
が正しいように見えることに注意してください。publishToMavenLocal
'~/.m2/repository'
まず、build.gradle
私のモジュールのファイルSharedCode
は次のとおりです。
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
group = "${projectGroupId}"
version = "${projectVersionName}"
dependencies {
compile 'com.google.guava:guava:18.0'
}
publishing {
publications {
SharedCode(MavenPublication) {
groupId "${projectGroupId}"
artifactId 'SharedCode'
version "${projectVersionName}"
from components.java
}
}
}
artifactory {
contextUrl = "${artifactory_url}"
publish {
repository {
repoKey = 'libs-release-local'
username = "${artifactory_username}"
password = "${artifactory_password}"
}
defaults {
publications('SharedCode')
publishArtifacts = true
properties = ['qa.level': 'basic', 'dev.team': 'core']
publishPom = true
}
}
}
次に、モジュール内のbuild.gradle
ファイルAndroid
は次のとおりです。
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
group = "${projectGroupId}"
version = "${projectVersionName}"
android {
// android stuff here...
}
dependencies {
compile project(':SharedCode')
}
publishing {
publications {
Android(MavenPublication) {
groupId "${projectGroupId}"
artifactId 'Android'
version "${projectVersionName}"
artifact "$buildDir/outputs/aar/Android-release.aar"
}
}
}
artifactory {
contextUrl = "${artifactory_url}"
publish {
repository {
repoKey = 'libs-release-local'
username = "${artifactory_username}"
password = "${artifactory_password}"
}
defaults {
publications('Android')
publishArtifacts = true
properties = ['qa.level': 'basic', 'dev.team': 'core']
publishPom = true
}
}
}
artifactoryPublish
ルート、プロジェクト レベル、またはモジュール レベルでタスクを実行するとSharedCode
、次のような出力が表示されます。
18:23:38: Executing external task 'artifactoryPublish'...
Publication named 'SharedCode' does not exist for project ':Android' in task ':Android:artifactoryPublish'.
:SharedCode:generatePomFileForSharedCodePublication
:SharedCode:artifactoryPublish
Deploying artifact: http://localhost:8081/artifactory/libs-release-local/com/mycompany/sdk/SharedCode/0.0.2/SharedCode-0.0.2.jar
Deploying artifact: http://localhost:8081/artifactory/libs-release-local/com/mycompany/sdk/SharedCode/0.0.2/SharedCode-0.0.2.pom
Deploying build descriptor to: http://localhost:8081/artifactory/api/build Build successfully deployed.
Browse it in Artifactory under http://localhost:8081/artifactory/webapp/builds/client-sdk/1457375019604
BUILD SUCCESSFUL
SharedCode
この場合、アーティファクトのみが公開されることに注意してください。
artifactoryPublish
モジュール レベルでタスクを実行するAndroid
と、次のような出力が表示されます。
18:25:25: Executing external task 'artifactoryPublish'...
Publication named 'SharedCode' does not exist for project ':Android' in task ':Android:artifactoryPublish'.
:Android:artifactoryPublish
Deploying build descriptor to: http://localhost:8081/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under http://localhost:8081/artifactory/webapp/builds/client-sdk/1457375127269
BUILD SUCCESSFUL
この場合、アーティファクトは公開されないことに注意してください。