Last active
February 10, 2020 17:58
-
-
Save romaopedro/0b3d70299fe6132d45e44ea22036a317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
publishing { | |
publications { | |
android.libraryVariants.all { variant -> | |
//use this kind of combination if you want to skip a publication | |
//if (variant.flavorName == "production" && variant.buildType.name == "debug") return | |
//if (variant.flavorName != "production" && variant.buildType.name == "release") return | |
def filename = "${archivesBaseName}-${variant.baseName}-${android.defaultConfig.versionName}" | |
//println(filename) | |
"${variant.name}"(MavenPublication) { | |
//println(variant.name) | |
groupId 'com.acceptto.sdk' | |
artifactId = "itsme" | |
if (project.hasProperty('paramEnv') && project.property('paramEnv') != 'RELEASE' || variant.name != "release") { | |
groupId "com.acceptto.sdk.${variant.name}" | |
} | |
version = "${android.defaultConfig.versionName}" | |
if (variant.buildType.name == "debug") { | |
//artifact("$buildDir/libs/itsme-sdk-sources.jar") | |
artifact(sourcesJar) | |
} | |
artifact file("$buildDir/outputs/aar/${filename}.aar") | |
pom.withXml { | |
// for dependencies and exclusions | |
def dependenciesNode = asNode().appendNode('dependencies') | |
def configurationNames = ["implementation", "api", "runtimeOnly"] | |
configurationNames.each { confName -> | |
configurations[confName].allDependencies.each { | |
def dependencyNode = dependenciesNode.appendNode('dependency') | |
dependencyNode.appendNode('groupId', it.group) | |
dependencyNode.appendNode('artifactId', it.name) | |
dependencyNode.appendNode('version', it.version) | |
if (it.excludeRules.size() > 0) { | |
def exclusionsNode = dependencyNode.appendNode('exclusions') | |
it.excludeRules.each { rule -> | |
def exclusionNode = exclusionsNode.appendNode('exclusion') | |
exclusionNode.appendNode('groupId', rule.group) | |
exclusionNode.appendNode('artifactId', rule.module) | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
assemble.finalizedBy(artifactoryPublish) | |
artifactory { | |
contextUrl = "${artifactory_context_url}" | |
publish { | |
repository { | |
repoKey = "${artifactory_dev_repo_key}" | |
if (project.hasProperty('paramEnv') && project.property('paramEnv') == 'RELEASE') { | |
repoKey = "${artifactory_rel_repo_key}" | |
} | |
username = "${artifactory_user}" | |
password = "${artifactory_password}" | |
maven = true | |
} | |
defaults { | |
if (project.hasProperty('paramEnv') && project.property('paramEnv') == 'RELEASE') { | |
publications('release') | |
} else { | |
publications('debug', 'release') | |
} | |
publishArtifacts = true | |
publishPom = true | |
} | |
} | |
resolve { | |
repository { | |
repoKey = "${artifactory_rel_repo_key}" | |
username = "${artifactory_user}" | |
password = "${artifactory_password}" | |
maven = true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment