Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. apply plugin: 'maven'
  2.  
  3. task sourcesJar(type: Jar) {
  4. classifier = 'sources'
  5. from sourceSets.main.allSource
  6. }
  7.  
  8. build.dependsOn(sourcesJar)
  9.  
  10. artifacts {
  11. archives sourcesJar
  12. }
  13.  
  14. uploadArchives {
  15. repositories {
  16. mavenDeployer {
  17. repository(url: 'releases repo') {
  18. authentication(
  19. userName: rootProject.properties.get('artifactory.username'),
  20. password: rootProject.properties.get('artifactory.token')
  21. )
  22. }
  23.  
  24. snapshotRepository(url: 'snapshots repo) {
  25. authentication(
  26. userName: rootProject.properties.get('artifactory.username'),
  27. password: rootProject.properties.get('artifactory.token')
  28. )
  29. }
  30. }
  31. }
  32. }
  33.  
  34. def installer = install.repositories.mavenInstaller
  35. def deployer = uploadArchives.repositories.mavenDeployer
  36.  
  37. [installer, deployer]*.pom*.whenConfigured { pom ->
  38. pom.project {
  39. packaging 'jar'
  40. }
  41.  
  42. pom.withXml {
  43. asNode().dependencies.'*'.each {
  44. if (it.scope*.value != null) {
  45. it.scope*.value = 'compile'
  46. }
  47. }
  48.  
  49. asNode().dependencyManagement.dependencies.'*'.each {
  50. if (it.scope*.value != null) {
  51. it.scope*.value = 'compile'
  52. }
  53. }
  54.  
  55. def repos = asNode().appendNode('repositories')
  56.  
  57. project.repositories.findAll { it.name != 'MavenLocal' }.each {
  58. def repo = repos.appendNode('repository')
  59. repo.appendNode('id', it.name)
  60. repo.appendNode('name', it.name)
  61. repo.appendNode('url', it.url)
  62. }
  63. }
  64.  
  65. if (project.hasProperty('pomConfigurer')) {
  66. pom.withXml(pomConfigurer)
  67. }
  68. }
  69.  
  70. install.dependsOn build
  71. uploadArchives.dependsOn build
  72.  
  73. task 'publish-snapshot'() {
  74. dependsOn uploadArchives
  75. }
  76.  
  77. task publish() {
  78. dependsOn uploadArchives
  79. }
  80.  
  81. dependencyManagement {
  82. generatedPomCustomization {
  83. enabled = true
  84. }
  85. }
  86.  
  87. ext.pomConfigurer = {
  88. // some pom configuration
  89. }
  90.  
  91. allprojects {
  92. apply plugin: 'maven'
  93. apply plugin: 'io.spring.dependency-management'
  94. }
  95.  
  96. subprojects {
  97. apply from: file('publish-jars.gradle')
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement