Skip to content

Commit 8ddccad

Browse files
committed
Use the 'io.freefair.aspectj' gradle plugin
see spring-projects/spring-security#7183 see spring-projects#23282
1 parent 0d3fb0e commit 8ddccad

File tree

2 files changed

+9
-78
lines changed

2 files changed

+9
-78
lines changed

Diff for: build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ plugins {
1515
id 'io.spring.nohttp' version '0.0.3.RELEASE'
1616
id 'de.undercouch.download' version '4.0.0'
1717
id "com.jfrog.artifactory" version '4.9.8' apply false
18+
id "io.freefair.aspectj" version "4.0.0" apply false
1819
}
1920

2021
ext {

Diff for: spring-aspects/spring-aspects.gradle

+8-78
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,18 @@
11
description = "Spring Aspects"
22

3-
// Redefine the compileJava and compileTestJava tasks in order to compile sources with ajc instead of javac
3+
apply plugin: "io.freefair.aspectj"
44

5-
configurations {
6-
rt
7-
ajc
8-
aspects
9-
ajInpath
10-
}
11-
12-
compileJava {
13-
actions = []
14-
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileJava")
15-
16-
def outputDir = project.sourceSets.main.java.outputDir
17-
inputs.files(project.sourceSets.main.allSource + project.sourceSets.main.compileClasspath)
18-
outputs.dir outputDir
19-
20-
sourceCompatibility = 1.8 // fixed even when general compatibility level set to e.g. 10
21-
targetCompatibility = 1.8
22-
23-
doLast{
24-
// Assemble runtime classpath from folders and JARs that actually exist
25-
def runtimeClasspath = project.files(sourceSets.main.runtimeClasspath.files.findAll({ it.exists() }))
26-
27-
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties",
28-
classpath: configurations.ajc.asPath)
29-
30-
ant.iajc(source: sourceCompatibility, target: targetCompatibility,
31-
maxmem: "1024m", fork: "true", Xlint: "ignore",
32-
destDir: outputDir.absolutePath,
33-
aspectPath: configurations.aspects.asPath,
34-
inpath: configurations.ajInpath.asPath,
35-
sourceRootCopyFilter: "**/*.java,**/*.aj",
36-
classpath: (runtimeClasspath + configurations.rt).asPath) {
37-
sourceroots {
38-
sourceSets.main.java.srcDirs.each {
39-
pathelement(location:it.absolutePath)
40-
}
41-
}
42-
}
43-
}
44-
}
45-
46-
compileTestJava {
47-
actions = []
48-
dependsOn configurations.ajc.getTaskDependencyFromProjectDependency(true, "compileTestJava")
49-
dependsOn jar
50-
51-
def outputDir = project.sourceSets.test.java.outputDir
52-
inputs.files(project.sourceSets.test.allSource + project.sourceSets.test.compileClasspath)
53-
outputs.dir outputDir
54-
55-
sourceCompatibility = 1.8 // fixed even when general compatibility level set to e.g. 10
56-
targetCompatibility = 1.8
5+
sourceSets.main.aspectj.srcDir "src/main/java"
6+
sourceSets.main.java.srcDirs = files()
577

58-
doLast{
59-
// Assemble runtime classpath from folders and JARs that actually exist
60-
def runtimeClasspath = project.files(sourceSets.test.runtimeClasspath.files.findAll({ it.exists() }))
61-
62-
ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties",
63-
classpath: configurations.ajc.asPath)
64-
65-
ant.iajc(source: sourceCompatibility, target: targetCompatibility,
66-
maxmem: "1024m", fork: "true", Xlint: "ignore",
67-
destDir: outputDir.absolutePath,
68-
aspectPath: jar.archivePath,
69-
inpath: configurations.ajInpath.asPath,
70-
classpath: (runtimeClasspath + project.files(jar.archivePath) + configurations.rt).asPath) {
71-
sourceroots {
72-
sourceSets.test.java.srcDirs.each {
73-
pathelement(location:it.absolutePath)
74-
}
75-
}
76-
}
77-
}
78-
}
8+
sourceSets.test.aspectj.srcDir "src/test/java"
9+
sourceSets.test.java.srcDirs = files()
7910

11+
aspectj.version = aspectjVersion
8012

8113
dependencies {
82-
aspects(project(":spring-orm"))
83-
ajc("org.aspectj:aspectjtools:${aspectjVersion}")
84-
rt("org.aspectj:aspectjrt:${aspectjVersion}")
85-
compile("org.aspectj:aspectjweaver:${aspectjVersion}")
14+
aspect(project(":spring-orm"))
15+
compile("org.aspectj:aspectjrt:${aspectjVersion}")
8616
optional(project(":spring-aop")) // for @Async support
8717
optional(project(":spring-beans")) // for @Configurable support
8818
optional(project(":spring-context")) // for @Enable* support

0 commit comments

Comments
 (0)