maven-deployment.gradle 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. // Remove the archive configuration from the runtime configuration, so that anything added to archives
  19. // (such as the source jar) is no longer included in the runtime classpath
  20. configurations.default.extendsFrom = [configurations.runtime] as Set
  21. // Add the main jar into the default configuration
  22. artifacts { 'default' jar }
  23. gradle.taskGraph.whenReady {graph ->
  24. if (graph.hasTask(uploadArchives)) {
  25. // check properties defined and fail early
  26. s3AccessKey
  27. s3SecretAccessKey
  28. }
  29. }
  30. uploadArchives {
  31. // "mavenSyncRepoDir" should be set in properties
  32. def releaseRepositoryUrl = "file://${project.properties.mavenSyncRepoDir}"
  33. def milestoneRepositoryUrl = 's3://maven.springframework.org/milestone'
  34. def snapshotRepositoryUrl = 's3://maven.springframework.org/snapshot'
  35. repositories.mavenDeployer { deployer ->
  36. configuration = configurations.deployerJars
  37. if (releaseBuild) {
  38. repository(url: releaseRepositoryUrl)
  39. } else {
  40. def s3credentials = [userName: project.properties.s3AccessKey, passphrase: project.properties.s3SecretAccessKey]
  41. repository(url: milestoneRepositoryUrl) {
  42. authentication(s3credentials)
  43. }
  44. snapshotRepository(url: snapshotRepositoryUrl) {
  45. authentication(s3credentials)
  46. }
  47. }
  48. customizePom(deployer.pom)
  49. }
  50. }
  51. install {
  52. customizePom(repositories.mavenInstaller.pom)
  53. }
  54. def customizePom(pom) {
  55. def optionalDeps = ['ehcache', 'log4j', 'apacheds-core', 'jsp-api', 'jsr250-api', 'ldapsdk', 'aspectjrt', 'aspectjweaver']
  56. pom.scopeMappings.addMapping(10, configurations.provided, 'provided')
  57. pom.whenConfigured { p ->
  58. // Remove test scope dependencies from published poms
  59. p.dependencies = p.dependencies.findAll {it.scope != 'test'}
  60. // Flag optional deps
  61. p.dependencies.findAll { dep ->
  62. optionalDeps.contains(dep.artifactId) ||
  63. dep.groupId.startsWith('org.apache.directory') ||
  64. dep.groupId.startsWith('org.slf4j')
  65. }*.optional = true
  66. // Hack for specific case of config module
  67. if (p.artifactId == 'spring-security-config') {
  68. p.dependencies.find { dep -> dep.artifactId == 'spring-security-web'}.optional = true
  69. p.dependencies.find { dep -> dep.artifactId == 'spring-web'}.optional = true
  70. }
  71. if (p.artifactId == 'spring-security-core') {
  72. p.dependencies.find { dep -> dep.artifactId == 'spring-jdbc'}.optional = true
  73. p.dependencies.find { dep -> dep.artifactId == 'spring-tx'}.optional = true
  74. p.dependencies.removeAll { dep -> dep.artifactId == 'spring-security-crypto' }
  75. }
  76. }
  77. pom.project {
  78. licenses {
  79. license {
  80. name 'The Apache Software License, Version 2.0'
  81. url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  82. distribution 'repo'
  83. }
  84. }
  85. dependencies {
  86. dependency {
  87. artifactId = groupId = 'commons-logging'
  88. scope = 'compile'
  89. optional = 'true'
  90. version = '1.1.1'
  91. }
  92. }
  93. }
  94. }