Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- apply plugin: 'com.jfrog.artifactory'
- apply plugin: 'maven-publish'
- def artifactVersion = "${artifactory_version}"
- //release包发布的版本
- //def artifactVersion = '1.1-SNAPSHOT'//snapshot包发布的版本
- publishing {
- publications {
- aar(MavenPublication) {
- groupId = "${artifactory_groupid}"
- artifactId "${artifactory_name}"
- version = artifactVersion
- artifact "${project.buildDir}/outputs/aar/${artifactory_name}.aar"
- pom.withXml {
- //Creating additional node for dependencies
- def dependenciesNode = asNode().appendNode('dependencies')
- //Defining configuration names from which dependencies will be taken (debugCompile or releaseCompile and compile)
- def configurationNames = ["debugCompile", 'compile', 'api','implementation']
- configurationNames.each { configurationName ->
- configurations[configurationName].allDependencies.each {
- if (it.group != null && it.name != null) {
- def dependencyNode = dependenciesNode.appendNode('dependency')
- dependencyNode.appendNode('groupId', it.group)
- dependencyNode.appendNode('artifactId', it.name)
- dependencyNode.appendNode('version', it.version)
- //If there are any exclusions in dependency
- 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)
- }
- }
- }
- }
- }
- }
- }
- }
- }
- artifactory {
- contextUrl = "${artifactory_contextUrl}"
- publish {
- repository {
- // The Artifactory repository key to publish to
- repoKey = artifactVersion.endsWith('SNAPSHOT') ? 'libs-snapshot-local' : 'libs-release-local'
- username = "${artifactory_user}" // The publisher user name
- password = "${artifactory_password}" // The publisher password
- }
- defaults {
- publishArtifacts = true
- publications('aar')
- publishPom = true //Publish generated POM files to Artifactory (true by default)
- publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default)
- }
- }
- resolve {
- repository {
- repoKey = 'jcenter'
- username = "${artifactory_user}" // The resolver user name
- password = "${artifactory_password}" // The resolver password
- }
- }
- }
Add Comment
Please, Sign In to add comment