Reputation: 1617
I have a library with 4 modules (all of them are aar's). Before updating to newest gradle for each module I needed to run artifactoryPublish task. Right now I need to clean & rebuild a project before triggering each publish task.
> Task :module-1:generatePomFileForAarPublication
> Task :module-1:artifactoryPublish
> Task :extractModuleInfo
No publisher config found for project: android-integration-sdk-light
> Task :module-1:extractModuleInfo
> Task :module-2:extractModuleInfo
> Task :module-3:extractModuleInfo
> Task :module-4:extractModuleInfo
[pool-4-thread-1] Deploying artifact: https://xxx.yyy
[pool-4-thread-1] Deploying artifact: https://xxx.yyy
> Task :artifactoryDeploy
BUILD SUCCESSFUL in 6s
First task run
> Task :module-1:generatePomFileForAarPublication
> Task :module-1:artifactoryPublish
> Task :extractModuleInfo UP-TO-DATE
> Task :module-1:extractModuleInfo UP-TO-DATE
> Task :module-2:extractModuleInfo UP-TO-DATE
> Task :module-3:extractModuleInfo UP-TO-DATE
> Task :module-4:extractModuleInfo UP-TO-DATE
> Task :artifactoryDeploy
BUILD SUCCESSFUL in 2s
Second task run
Config for artifactory:
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply from: "../artifactory/config.gradle"
publishing {
publications {
aar(MavenPublication) {
groupId project.groupId
version project.versionName
artifactId project.name
artifact("$buildDir/outputs/aar/${project.getName()}-release.${project.fileExtension}")
pom.withXml {
def node = asNode()
// ugly hack to set the packaging property in the POM as 'aar'
((NodeList) node.get('packaging')).get(0).value = project.fileExtension
def dependenciesNode = node.appendNode('dependencies')
def cl = { Dependency dep ->
if (dep.group == null || dep.name == null || dep.name == "unspecified") {
return // ignore invalid dependencies
}
def dependencyVersion
//Only a temporary hack - need more investigation
def dependencyGroup
if (dep.group == "mobile-library") {
dependencyGroup = groupId
} else {
dependencyGroup = dep.group
}
//"fix" for compile projects
if (dep.version == "unspecified" || dep.version == null) {
dependencyVersion = project.versionName
} else {
dependencyVersion = dep.version
}
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dependencyGroup)
dependencyNode.appendNode('artifactId', dep.name)
dependencyNode.appendNode('version', dependencyVersion)
if (!dep.transitive) {
// If this dependency is transitive, we should force exclude all its dependencies them from the POM
def exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')
exclusionNode.appendNode('groupId', '*')
exclusionNode.appendNode('artifactId', '*')
} else if (!dep.properties.excludeRules.empty) {
// Otherwise add specified exclude rules
def exclusionsNode = dependencyNode.appendNode('exclusions')
dep.properties.excludeRules.each { ExcludeRule rule ->
def exclusion = exclusionsNode.appendNode('exclusion')
exclusion.appendNode('groupId', rule.group ?: '*')
exclusion.appendNode('artifactId', rule.module ?: '*')
}
}
}
// List all dependencies and write to POM
configurations.api.getAllDependencies().each cl
configurations.implementation.getAllDependencies().each cl
}
}
}
}
artifactory {
contextUrl = repositoryPath
publish {
repository {
repoKey = repositoryName
username = repositoryUserName
password = repositoryPassword
maven = true
}
defaults {
publications('aar')
publishArtifacts = true
// Publish generated POM files to Artifactory (true by default)
}
}
}
Use of the file in sub-modules, each module has it's own name:
project.ext {
name = "module-1"
fileExtension = "aar"
}
apply plugin: 'com.android.library'
apply from: "../artifactory/release.gradle"
Should I force clean task & rebuild task before each publish? Or should I try to have one entry-point for each module in main gradle file?
Upvotes: 1
Views: 4050
Reputation: 6033
This issue should have been resolved in Gradle Artifactory plugin 4.18.0.
You can find more information about this issue here: https://github.com/jfrog/build-info/issues/383
Please upgrade your Gradle Artifactory plugin.
Upvotes: 1