I'm working on a repo with a set of releasable libraries each in a module. The idea is each library should be able to be released individually with i.e., ./gradlew upload
.
Currently in each module I have the following code to publish it:
uploadArchives {
repositories {
mavenDeployer {
repository(url: "<url>") {
authentication(userName: System.getenv('USER_NAME'), password: System.getenv('PASSWORD'))
pom.groupId = "$groupId"
pom.artifactId = "$artifactId"
pom.version = android.defaultConfig.versionName
}
}
}
}
afterEvaluate {
publishing {
publications {
library(MavenPublication) {
setGroupId "$groupId"
setArtifactId "$artifactId"
version android.defaultConfig.versionName
artifact bundleReleaseAar
}
}
}
}
I'd love to have a way to share those gradle tasks and to avoid repeating them in each module but haven't found a way to do that. One tricky thing probably is that artifactId
would be different in each module so assuming I could extract those gradle tasks there should be a way to set artifactId
individually.
Can someone shed me some light? Thanks