maven.gradle 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. configurations {
  8. deployerJars
  9. }
  10. artifacts {
  11. archives sourceJar
  12. }
  13. dependencies {
  14. deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE"
  15. }
  16. gradle.taskGraph.whenReady {graph ->
  17. if (graph.hasTask(uploadArchives)) {
  18. // check properties defined and fail early
  19. s3AccessKey
  20. s3SecretAccessKey
  21. }
  22. }
  23. def deployer = null
  24. uploadArchives {
  25. deployer = repositories.mavenDeployer {
  26. configuration = configurations.deployerJars
  27. }
  28. doFirst {
  29. if (releaseBuild) {
  30. // "mavenSyncRepoDir" should be set in properties
  31. repository(url: mavenSyncRepoDir)
  32. } else {
  33. s3credentials = [userName: s3AccessKey, passphrase: s3SecretAccessKey]
  34. repository(url: "s3://maven.springframework.org/milestone") {
  35. authentication(s3credentials)
  36. }
  37. snapshotRepository(url: "s3://maven.springframework.org/snapshot") {
  38. authentication(s3credentials)
  39. }
  40. }
  41. }
  42. }
  43. // Pom Customization
  44. installer = install.repositories.mavenInstaller
  45. def optionalDeps = ['commons-logging', 'ehcache', 'log4j', 'apacheds-core', 'jsp-api', 'jsr250-api', 'ldapsdk']
  46. [installer, deployer]*.pom.collect { pom ->
  47. pom.scopeMappings.addMapping(10, configurations.provided, 'provided')
  48. }
  49. [installer, deployer]*.pom*.whenConfigured { pom ->
  50. pom.dependencies.findAll { dep ->
  51. optionalDeps.contains(dep.artifactId) ||
  52. dep.groupId.startsWith('org.apache.directory') ||
  53. dep.groupId.startsWith('org.slf4j')
  54. }*.optional = true
  55. if (pom.artifactId == 'spring-security-config') {
  56. pom.dependencies.find { dep -> dep.artifactId == 'spring-security-web'}.optional = true
  57. pom.dependencies.find { dep -> dep.artifactId == 'spring-web'}.optional = true
  58. }
  59. }