maven.gradle 2.3 KB

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