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

问题描述 投票:0回答:2

我试图运行一个看起来像这样的build.gradle文件,并在行应用插件上返回错误:'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.

我在这做错了什么?

spring gradle build.gradle
2个回答
0
投票

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

最容易的可能是replace the plugin;例如。与io.freefair.aspectj.post-compile-weaving,因为aspectj.gradle最近更新2年前(它似乎被遗弃)。


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
© www.soinside.com 2019 - 2024. All rights reserved.