2
0

maven-deployment.gradle 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. def deployer = null
  30. uploadArchives {
  31. def releaseRepositoryUrl = "file://${project.properties.mavenSyncRepoDir}"
  32. def milestoneRepositoryUrl = 's3://maven.springframework.org/milestone'
  33. def snapshotRepositoryUrl = 's3://maven.springframework.org/snapshot'
  34. deployer = repositories.mavenDeployer {
  35. configuration = configurations.deployerJars
  36. if (releaseBuild) {
  37. // "mavenSyncRepoDir" should be set in properties
  38. repository(url: releaseRepositoryUrl)
  39. } else {
  40. 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. }
  49. }
  50. // Pom Customization
  51. installer = install.repositories.mavenInstaller
  52. def optionalDeps = ['ehcache', 'log4j', 'apacheds-core', 'jsp-api', 'jsr250-api', 'ldapsdk']
  53. // Workaround for GRADLE-1497
  54. def cloggingDep(Class cl) {
  55. clogging = cl.newInstance()
  56. clogging.artifactId = clogging.groupId = "commons-logging"
  57. clogging.scope = 'compile'
  58. clogging.optional = true
  59. clogging.version = '1.1.1'
  60. clogging
  61. }
  62. [installer, deployer]*.pom.collect { pom ->
  63. pom.scopeMappings.addMapping(10, configurations.provided, 'provided')
  64. }
  65. [installer, deployer]*.pom*.whenConfigured { pom ->
  66. // Remove test scope dependencies from published poms
  67. pom.dependencies = pom.dependencies.findAll {it.scope != 'test'}
  68. pom.dependencies.findAll { dep ->
  69. optionalDeps.contains(dep.artifactId) ||
  70. dep.groupId.startsWith('org.apache.directory') ||
  71. dep.groupId.startsWith('org.slf4j')
  72. }*.optional = true
  73. pom.dependencies.add(cloggingDep(pom.dependencies[0].class))
  74. if (pom.artifactId == 'spring-security-config') {
  75. pom.dependencies.find { dep -> dep.artifactId == 'spring-security-web'}.optional = true
  76. pom.dependencies.find { dep -> dep.artifactId == 'spring-web'}.optional = true
  77. }
  78. }