maven-deployment.gradle 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. apply plugin: 'maven'
  2. // Create a source jar for uploading
  3. task sourceJar(type: Jar) {
  4. classifier = 'sources'
  5. from sourceSets.main.java.srcDirs
  6. include '**/*.java', '**/*.aj'
  7. }
  8. artifacts {
  9. archives sourceJar
  10. archives javadocJar
  11. }
  12. // Configuration for SpringSource s3 maven deployer
  13. configurations {
  14. deployerJars
  15. }
  16. dependencies {
  17. deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE"
  18. }
  19. install {
  20. repositories.mavenInstaller {
  21. customizePom(pom, project)
  22. }
  23. }
  24. def customizePom(pom, gradleProject) {
  25. pom.whenConfigured { p ->
  26. p.dependencies.findAll{ it.scope == "optional" }.each {
  27. it.scope = "compile"
  28. it.optional = true
  29. }
  30. // sort to make pom dependencies order consistent to ease comparison of older poms
  31. p.dependencies = p.dependencies.sort { dep ->
  32. "$dep.scope:$dep.optional:$dep.groupId:$dep.artifactId"
  33. }
  34. }
  35. def isWar = project.hasProperty('war')
  36. pom.project {
  37. name = gradleProject.name
  38. if(isWar) {
  39. packaging = "war"
  40. }
  41. description = gradleProject.name
  42. url = 'http://springsource.org/spring-security'
  43. organization {
  44. name = 'SpringSource'
  45. url = 'http://springsource.org/'
  46. }
  47. licenses {
  48. license {
  49. name 'The Apache Software License, Version 2.0'
  50. url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  51. distribution 'repo'
  52. }
  53. }
  54. scm {
  55. url = 'https://github.com/SpringSource/spring-security'
  56. connection = 'scm:git:git://github.com/SpringSource/spring-security'
  57. developerConnection = 'scm:git:git://github.com/SpringSource/spring-security'
  58. }
  59. developers {
  60. developer {
  61. id = 'rwinch'
  62. name = 'Rob Winch'
  63. email = 'rwinch@gopivotal.com'
  64. }
  65. }
  66. if(isWar) {
  67. properties {
  68. 'm2eclipse.wtp.contextRoot' '/' + project.war.baseName
  69. }
  70. }
  71. if(project.snapshotBuild) {
  72. repositories {
  73. repository {
  74. id 'spring-snasphot'
  75. url 'https://repo.spring.io/snapshot'
  76. }
  77. }
  78. } else if(!project.releaseBuild) {
  79. repositories {
  80. repository {
  81. id 'spring-milestone'
  82. url 'https://repo.spring.io/milestone'
  83. }
  84. }
  85. }
  86. build {
  87. plugins {
  88. plugin {
  89. groupId = 'org.apache.maven.plugins'
  90. artifactId = 'maven-compiler-plugin'
  91. configuration {
  92. source = '1.7'
  93. target = '1.7'
  94. }
  95. }
  96. if(isWar) {
  97. plugin {
  98. groupId = 'org.apache.maven.plugins'
  99. artifactId = 'maven-war-plugin'
  100. version = '2.3'
  101. configuration {
  102. failOnMissingWebXml = 'false'
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }
  110. task generatePom {
  111. group = 'Build'
  112. description = 'Generates a Maven pom.xml'
  113. ext.generatedPomFileName = "pom.xml"
  114. onlyIf { install.enabled }
  115. inputs.files(fileTree(project.rootProject.rootDir).include("**/*.gradle").files)
  116. inputs.files(new File(project.rootProject.rootDir, Project.GRADLE_PROPERTIES))
  117. outputs.files(generatedPomFileName)
  118. doLast() {
  119. def p = pom {}
  120. customizePom(p, project)
  121. p.writeTo(generatedPomFileName)
  122. }
  123. }
  124. build.dependsOn generatePom