134 lines
3.8 KiB
Groovy
134 lines
3.8 KiB
Groovy
apply plugin: 'maven'
|
|
|
|
// Create a source jar for uploading
|
|
task sourceJar(type: Jar) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.java.srcDirs
|
|
include '**/*.java', '**/*.aj'
|
|
}
|
|
|
|
artifacts {
|
|
archives sourceJar
|
|
}
|
|
|
|
// Configuration for SpringSource s3 maven deployer
|
|
configurations {
|
|
deployerJars
|
|
}
|
|
dependencies {
|
|
deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE"
|
|
}
|
|
|
|
install {
|
|
repositories.mavenInstaller {
|
|
customizePom(pom, project)
|
|
}
|
|
}
|
|
|
|
def customizePom(pom, gradleProject) {
|
|
pom.whenConfigured { p ->
|
|
p.dependencies.findAll{ it.scope == "optional" }.each {
|
|
it.scope = "compile"
|
|
it.optional = true
|
|
}
|
|
// 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(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'
|
|
}
|
|
}
|
|
}
|
|
build {
|
|
plugins {
|
|
plugin {
|
|
groupId = 'org.apache.maven.plugins'
|
|
artifactId = 'maven-compiler-plugin'
|
|
configuration {
|
|
source = '1.7'
|
|
target = '1.7'
|
|
}
|
|
}
|
|
if(isWar) {
|
|
plugin {
|
|
groupId = 'org.apache.maven.plugins'
|
|
artifactId = 'maven-war-plugin'
|
|
version = '2.3'
|
|
configuration {
|
|
failOnMissingWebXml = 'false'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task generatePom {
|
|
group = 'Build'
|
|
description = 'Generates a Maven pom.xml'
|
|
|
|
ext.generatedPomFileName = "pom.xml"
|
|
onlyIf { install.enabled }
|
|
|
|
inputs.files(fileTree(project.rootProject.rootDir).include("**/*.gradle").files)
|
|
inputs.files(new File(project.rootProject.rootDir, Project.GRADLE_PROPERTIES))
|
|
outputs.files(generatedPomFileName)
|
|
|
|
doLast() {
|
|
def p = pom {}
|
|
customizePom(p, project)
|
|
p.writeTo(generatedPomFileName)
|
|
}
|
|
}
|
|
|
|
build.dependsOn generatePom
|