Guest User

Untitled

a guest
Jan 3rd, 2019
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. apply plugin: 'com.jfrog.artifactory'
  2. apply plugin: 'maven-publish'
  3.  
  4. def artifactVersion = "${artifactory_version}"
  5. //release包发布的版本
  6. //def artifactVersion = '1.1-SNAPSHOT'//snapshot包发布的版本
  7.  
  8.  
  9. publishing {
  10. publications {
  11. aar(MavenPublication) {
  12. groupId = "${artifactory_groupid}"
  13. artifactId "${artifactory_name}"
  14. version = artifactVersion
  15. artifact "${project.buildDir}/outputs/aar/${artifactory_name}.aar"
  16. pom.withXml {
  17. //Creating additional node for dependencies
  18. def dependenciesNode = asNode().appendNode('dependencies')
  19.  
  20. //Defining configuration names from which dependencies will be taken (debugCompile or releaseCompile and compile)
  21. def configurationNames = ["debugCompile", 'compile', 'api','implementation']
  22.  
  23. configurationNames.each { configurationName ->
  24. configurations[configurationName].allDependencies.each {
  25. if (it.group != null && it.name != null) {
  26. def dependencyNode = dependenciesNode.appendNode('dependency')
  27. dependencyNode.appendNode('groupId', it.group)
  28. dependencyNode.appendNode('artifactId', it.name)
  29. dependencyNode.appendNode('version', it.version)
  30.  
  31. //If there are any exclusions in dependency
  32. if (it.excludeRules.size() > 0) {
  33. def exclusionsNode = dependencyNode.appendNode('exclusions')
  34. it.excludeRules.each { rule ->
  35. def exclusionNode = exclusionsNode.appendNode('exclusion')
  36. exclusionNode.appendNode('groupId', rule.group)
  37. exclusionNode.appendNode('artifactId', rule.module)
  38. }
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. artifactory {
  48. contextUrl = "${artifactory_contextUrl}"
  49. publish {
  50. repository {
  51. // The Artifactory repository key to publish to
  52. repoKey = artifactVersion.endsWith('SNAPSHOT') ? 'libs-snapshot-local' : 'libs-release-local'
  53. username = "${artifactory_user}" // The publisher user name
  54. password = "${artifactory_password}" // The publisher password
  55.  
  56. }
  57. defaults {
  58. publishArtifacts = true
  59. publications('aar')
  60. publishPom = true //Publish generated POM files to Artifactory (true by default)
  61. publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default)
  62. }
  63. }
  64. resolve {
  65. repository {
  66. repoKey = 'jcenter'
  67. username = "${artifactory_user}" // The resolver user name
  68. password = "${artifactory_password}" // The resolver password
  69. }
  70. }
  71. }
Add Comment
Please, Sign In to add comment