maven-deployment.gradle 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. // Remove the archive configuration from the runtime configuration, so that anything added to archives
  20. // (such as the source jar) is no longer included in the runtime classpath
  21. configurations.default.extendsFrom = [configurations.runtime] as Set
  22. // Add the main jar into the default configuration
  23. artifacts { 'default' jar }
  24. install {
  25. customizePom(repositories.mavenInstaller.pom, project)
  26. }
  27. def customizePom(pom, gradleProject) {
  28. def optionalDeps = ['ehcache', 'log4j', 'apacheds-core', 'jsp-api', 'jsr250-api', 'ldapsdk', 'aspectjrt', 'aspectjweaver']
  29. pom.scopeMappings.addMapping(10, configurations.provided, 'provided')
  30. pom.whenConfigured { p ->
  31. // Remove test scope dependencies from published poms
  32. p.dependencies = p.dependencies.findAll {it.scope != 'test'}
  33. // Flag optional deps
  34. p.dependencies.findAll { dep ->
  35. optionalDeps.contains(dep.artifactId) ||
  36. dep.groupId.startsWith('org.apache.directory') ||
  37. dep.groupId.startsWith('org.slf4j')
  38. }*.optional = true
  39. // Hack for specific case of config module
  40. if (p.artifactId == 'spring-security-config') {
  41. p.dependencies.find { dep -> dep.artifactId == 'spring-security-web'}.optional = true
  42. p.dependencies.find { dep -> dep.artifactId == 'spring-web'}.optional = true
  43. }
  44. if (p.artifactId == 'spring-security-core') {
  45. p.dependencies.find { dep -> dep.artifactId == 'spring-jdbc'}.optional = true
  46. p.dependencies.find { dep -> dep.artifactId == 'spring-tx'}.optional = true
  47. p.dependencies.removeAll { dep -> dep.artifactId == 'spring-security-crypto' }
  48. }
  49. }
  50. pom.project {
  51. name = gradleProject.name
  52. description = gradleProject.name
  53. url = 'http://springsource.org/spring-security'
  54. organization {
  55. name = 'SpringSource'
  56. url = 'http://springsource.org/'
  57. }
  58. licenses {
  59. license {
  60. name 'The Apache Software License, Version 2.0'
  61. url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  62. distribution 'repo'
  63. }
  64. }
  65. scm {
  66. url = 'https://github.com/SpringSource/spring-security'
  67. connection = 'scm:git:git://github.com/SpringSource/spring-security'
  68. developerConnection = 'scm:git:git://github.com/SpringSource/spring-security'
  69. }
  70. developers {
  71. developer {
  72. id = 'rwinch'
  73. name = 'Rob Winch'
  74. email = 'rwinch@vmware.com'
  75. }
  76. }
  77. dependencies {
  78. dependency {
  79. artifactId = groupId = 'commons-logging'
  80. scope = 'compile'
  81. optional = 'true'
  82. version = '1.1.1'
  83. }
  84. }
  85. }
  86. }
  87. task generatePom {
  88. group = 'Build'
  89. description = 'Generates the Maven pom.xml'
  90. ext.generatedPomFileName = 'pom.xml'
  91. inputs.files('**/*.gradle')
  92. outputs.files(generatedPomFileName)
  93. doLast() {
  94. def p = pom {}
  95. customizePom(p, project)
  96. p.writeTo(generatedPomFileName)
  97. }
  98. }