Skip to content

Commit

Permalink
Fix and refactor spring-aspects build
Browse files Browse the repository at this point in the history
 - Fix compileTestJava issue in which test classes were not being
   compiled or run

 - Use built-in eclipse.project DSL instead of withXml closure
   to add AspectJ nature and builder

 - Rename {aspectJ=>aspects}.gradle and format source
  • Loading branch information
cbeams committed Jan 31, 2012
1 parent 77d8e81 commit 5ea51f4
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 82 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Expand Up @@ -432,14 +432,18 @@ project('spring-struts') {

project('spring-aspects') {
description = 'Spring Aspects'
apply from: 'aspectJ.gradle'
apply from: 'aspects.gradle'
dependencies {
compile project(":spring-orm")
aspects project(":spring-orm")
ajc "org.aspectj:aspectjtools:1.6.8"
compile "org.aspectj:aspectjrt:1.6.8"
testCompile project(":spring-test")
}
eclipse.project {
natures += 'org.eclipse.ajdt.ui.ajnature'
buildCommand 'org.eclipse.ajdt.core.ajbuilder'
}
}

configure(rootProject) {
Expand Down
81 changes: 0 additions & 81 deletions spring-aspects/aspectJ.gradle

This file was deleted.

66 changes: 66 additions & 0 deletions spring-aspects/aspects.gradle
@@ -0,0 +1,66 @@
// redefine the compileJava and compileTestJava tasks in order to
// compile sources with ajc instead of javac

configurations {
ajc
aspects
ajInpath
}

task compileJava(overwrite: true) {
dependsOn JavaPlugin.PROCESS_RESOURCES_TASK_NAME
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileJava")

def outputDir = project.sourceSets.main.output.classesDir

inputs.files(project.sourceSets.main.allSource + project.sourceSets.main.compileClasspath)
outputs.dir outputDir

doLast{
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties",
classpath: configurations.ajc.asPath)

ant.iajc(source: sourceCompatibility, target: targetCompatibility,
maxmem: "1024m", fork: "true", Xlint: "ignore",
destDir: outputDir.absolutePath,
aspectPath: configurations.aspects.asPath,
inpath: configurations.ajInpath.asPath,
sourceRootCopyFilter: "**/*.java",
classpath: configurations.compile.asPath) {
sourceroots {
sourceSets.main.java.srcDirs.each {
pathelement(location:it.absolutePath)
}
}
}
}
}

task compileTestJava(overwrite: true) {
dependsOn JavaPlugin.PROCESS_TEST_RESOURCES_TASK_NAME
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileTestJava")
dependsOn jar

def outputDir = project.sourceSets.test.output.classesDir

inputs.files(project.sourceSets.test.allSource + project.sourceSets.test.compileClasspath)
outputs.dir outputDir

doLast{
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties",
classpath: configurations.ajc.asPath)

ant.iajc(source: sourceCompatibility, target: targetCompatibility,
maxmem: "1024m", fork: "true", Xlint: "ignore",
destDir: outputDir.absolutePath,
aspectPath: jar.archivePath,
inpath: configurations.ajInpath.asPath,
classpath: configurations.testRuntime.asPath + configurations.compile.asPath + jar.archivePath) {
sourceroots {
sourceSets.test.java.srcDirs.each {
pathelement(location:it.absolutePath)
}
}
}
}
}

0 comments on commit 5ea51f4

Please sign in to comment.