等级5:无法应用插件[id'aspectj']

时间:2019-04-06 17:38:59

标签: spring gradle build.gradle

我正在尝试运行一个如下所示的build.gradle文件,该文件在 apply插件行上返回错误:'aspectj'

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "http://repo.spring.io/release" }
        maven { url "http://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/libs-snapshot" }
        maven { url "http://repo.spring.io/milestone" }
        maven { url "https://repo.spring.io/libs-milestone" }
        maven { url "https://maven.eveoh.nl/content/repositories/releases" }
    }

    dependencies {
        classpath "nl.eveoh:gradle-aspectj:2.0"
    }
}
apply plugin: 'aspectj'

jar {
    manifest {
        attributes(
                "Created-By": "Iuliana Cosmina",
                "Specification-Title": "Pro Spring 5",
                "Main-Class": "com.apress.prospring5.ch5.AspectJDemo",
                "Class-Path": configurations.compile.collect { it.getName() }.join(' ')
        )
    }
}

错误消息如下:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/me/Spring/pro-spring-5-master/chapter05/aspectj-aspects/build.gradle' line: 17

* What went wrong:
A problem occurred evaluating project ':chapter05:aspectj-aspects'.
> Failed to apply plugin [id 'aspectj']
   > Could not find method deleteAllActions() for arguments [] on task ':chapter05:aspectj-aspects:compileJava' of type org.gradle.api.tasks.compile.JavaCompile.

我在这里做什么错了?

2 个答案:

答案 0 :(得分:0)

AspectJ与Gradle 5.0不兼容-请参阅问题#7861#8063

最容易的是replace the plugin;例如。之所以使用io.freefair.aspectj.post-compile-weaving,是因为aspectj.gradle最近更新于2年前(它似乎已被废弃)。

答案 1 :(得分:0)

我已经解决了该问题,并向jcenter发布了一个新版本。在这里找到它:https://bintray.com/zebalu/releases/gradle-aspectj

当前您需要此:

buildscript {
    repositories {
        jcenter()
    }
    dependnecies {
       classpath 'io.github.zebalu:gradle-aspectj:2.3.3'
    }
}

apply plugin: 'gradle-aspectj'
// rest of your code