maven-deployment.gradle 3.6 KB

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