diff --git a/aspects/spring-security-aspects.gradle b/aspects/spring-security-aspects.gradle
index fbb81bb674f..51ba3fcb679 100644
--- a/aspects/spring-security-aspects.gradle
+++ b/aspects/spring-security-aspects.gradle
@@ -1,11 +1,21 @@
apply plugin: 'io.spring.convention.spring-module'
-apply plugin: 'aspectj'
+apply plugin: 'io.freefair.aspectj'
dependencies {
+ compile "org.aspectj:aspectjrt"
compile project(':spring-security-core')
compile 'org.springframework:spring-beans'
compile 'org.springframework:spring-context'
compile 'org.springframework:spring-core'
testCompile 'org.springframework:spring-aop'
+ testAspect sourceSets.main.output
}
+
+sourceSets.main.aspectj.srcDir "src/main/java"
+sourceSets.main.java.srcDirs = files()
+
+sourceSets.test.aspectj.srcDir "src/test/java"
+sourceSets.test.java.srcDirs = files()
+
+compileAspectj.ajcOptions.outxmlfile = "META-INF/aop.xml"
diff --git a/aspects/src/main/resources/META-INF/aop.xml b/aspects/src/main/resources/META-INF/aop.xml
deleted file mode 100644
index 0a39bf65c61..00000000000
--- a/aspects/src/main/resources/META-INF/aop.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build.gradle b/build.gradle
index 25a6dcd652e..ba989a600b5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,6 +3,7 @@ buildscript {
classpath 'io.spring.gradle:spring-build-conventions:0.0.23.RELEASE'
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
classpath 'io.spring.nohttp:nohttp-gradle:0.0.2.RELEASE'
+ classpath "io.freefair.gradle:aspectj-plugin:3.8.4"
}
repositories {
maven { url 'https://repo.spring.io/plugins-snapshot' }
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 1fdbd6d6fb1..a6a14441540 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -1,4 +1,4 @@
-apply plugin: 'groovy'
+apply plugin: 'java'
repositories {
mavenCentral()
diff --git a/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy b/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy
deleted file mode 100644
index eeb678ff285..00000000000
--- a/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy
+++ /dev/null
@@ -1,126 +0,0 @@
-package aspectj
-
-import org.gradle.api.Project
-import org.gradle.api.Plugin
-import org.gradle.api.tasks.TaskAction
-import org.gradle.api.logging.LogLevel
-import org.gradle.api.file.*
-import org.gradle.api.tasks.SourceSet
-import org.gradle.api.DefaultTask
-import org.gradle.api.GradleException
-
-import org.gradle.api.plugins.JavaPlugin
-import org.gradle.api.tasks.compile.JavaCompile
-import org.gradle.plugins.ide.eclipse.GenerateEclipseProject
-import org.gradle.plugins.ide.eclipse.GenerateEclipseClasspath
-import org.gradle.plugins.ide.eclipse.EclipsePlugin
-import org.gradle.plugins.ide.eclipse.model.BuildCommand
-import org.gradle.plugins.ide.eclipse.model.ProjectDependency
-
-/**
- *
- * @author Luke Taylor
- */
-class AspectJPlugin implements Plugin {
-
- void apply(Project project) {
- project.plugins.apply(JavaPlugin)
-
- if (project.configurations.findByName('ajtools') == null) {
- project.configurations.create('ajtools')
- project.dependencies {
- ajtools "org.aspectj:aspectjtools"
- optional "org.aspectj:aspectjrt"
- }
- }
-
- if (project.configurations.findByName('aspectpath') == null) {
- project.configurations.create('aspectpath')
- }
-
- project.afterEvaluate {
- setupAspectJ(project)
- }
- }
-
- void setupAspectJ(Project project) {
- project.tasks.withType(JavaCompile) { javaCompileTask ->
- def javaCompileTaskName = javaCompileTask.name
- def ajCompileTask = project.tasks.create(name: javaCompileTaskName + 'Aspect', overwrite: true, description: 'Compiles AspectJ Source', type: Ajc) {
- inputs.files(javaCompileTask.inputs.files)
- inputs.properties(javaCompileTask.inputs.properties.findAll {it.value != null})
-
- sourceRoots.addAll(project.sourceSets.main.java.srcDirs)
- if(javaCompileTaskName.contains("Test")) {
- sourceRoots.addAll(project.sourceSets.test.java.srcDirs)
- }
- compileClasspath = javaCompileTask.classpath
- destinationDir = javaCompileTask.destinationDir
- aspectPath = project.configurations.aspectpath
- }
-
- javaCompileTask.setActions Arrays.asList()
- javaCompileTask.dependsOn ajCompileTask
-
- }
-
- 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')]
- }
- }
-
- 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.allprojects.find{ p->
- if(p.plugins.findPlugin(EclipsePlugin)) {
- return p.eclipse.project.name == projectPath && p.plugins.findPlugin(AspectJPlugin)
- }
- false
- }
- }
- entries.each { entry->
- entry.entryAttributes.put('org.eclipse.ajdt.aspectpath','org.eclipse.ajdt.aspectpath')
- }
- }
- }
- }
-}
-
-class Ajc extends DefaultTask {
- Set sourceRoots = []
- FileCollection compileClasspath
- File destinationDir
- FileCollection aspectPath
-
- Ajc() {
- logging.captureStandardOutput(LogLevel.INFO)
- }
-
- @TaskAction
- def compile() {
- logger.info("="*30)
- logger.info("="*30)
- logger.info("Running ajc ...")
- logger.info("classpath: ${compileClasspath?.files}")
- logger.info("srcDirs ${sourceRoots}")
- ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: project.configurations.ajtools.asPath)
- if(sourceRoots.empty) {
- return
- }
- ant.iajc(classpath: compileClasspath.asPath, fork: 'true', destDir: destinationDir.absolutePath,
- source: project.convention.plugins.java.sourceCompatibility,
- target: project.convention.plugins.java.targetCompatibility,
- aspectPath: aspectPath.asPath, sourceRootCopyFilter: '**/*.java', showWeaveInfo: 'true') {
- sourceroots {
- sourceRoots.each {
- logger.info(" sourceRoot $it")
- pathelement(location: it.absolutePath)
- }
- }
- }
- }
-}
diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/aspectj.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/aspectj.properties
deleted file mode 100644
index 3e8a23c083f..00000000000
--- a/buildSrc/src/main/resources/META-INF/gradle-plugins/aspectj.properties
+++ /dev/null
@@ -1 +0,0 @@
-implementation-class=aspectj.AspectJPlugin
diff --git a/samples/javaconfig/aspectj/spring-security-samples-javaconfig-aspectj.gradle b/samples/javaconfig/aspectj/spring-security-samples-javaconfig-aspectj.gradle
index 92816e007eb..cba74cbdbe3 100644
--- a/samples/javaconfig/aspectj/spring-security-samples-javaconfig-aspectj.gradle
+++ b/samples/javaconfig/aspectj/spring-security-samples-javaconfig-aspectj.gradle
@@ -1,5 +1,5 @@
apply plugin: 'io.spring.convention.spring-sample'
-apply plugin: 'aspectj'
+apply plugin: 'io.freefair.aspectj.post-compile-weaving'
repositories {
mavenCentral()
@@ -9,7 +9,7 @@ dependencies {
compile project(':spring-security-config')
compile project(':spring-security-core')
- aspectpath project(':spring-security-aspects')
+ aspect project(':spring-security-aspects')
runtime project(':spring-security-aspects')
}
diff --git a/samples/xml/aspectj/spring-security-samples-xml-aspectj.gradle b/samples/xml/aspectj/spring-security-samples-xml-aspectj.gradle
index d869f632961..5ec643637f9 100644
--- a/samples/xml/aspectj/spring-security-samples-xml-aspectj.gradle
+++ b/samples/xml/aspectj/spring-security-samples-xml-aspectj.gradle
@@ -1,10 +1,10 @@
apply plugin: 'io.spring.convention.spring-sample-war'
-apply plugin: 'aspectj'
+apply plugin: 'io.freefair.aspectj.post-compile-weaving'
dependencies {
compile project(':spring-security-core')
- aspectpath project(':spring-security-aspects')
+ aspect project(':spring-security-aspects')
runtime project(':spring-security-aspects')
runtime project(':spring-security-config')