Gradle:无法获取主类的未知属性“ classesDir”

Jor*_*rdi 5 gradle

根据文档,我尝试使用Aspectj插件。

这是我在构建项目时收到的消息。

FAILURE: Build failed with an exception.

* Where:
Build file '/home/jesudi/projects/gradle-vscode/build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'security'.
> Failed to apply plugin [id 'aspectj.gradle']
   > Could not create task ':compileAspect'.
      > Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.
Run Code Online (Sandbox Code Playgroud)

这是我的脚本:

buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath "org.apache.meecrowave:meecrowave-gradle-plugin:1.2.6"
        classpath "gradle.plugin.aspectj:gradle-aspectj:0.1.6"
    }
}

plugins {
    id 'java'
}

project.ext {
    aspectjVersion = '1.9.2'
}

apply plugin: 'aspectj.gradle'
apply plugin: "org.apache.microwave.microwave"

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

dependencies {
    compile("org.apache.meecrowave:meecrowave-core:1.2.6")
    compile("org.apache.meecrowave:meecrowave-specs-api:1.2.6")
}

meecrowave {
    httpPort = 9090
    // most of the meecrowave core configuration
}
Run Code Online (Sandbox Code Playgroud)

这是gradle -version输出:

------------------------------------------------------------
Gradle 5.1.1
------------------------------------------------------------

Build time:   2019-01-10 23:05:02 UTC
Revision:     3c9abb645fb83932c44e8610642393ad62116807

Kotlin DSL:   1.1.1
Kotlin:       1.3.11
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          11.0.2 (Oracle Corporation 11.0.2+9)
OS:           Linux 4.15.0-20-generic amd64
Run Code Online (Sandbox Code Playgroud)

tag*_*agg 20

在 Gradle 5.x 中,此属性已重命名为classesDirsfrom classesDir

你可以在这里找到更多信息


MaC*_*oda 8

可能你的插件不是问题的根源,而是 Gradle 的版本。我第一次在 libgdx 游戏(android studio)中遇到同样的错误。在 build.gradle(desktop) 文件中,“classDir 被重命名为 classesDirs,它有所帮助。

from files(sourceSets.main.output.classesDirs)
Run Code Online (Sandbox Code Playgroud)


JB *_*zet 6

classesDir属性在 gradle 4.x 中已弃用,并在 gradle 5.x 中删除(请参阅发行说明)。

该插件显然没有得到维护。