maven-deployment.gradle 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. apply plugin: 'maven'
  2. // Create a source jar for uploading
  3. task sourceJar(type: Jar) {
  4. classifier = 'sources'
  5. from sourceSets.main.java.srcDirs
  6. include '**/*.java', '**/*.aj'
  7. }
  8. artifacts {
  9. archives sourceJar
  10. archives javadocJar
  11. }
  12. // Configuration for SpringSource s3 maven deployer
  13. configurations {
  14. deployerJars
  15. }
  16. dependencies {
  17. deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE"
  18. }
  19. // Remove the archive configuration from the runtime configuration, so that anything added to archives
  20. // (such as the source jar) is no longer included in the runtime classpath
  21. configurations.default.extendsFrom = [configurations.runtime] as Set
  22. // Add the main jar into the default configuration
  23. artifacts { 'default' jar }
  24. install {
  25. customizePom(repositories.mavenInstaller.pom, project)
  26. }
  27. def customizePom(pom, gradleProject) {
  28. def optionalDeps = ['ehcache', 'log4j', 'apacheds-core', 'jsp-api', 'jsr250-api', 'ldapsdk', 'aspectjrt', 'aspectjweaver']
  29. pom.scopeMappings.addMapping(10, configurations.provided, 'provided')
  30. pom.whenConfigured { p ->
  31. // Remove test scope dependencies from published poms
  32. p.dependencies = p.dependencies.findAll {it.scope != 'test'}
  33. // Flag optional deps
  34. p.dependencies.findAll { dep ->
  35. optionalDeps.contains(dep.artifactId) ||
  36. dep.groupId.startsWith('org.apache.directory') ||
  37. dep.groupId.startsWith('org.slf4j')
  38. }*.optional = true
  39. // Hack for specific case of config module
  40. if (p.artifactId == 'spring-security-config') {
  41. p.dependencies.find { dep -> dep.artifactId == 'spring-security-ldap'}.optional = true
  42. p.dependencies.find { dep -> dep.artifactId == 'spring-ldap-core'}.optional = true
  43. p.dependencies.find { dep -> dep.groupId.startsWith "org.apache.directory" }*.optional = true
  44. p.dependencies.find { dep -> dep.artifactId == 'spring-security-web'}.optional = true
  45. p.dependencies.find { dep -> dep.artifactId == 'spring-security-openid'}.optional = true
  46. p.dependencies.find { dep -> dep.artifactId == 'guice'}.optional = true
  47. p.dependencies.find { dep -> dep.artifactId == 'openid4java-nodeps'}.optional = true
  48. p.dependencies.find { dep -> dep.artifactId == 'spring-jdbc'}.optional = true
  49. p.dependencies.find { dep -> dep.artifactId == 'spring-tx'}.optional = true
  50. p.dependencies.find { dep -> dep.artifactId == 'spring-web'}.optional = true
  51. }
  52. if (p.artifactId == 'spring-security-core') {
  53. p.dependencies.find { dep -> dep.artifactId == 'spring-jdbc'}.optional = true
  54. p.dependencies.find { dep -> dep.artifactId == 'spring-tx'}.optional = true
  55. p.dependencies.removeAll { dep -> dep.artifactId == 'spring-security-crypto' }
  56. }
  57. }
  58. pom.project {
  59. name = gradleProject.name
  60. description = gradleProject.name
  61. url = 'http://springsource.org/spring-security'
  62. organization {
  63. name = 'SpringSource'
  64. url = 'http://springsource.org/'
  65. }
  66. licenses {
  67. license {
  68. name 'The Apache Software License, Version 2.0'
  69. url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  70. distribution 'repo'
  71. }
  72. }
  73. scm {
  74. url = 'https://github.com/SpringSource/spring-security'
  75. connection = 'scm:git:git://github.com/SpringSource/spring-security'
  76. developerConnection = 'scm:git:git://github.com/SpringSource/spring-security'
  77. }
  78. developers {
  79. developer {
  80. id = 'rwinch'
  81. name = 'Rob Winch'
  82. email = 'rwinch@vmware.com'
  83. }
  84. }
  85. repositories {
  86. repository {
  87. id 'spring-milestone'
  88. url 'http://repo.springsource.org/libs-milestone'
  89. }
  90. }
  91. dependencies {
  92. dependency {
  93. artifactId = groupId = 'commons-logging'
  94. scope = 'compile'
  95. optional = 'true'
  96. version = '1.1.1'
  97. }
  98. }
  99. }
  100. }
  101. task generatePom {
  102. group = 'Build'
  103. description = 'Generates the Maven pom.xml'
  104. ext.generatedPomFileName = 'pom.xml'
  105. inputs.files('**/*.gradle')
  106. outputs.files(generatedPomFileName)
  107. doLast() {
  108. def p = pom {}
  109. customizePom(p, project)
  110. p.writeTo(generatedPomFileName)
  111. }
  112. }