Skip to content

Commit

Permalink
SEC-1906: Update to Gradle 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rwinch committed Jul 5, 2012
1 parent 2fba10a commit a2452ab
Show file tree
Hide file tree
Showing 24 changed files with 201 additions and 243 deletions.
18 changes: 9 additions & 9 deletions build.gradle
Expand Up @@ -4,8 +4,8 @@ description = 'Spring Security'

allprojects {
version = '3.1.1.CI-SNAPSHOT'
releaseBuild = version.endsWith('RELEASE')
snapshotBuild = version.endsWith('SNAPSHOT')
ext.releaseBuild = version.endsWith('RELEASE')
ext.snapshotBuild = version.endsWith('SNAPSHOT')

group = 'org.springframework.security'

Expand All @@ -16,19 +16,19 @@ allprojects {
}

// Set up different subproject lists for individual configuration
javaProjects = subprojects.findAll { project -> project.name != 'docs' && project.name != 'faq' && project.name != 'manual' }
sampleProjects = subprojects.findAll { project -> project.name.startsWith('spring-security-samples') }
itestProjects = subprojects.findAll { project -> project.name.startsWith('itest') }
coreModuleProjects = javaProjects - sampleProjects - itestProjects
aspectjProjects = [project(':spring-security-aspects'), project(':spring-security-samples-aspectj')]
ext.javaProjects = subprojects.findAll { project -> project.name != 'docs' && project.name != 'faq' && project.name != 'manual' }
ext.sampleProjects = subprojects.findAll { project -> project.name.startsWith('spring-security-samples') }
ext.itestProjects = subprojects.findAll { project -> project.name.startsWith('itest') }
ext.coreModuleProjects = javaProjects - sampleProjects - itestProjects
ext.aspectjProjects = [project(':spring-security-aspects'), project(':spring-security-samples-aspectj')]

configure(javaProjects) {
apply from: "$rootDir/gradle/javaprojects.gradle"
}

configure(coreModuleProjects) {
// Gives better names in structure101 jar diagram
sourceSets.main.classesDir = new File(buildDir, "classes/" + project.name.substring("spring-security".length() + 1))
sourceSets.main.output.classesDir = new File(buildDir, "classes/" + project.name.substring("spring-security".length() + 1))
apply plugin: 'bundlor'
bundlor.expansions = bundlorProperties
apply from: "$rootDir/gradle/maven-deployment.gradle"
Expand Down Expand Up @@ -75,5 +75,5 @@ task uploadDist(type: S3DistroUpload) {
apply from: "$rootDir/gradle/ide-integration.gradle"

task wrapper(type: Wrapper) {
gradleVersion = '1.0-milestone-3'
gradleVersion = '1.0'
}
16 changes: 8 additions & 8 deletions buildSrc/build.gradle
Expand Up @@ -3,8 +3,14 @@ apply plugin: 'groovy'
repositories {
mavenLocal()
mavenCentral()
mavenRepo name: 'SpringSource Enterprise Release', urls: 'http://repository.springsource.com/maven/bundles/release'
mavenRepo name: 'SpringSource Enterprise External', urls: 'http://repository.springsource.com/maven/bundles/external'
maven {
name = 'SpringSource Enterprise Release'
url = 'http://repository.springsource.com/maven/bundles/release'
}
maven {
name = 'SpringSource Enterprise External'
url = 'http://repository.springsource.com/maven/bundles/external'
}
}

// Docbook Plugin
Expand Down Expand Up @@ -48,9 +54,3 @@ task ide(type: Copy) {
from configurations.runtime
into 'ide'
}

apply plugin: 'idea'

ideaModule {
excludeDirs += file('.gradle')
}
18 changes: 9 additions & 9 deletions buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy
Expand Up @@ -12,7 +12,7 @@ import org.gradle.api.GradleException
import org.gradle.plugins.ide.eclipse.GenerateEclipseProject
import org.gradle.plugins.ide.eclipse.GenerateEclipseClasspath
import org.gradle.plugins.ide.eclipse.model.BuildCommand
import org.gradle.tooling.model.ProjectDependency
import org.gradle.plugins.ide.eclipse.model.ProjectDependency

/**
*
Expand Down Expand Up @@ -41,27 +41,27 @@ class AspectJPlugin implements Plugin<Project> {
dependsOn project.processResources
sourceSet = project.sourceSets.main
inputs.files(sourceSet.java.srcDirs)
outputs.dir(sourceSet.classesDir)
outputs.dir(sourceSet.output.classesDir)
aspectPath = project.configurations.aspectpath
}

project.tasks.add(name: 'compileTestJava', overwrite: true, description: 'Compiles AspectJ Test Source', type: Ajc) {
dependsOn project.processTestResources, project.compileJava, project.jar
sourceSet = project.sourceSets.test
inputs.files(sourceSet.java.srcDirs)
outputs.dir(sourceSet.classesDir)
outputs.dir(sourceSet.output.classesDir)
aspectPath = project.files(project.configurations.aspectpath, project.jar.archivePath)
}

project.tasks.withType(GenerateEclipseProject).all {
whenConfigured { p ->
project.tasks.withType(GenerateEclipseProject) {
project.eclipse.project.file.whenMerged { p ->
p.natures.add(0, 'org.eclipse.ajdt.ui.ajnature')
p.buildCommands = [new BuildCommand('org.eclipse.ajdt.core.ajbuilder',[:])]
p.buildCommands = [new BuildCommand('org.eclipse.ajdt.core.ajbuilder')]
}
}

project.tasks.withType(GenerateEclipseClasspath).all {
whenConfigured { classpath ->
project.tasks.withType(GenerateEclipseClasspath) {
project.eclipse.classpath.file.whenMerged { classpath ->
def entries = classpath.entries.findAll { it instanceof ProjectDependency}.findAll { entry ->
def projectPath = entry.path.replaceAll('/',':')
project.rootProject.findProject(projectPath).plugins.findPlugin(AspectJPlugin)
Expand All @@ -86,7 +86,7 @@ class Ajc extends DefaultTask {
def compile() {
logger.info("Running ajc ...")
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: project.configurations.ajtools.asPath)
ant.iajc(classpath: sourceSet.compileClasspath.asPath, fork: 'true', destDir: sourceSet.classesDir.absolutePath,
ant.iajc(classpath: sourceSet.compileClasspath.asPath, fork: 'true', destDir: sourceSet.output.classesDir.absolutePath,
source: project.convention.plugins.java.sourceCompatibility,
target: project.convention.plugins.java.targetCompatibility,
aspectPath: aspectPath.asPath, sourceRootCopyFilter: '**/*.java', showWeaveInfo: 'true') {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/bundlor/BundlorPlugin.groovy
Expand Up @@ -76,7 +76,7 @@ public class Bundlor extends DefaultTask {
manifestTemplate = null
}

inputPaths = project.files(project.sourceSets.main.classesDir)
inputPaths = project.files(project.sourceSets.main.output.classesDir)

if (manifestTemplate != null) {
project.jar.manifest.from manifest
Expand Down
2 changes: 1 addition & 1 deletion config/config.gradle
Expand Up @@ -27,7 +27,7 @@ dependencies {

testCompile project(':spring-security-ldap'),
project(':spring-security-openid'),
project(':spring-security-core').sourceSets.test.classes,
project(':spring-security-core').sourceSets.test.output,
'javax.annotation:jsr250-api:1.0',
"org.springframework.ldap:spring-ldap-core:$springLdapVersion",
"org.springframework:spring-expression:$springVersion",
Expand Down
15 changes: 2 additions & 13 deletions core/core.gradle
Expand Up @@ -2,7 +2,7 @@

// We don't define a module dependency on crypto to avoid creating a transitive dependency
def cryptoProject = project(':spring-security-crypto')
def cryptoClasses = cryptoProject.sourceSets.main.classes
def cryptoClasses = cryptoProject.sourceSets.main.output

dependencies {
compile cryptoProject,
Expand Down Expand Up @@ -31,7 +31,7 @@ classes.dependsOn cryptoProject.classes
classes.doLast {
copy {
from cryptoClasses
into sourceSets.main.classesDir
into sourceSets.main.output.classesDir
}
}

Expand All @@ -43,15 +43,4 @@ sourceJar.from cryptoProject.sourceSets.main.java
test {
systemProperties['springSecurityVersion'] = version
systemProperties['springVersion'] = springVersion
}

// Add the crypto module in the IDE
ideaModule {
def cryptoDep = new org.gradle.plugins.ide.idea.model.ModuleDependency('spring-security-crypto', 'COMPILE')
cryptoDep.exported = true
module.dependencies.add(cryptoDep)
}

eclipseProject {
referencedProjects.add('spring-security-crypto')
}
7 changes: 3 additions & 4 deletions docs/docs.gradle
Expand Up @@ -17,7 +17,7 @@ project('faq') {
[docbookHtml, docbookFoPdf, docbookHtmlSingle]*.sourceFileName = 'faq.xml'
docbookHtmlSingle.suffix = ''

spec = copySpec {
ext.spec = copySpec {
into ('faq') {
from("$buildDir/docs")
from("$projectDir/src/resources")
Expand All @@ -36,7 +36,7 @@ project('manual') {
// docbookFoPdf.admonGraphicsPath = "${imagesDir}/"
docbookFoPdf.imgSrcPath = "${projectDir}/src/docbook/"

spec = copySpec {
ext.spec = copySpec {
into ('reference') {
from("$buildDir/docs")
from("$projectDir/src/resources")
Expand All @@ -56,7 +56,6 @@ task reference (type: Copy) {
task apidocs(type: Javadoc) {
destinationDir = new File(buildDir, 'apidocs')
title = "Spring Security $version API"
optionsFile = file("$buildDir/tmp/javadoc.options")

source coreModuleProjects.collect { project ->
project.sourceSets.main.allJava
Expand Down Expand Up @@ -94,7 +93,7 @@ apidocs.options.groups = [

]

apiSpec = copySpec {
ext.apiSpec = copySpec {
into('apidocs') {
from(apidocs.destinationDir)
}
Expand Down
96 changes: 28 additions & 68 deletions gradle/ide-integration.gradle
Expand Up @@ -2,80 +2,40 @@ apply plugin: 'idea'

configure(javaProjects) {
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'

eclipse.classpath.downloadSources = true

ideaModule {
downloadJavadoc=false
excludeDirs.add(buildDir)
gradleCacheVariable = 'GRADLE_CACHE'
outputDir = "$rootProject.projectDir/intellij/out" as File
testOutputDir = "$rootProject.projectDir/intellij/testOut" as File
whenConfigured { module ->
def allClasses = module.dependencies.findAll() { dep ->
if (dep instanceof org.gradle.plugins.ide.idea.model.ModuleLibrary
&& dep.classes.find { path ->
path.url.matches('.*jcl-over-slf4j.*') ||
path.url.matches('.*servlet-api.*') ||
path.url.matches('.*jsp-api.*')
}) {
dep.scope = 'COMPILE'
dep.exported = false
}
}
}
}
// GRADLE-1116
eclipseClasspath.whenConfigured { classpath ->
classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') }
}
eclipseClasspath.doFirst {
eclipseClasspath.whenConfigured { classpath ->
def includeDeps = project.configurations.getByName('runtime')?.collect { f-> f.absolutePath } as Set
classpath.entries.each { cp ->
if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) {
def include = includeDeps.contains(cp.path)
def attr = 'org.eclipse.jst.component.dependency'
if(include && project.hasProperty('war')) {
// GRADLE-1426 (part a)
cp.entryAttributes.put(attr,'/WEB-INF/lib')
} else if(!include) {
// GRADLE-1422
cp.entryAttributes.remove(attr)
}
}
}
}
}
// GRADLE-1426 (part b)
project.plugins.withType(org.gradle.api.plugins.WarPlugin.class).all {
eclipseWtpComponent.whenConfigured { wtpComp ->
wtpComp.wbModuleEntries.findAll { it instanceof org.gradle.plugins.ide.eclipse.model.WbDependentModule }.each { e ->
if(!e.handle.startsWith('module:/resource/')) {
wtpComp.wbModuleEntries.remove(e)
}
}
}
}
tasks.withType(org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent) {
whenConfigured { wtpComponent ->
wtpComponent.contextPath = project.tasks.findByName('jettyRun')?.contextPath?.replaceFirst('/','')
project.eclipse.classpath.file.whenMerged { classpath->
project.eclipse.wtp.component.file.whenMerged { wtpComponent ->
wtpComponent.contextPath = project.tasks.findByName('jettyRun')?.contextPath?.replaceFirst('/','')
}
}
}
}

ideaModule {
excludeDirs += file('.gradle')
excludeDirs += file('buildSrc/build')
excludeDirs += file('buildSrc/.gradle')
}
project(':spring-security-samples-aspectj') {
task afterEclipseImport {
ext.srcFile = file('.classpath')
inputs.file srcFile
outputs.dir srcFile

onlyIf { srcFile.exists() }

ideaProject {
javaVersion = '1.6'
subprojects = [rootProject] + javaProjects
withXml { provider ->
// Use git
def node = provider.asNode()
def vcsConfig = node.component.find { it.'@name' == 'VcsDirectoryMappings' }
vcsConfig.mapping[0].'@vcs' = 'Git'
doLast {
def classpath = new XmlParser().parse(srcFile)

classpath.classpathentry.findAll{ it.@path == '/spring-security-aspects' }.each { node ->
if(node.children().size() == 0) {
def attrs = new Node(node,'attributes')
def adjtAttr = new Node(attrs,'attributes',[name: 'org.eclipse.ajdt.aspectpath', value: 'org.eclipse.ajdt.aspectpath'])
node.appendNode(adjtAttr)
}
}

def writer = new FileWriter(srcFile)
new XmlNodePrinter(new PrintWriter(writer)).print(classpath)
}
}
}
34 changes: 17 additions & 17 deletions gradle/javaprojects.gradle
@@ -1,20 +1,20 @@
apply plugin: 'java'
apply plugin: 'eclipse'

springVersion = '3.0.6.RELEASE'
springLdapVersion = '1.3.1.RELEASE'
ehcacheVersion = '1.6.2'
aspectjVersion = '1.6.10'
apacheDsVersion = '1.5.5'
jstlVersion = '1.2'
jettyVersion = '6.1.26'
hsqlVersion = '1.8.0.10'
slf4jVersion = '1.6.1'
logbackVersion = '0.9.29'
cglibVersion = '2.2'
powerMockVersion = '1.4.12'

bundlorProperties = [
ext.springVersion = '3.0.6.RELEASE'
ext.springLdapVersion = '1.3.1.RELEASE'
ext.ehcacheVersion = '1.6.2'
ext.aspectjVersion = '1.6.10'
ext.apacheDsVersion = '1.5.5'
ext.jstlVersion = '1.2'
ext.jettyVersion = '6.1.26'
ext.hsqlVersion = '1.8.0.10'
ext.slf4jVersion = '1.6.1'
ext.logbackVersion = '0.9.29'
ext.cglibVersion = '2.2'
ext.powerMockVersion = '1.4.12'

ext.bundlorProperties = [
version: version,
secRange: "[$version, 3.2.0)",
springRange: "[$springVersion, 3.2.0)",
Expand Down Expand Up @@ -55,13 +55,13 @@ sourceSets {
integrationTest {
java.srcDir file('src/integration-test/java')
resources.srcDir file('src/integration-test/resources')
compileClasspath = sourceSets.main.classes + sourceSets.test.classes + configurations.integrationTestCompile
runtimeClasspath = classes + compileClasspath + configurations.integrationTestRuntime
compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
}
}

task integrationTest(type: Test, dependsOn: jar) {
testClassesDir = sourceSets.integrationTest.classesDir
testClassesDir = sourceSets.integrationTest.output.classesDir
logging.captureStandardOutput(LogLevel.INFO)
classpath = sourceSets.integrationTest.runtimeClasspath
maxParallelForks = 1
Expand Down
2 changes: 1 addition & 1 deletion gradle/maven-deployment.gradle
Expand Up @@ -43,7 +43,7 @@ uploadArchives {
if (releaseBuild) {
repository(url: releaseRepositoryUrl)
} else {
s3credentials = [userName: project.properties.s3AccessKey, passphrase: project.properties.s3SecretAccessKey]
def s3credentials = [userName: project.properties.s3AccessKey, passphrase: project.properties.s3SecretAccessKey]
repository(url: milestoneRepositoryUrl) {
authentication(s3credentials)
}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Wed Apr 27 16:17:28 BST 2011
#Sun Jul 01 12:51:55 CDT 2012
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://repo.gradle.org/gradle/distributions/gradle-1.0-milestone-3-bin.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-bin.zip

0 comments on commit a2452ab

Please sign in to comment.