spring-security/gradle/maven-deployment.gradle

148 lines
3.5 KiB
Groovy
Raw Normal View History

2010-03-28 18:54:41 -04:00
apply plugin: 'maven'
// Create a source jar for uploading
task sourceJar(type: Jar) {
2015-03-23 12:14:26 -04:00
classifier = 'sources'
from sourceSets.main.java.srcDirs
include '**/*.java', '**/*.aj'
}
artifacts {
2015-03-23 12:14:26 -04:00
archives sourceJar
}
// Configuration for SpringSource s3 maven deployer
configurations {
2015-03-23 12:14:26 -04:00
deployerJars
}
dependencies {
2015-03-23 12:14:26 -04:00
deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE"
}
install {
2015-03-23 12:14:26 -04:00
repositories.mavenInstaller {
customizePom(pom, project)
}
}
def customizePom(pom, gradleProject) {
2015-03-23 12:14:26 -04:00
pom.whenConfigured { p ->
p.dependencies.findAll{ it.scope == "optional" }.each {
it.scope = "compile"
it.optional = true
}
p.dependencies.findAll{ it.groupId == "org.springframework" }.each {
it.version = null
}
2015-03-23 12:14:26 -04:00
// sort to make pom dependencies order consistent to ease comparison of older poms
p.dependencies = p.dependencies.sort { dep ->
"$dep.scope:$dep.optional:$dep.groupId:$dep.artifactId"
}
}
def isWar = project.hasProperty('war')
pom.project {
name = gradleProject.name
if(isWar) {
packaging = "war"
}
description = gradleProject.name
url = 'http://spring.io/spring-security'
organization {
name = 'spring.io'
url = 'http://spring.io/'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
scm {
url = 'https://github.com/spring-projects/spring-security'
connection = 'scm:git:git://github.com/spring-projects/spring-security'
developerConnection = 'scm:git:git://github.com/spring-projects/spring-security'
}
developers {
developer {
id = 'rwinch'
name = 'Rob Winch'
email = 'rwinch@gopivotal.com'
}
}
if(!gradleProject.name.endsWith('-bom')) {
dependencyManagement {
dependencies {
dependency {
groupId 'org.springframework'
artifactId 'spring-framework-bom'
version project.springVersion
type 'pom'
scope 'import'
}
}
}
}
2015-03-23 12:14:26 -04:00
if(isWar) {
properties {
'm2eclipse.wtp.contextRoot' '/' + project.war.baseName
}
}
if(project.snapshotBuild) {
repositories {
repository {
id 'spring-snasphot'
url 'https://repo.spring.io/snapshot'
}
}
} else if(!project.releaseBuild) {
repositories {
repository {
id 'spring-milestone'
url 'https://repo.spring.io/milestone'
}
}
}
}
2014-12-08 14:18:45 -05:00
2015-03-23 12:14:26 -04:00
// http://forums.gradle.org/gradle/topics/after_upgrade_gradle_to_2_0_version_the_maven_pom_not_support_build_property
pom.withXml {
def plugins = asNode().appendNode('build').appendNode('plugins')
plugins
.appendNode('plugin')
.appendNode('artifactId','maven-compiler-plugin').parent()
.appendNode('configuration')
.appendNode('source','1.7').parent()
.appendNode('target','1.7')
if(isWar) {
plugins
.appendNode('plugin')
.appendNode('artifactId','maven-war-plugin').parent()
.appendNode('version','2.3').parent()
.appendNode('configuration')
.appendNode('failOnMissingWebXml','false')
}
}
}
task generatePom {
2015-03-23 12:14:26 -04:00
group = 'Build'
description = 'Generates a Maven pom.xml'
2015-03-23 12:14:26 -04:00
ext.generatedPomFileName = "pom.xml"
onlyIf { install.enabled }
2015-03-23 12:14:26 -04:00
inputs.files(fileTree(project.rootProject.rootDir).include("**/*.gradle").files)
inputs.files(new File(project.rootProject.rootDir, Project.GRADLE_PROPERTIES))
outputs.files(generatedPomFileName)
2015-03-23 12:14:26 -04:00
doLast() {
def p = pom {}
customizePom(p, project)
p.writeTo(generatedPomFileName)
}
2013-07-15 23:13:15 -04:00
}
build.dependsOn generatePom