Reputation: 1269
I have a build.gradle file to build and upload on a private Maven Repository an Android library (.aar) Script is perfectly working, but the problem, it uploads my two buildType on the maven repo (debug and release builds) and I would like to upload only the release one.
Here my script:
afterEvaluate { project ->
// Generate Jar of the Javadoc
task androidJavadocsJar(type: Jar, dependsOn: generateReleaseJavadoc) {
classifier = 'javadoc'
from generateReleaseJavadoc.destinationDir
}
// Include Javadoc Jar file in the Maven repository
artifacts {
archives androidJavadocsJar
}
// Task to upload SDK in Maven private repository
uploadArchives {
repositories {
mavenDeployer {
repository(url: "***") {
authentication(userName: '***', password: '***')
}
snapshotRepository(url: "***") {
authentication(userName: '***', password: '***')
}
pom.project {
artifactId '***'
name '***'
packaging 'aar'
}
}
}
}
}
I know that it is possible by writting this defaultPublishConfig "release" in the android {} part, but when I do that, I cannot use my library in a debug build for debugging. I did not find any workaround to stop uploading the debug package than to comment and uncomment depending on what I would like to do...
Upvotes: 3
Views: 1730
Reputation: 2651
this might help to resolve your issue. Basically it uses the release build by default. However, it seems you can override the behaviour by;
android {
defaultPublishConfig "flavor1Debug"
}
Upvotes: 3
Reputation: 3100
I do it the following way and I get only release artifacts in the packaged AAR.
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
uploadArchives {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: 'http://myserver/artifactory/libs-release-local') {
authentication(userName: artifactoryUsername, password: artifactoryPassword)
}
snapshotRepository(url: 'http://myserver/artifactory/libs-snapshot-local') {
authentication(userName: artifactoryUsername, password: artifactoryPassword)
}
pom.project {
name 'somelibrary'
description 'some library'
scm {
developerConnection 'repo location'
}
}
}
}
}
On the contrary, I was actually looking for a way to publish separate artifact for debug and release but couldn't find heh :)
Upvotes: 2