Jordi
Jordi

Reputation: 23277

Gradle: Could not get unknown property 'classesDir' for main classes

According to the documentation, I've tried to use aspectj plugin.

This is the message I get when I build my project.

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.

This is my script:

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
}

This is the gradle -version output:

------------------------------------------------------------
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

Upvotes: 25

Views: 30478

Answers (4)

David Ha
David Ha

Reputation: 327

I got a similar error message, not with this plugin but even with the HelloWorld app created by Grails (3.2.9). In my case, I already used sdkman to set my current Gradle to 3.5 instead of 5, but the problem persists. It turned out that the "grails" cli (https://github.com/grails/grails-core/blob/3.2.x/grails-shell/src/main/groovy/org/grails/cli/gradle/GradleUtil.groovy) uses the default sdkman version for Gradle (which is different from the "current" version). From Grails 3.3.X, one can set "gradleWrapperVersion=3.5" in gradle.properties instead, or use GRAILS_GRADLE_HOME environment variable as before.

Upvotes: 1

MaCoda
MaCoda

Reputation: 316

Possible your plugin is not a root of problem but the version of Gradle is. First time I had the same error in libgdx game (android studio). In build.gradle(desktop) file "classDir was renamed to classesDirs and it helped.

from files(sourceSets.main.output.classesDirs)

Upvotes: 12

tagg
tagg

Reputation: 543

In Gradle 5.x, this property has been renamed to classesDirs from classesDir.

You can find more information here

Upvotes: 37

JB Nizet
JB Nizet

Reputation: 692231

The classesDir property was deprecated in gradle 4.x, and removed in gradle 5.x (see the release notes).

The plugin has apparently not been maintained.

Upvotes: 7

Related Questions