I am using Bamboo 6.0.3 build 60004
and I installed the version 2.1.0
of the official Artifactory plugin for Bamboo.
The build.gradle
of the project looks like:
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
...
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
afterEvaluate {
androidJavadocs.classpath += files(android.libraryVariants.collect { variant ->
variant.javaCompile.classpath.files
})
}
publishing {
publications {
android.buildTypes.all { variant ->
"${variant.name}Aar"(MavenPublication) {
// set values from Android manifest file
groupId group
version version
if (variant.name == "release") {
artifactId project.getName()
}
else {
artifactId "${project.getName()}-${variant.name}"
}
artifact "$buildDir/outputs/aar/${project.getName()}-${variant.name}-${version}.aar"
artifact androidJavadocsJar
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// List all compile dependencies and write to POM
configurations.compile.getAllDependencies().each { Dependency dep ->
if (dep.group == null || dep.version == null || dep.name == null || dep.name == "unspecified")
return // ignore invalid dependencies
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name)
dependencyNode.appendNode('version', dep.version)
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 exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')
dep.properties.excludeRules.each { ExcludeRule rule ->
exclusionNode.appendNode('groupId', rule.group ?: '*')
exclusionNode.appendNode('artifactId', rule.module ?: '*')
}
}
}
}
}
}
}
}
def libraryGroupId = group
def libraryVersion = version
artifactory {
contextUrl = '<artifactory_url>'
publish {
repository {
repoKey = '<repoKey>'
username = artifactory_username
password = artifactory_password
}
defaults {
android.buildTypes.all { variant ->
publications("${variant.name}Aar")
publishArtifacts = true
}
properties = ['qa.level': 'basic', 'dev.team': 'core']
publishPom = true
}
}
}
When I run the command gradle build assembleRelease artifactoryPublish
on my laptop, it uploads in the Artifactory repo an aar
and a pom
file.
I tried using the Artifactory Deployment
task in the deployment project that runs after a build task that does gradle build assembleRelease
(so the same but without the publishing to artifactory), but it instead publishes only the aar file and the directory structure in artifactory doesn't look the same (it does not breakdown the package name by subfolder). How to achieve the same with Bamboo?