Browse Source

Use the 'io.freefair.aspectj' Gradle plugin

See gh-23282
See spring-projects/spring-security#7183
Closes gh-23506
pull/23569/head
Lars Grefer 6 years ago committed by Brian Clozel
parent
commit
fbee3ed889
  1. 1
      build.gradle
  2. 86
      spring-aspects/spring-aspects.gradle

1
build.gradle

@ -15,6 +15,7 @@ plugins {
id 'io.spring.nohttp' version '0.0.3.RELEASE' id 'io.spring.nohttp' version '0.0.3.RELEASE'
id 'de.undercouch.download' version '4.0.0' id 'de.undercouch.download' version '4.0.0'
id "com.jfrog.artifactory" version '4.9.8' apply false id "com.jfrog.artifactory" version '4.9.8' apply false
id "io.freefair.aspectj" version "4.0.0" apply false
} }
ext { ext {

86
spring-aspects/spring-aspects.gradle

@ -1,88 +1,18 @@
description = "Spring Aspects" description = "Spring Aspects"
// Redefine the compileJava and compileTestJava tasks in order to compile sources with ajc instead of javac apply plugin: "io.freefair.aspectj"
configurations { sourceSets.main.aspectj.srcDir "src/main/java"
rt sourceSets.main.java.srcDirs = files()
ajc
aspects
ajInpath
}
compileJava {
actions = []
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileJava")
def outputDir = project.sourceSets.main.java.outputDir
inputs.files(project.sourceSets.main.allSource + project.sourceSets.main.compileClasspath)
outputs.dir outputDir
sourceCompatibility = 1.8 // fixed even when general compatibility level set to e.g. 10
targetCompatibility = 1.8
doLast{
// Assemble runtime classpath from folders and JARs that actually exist
def runtimeClasspath = project.files(sourceSets.main.runtimeClasspath.files.findAll({ it.exists() }))
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,**/*.aj",
classpath: (runtimeClasspath + configurations.rt).asPath) {
sourceroots {
sourceSets.main.java.srcDirs.each {
pathelement(location:it.absolutePath)
}
}
}
}
}
compileTestJava {
actions = []
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileTestJava")
dependsOn jar
def outputDir = project.sourceSets.test.java.outputDir
inputs.files(project.sourceSets.test.allSource + project.sourceSets.test.compileClasspath)
outputs.dir outputDir
sourceCompatibility = 1.8 // fixed even when general compatibility level set to e.g. 10
targetCompatibility = 1.8
doLast{ sourceSets.test.aspectj.srcDir "src/test/java"
// Assemble runtime classpath from folders and JARs that actually exist sourceSets.test.java.srcDirs = files()
def runtimeClasspath = project.files(sourceSets.test.runtimeClasspath.files.findAll({ it.exists() }))
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: (runtimeClasspath + project.files(jar.archivePath) + configurations.rt).asPath) {
sourceroots {
sourceSets.test.java.srcDirs.each {
pathelement(location:it.absolutePath)
}
}
}
}
}
aspectj.version = aspectjVersion
dependencies { dependencies {
aspects(project(":spring-orm")) aspect(project(":spring-orm"))
ajc("org.aspectj:aspectjtools:${aspectjVersion}") compile("org.aspectj:aspectjrt:${aspectjVersion}")
rt("org.aspectj:aspectjrt:${aspectjVersion}")
compile("org.aspectj:aspectjweaver:${aspectjVersion}")
optional(project(":spring-aop")) // for @Async support optional(project(":spring-aop")) // for @Async support
optional(project(":spring-beans")) // for @Configurable support optional(project(":spring-beans")) // for @Configurable support
optional(project(":spring-context")) // for @Enable* support optional(project(":spring-context")) // for @Enable* support

Loading…
Cancel
Save