maven-deployment.gradle 3.5 KB

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