maven.gradle 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. deployer = repositories.mavenDeployer {
  32. configuration = configurations.deployerJars
  33. if (releaseBuild) {
  34. // "mavenSyncRepoDir" should be set in properties
  35. repository(url: mavenSyncRepoDir)
  36. } else {
  37. s3credentials = [userName: s3AccessKey, passphrase: s3SecretAccessKey]
  38. repository(url: "s3://maven.springframework.org/milestone") {
  39. authentication(s3credentials)
  40. }
  41. snapshotRepository(url: "s3://maven.springframework.org/snapshot") {
  42. authentication(s3credentials)
  43. }
  44. }
  45. }
  46. }
  47. // Pom Customization
  48. installer = install.repositories.mavenInstaller
  49. def optionalDeps = ['commons-logging', 'ehcache', 'log4j', 'apacheds-core', 'jsp-api', 'jsr250-api', 'ldapsdk']
  50. [installer, deployer]*.pom.collect { pom ->
  51. pom.scopeMappings.addMapping(10, configurations.provided, 'provided')
  52. }
  53. [installer, deployer]*.pom*.whenConfigured { pom ->
  54. pom.dependencies.findAll { dep ->
  55. optionalDeps.contains(dep.artifactId) ||
  56. dep.groupId.startsWith('org.apache.directory') ||
  57. dep.groupId.startsWith('org.slf4j')
  58. }*.optional = true
  59. if (pom.artifactId == 'spring-security-config') {
  60. pom.dependencies.find { dep -> dep.artifactId == 'spring-security-web'}.optional = true
  61. pom.dependencies.find { dep -> dep.artifactId == 'spring-web'}.optional = true
  62. }
  63. }