maven-deployment.gradle 3.8 KB

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