maven.gradle 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 = ['commons-logging', 'ehcache', 'log4j', 'apacheds-core', 'jsp-api', 'jsr250-api', 'ldapsdk']
  53. [installer, deployer]*.pom.collect { pom ->
  54. pom.scopeMappings.addMapping(10, configurations.provided, 'provided')
  55. }
  56. [installer, deployer]*.pom*.whenConfigured { pom ->
  57. pom.dependencies.findAll { dep ->
  58. optionalDeps.contains(dep.artifactId) ||
  59. dep.groupId.startsWith('org.apache.directory') ||
  60. dep.groupId.startsWith('org.slf4j')
  61. }*.optional = true
  62. if (pom.artifactId == 'spring-security-config') {
  63. pom.dependencies.find { dep -> dep.artifactId == 'spring-security-web'}.optional = true
  64. pom.dependencies.find { dep -> dep.artifactId == 'spring-web'}.optional = true
  65. }
  66. }