1

below is a snippet of our gradle build script

def binDir = file("bin")
def libDir = "WebContent/WEB-INF/lib"
def testReportDir = file('testReport')
def outputDir = file("output")
def envParam = "local"


repositories {
    mavenCentral()
}

sourceSets {
    project.webAppDirName = 'WebContent'

    if (project.hasProperty("env")) {
        envParam = env
        outputDir = file("output/$envParam")
    }

    main {
        java { srcDirs = ['src/main/java'] }
        resources { srcDirs = ['src/main/resources','config/' + envParam] }
        output.classesDir = binDir
    }

    test {
        java { srcDirs = ['src/main/java', 'src/test/java'] }
        resources { srcDirs = ['src/main/resources', 'src/test'] }
        output.classesDir = binDir
        compileClasspath = sourceSets.main.compileClasspath
        runtimeClasspath = output + compileClasspath
    }
}

What this does is, build an .ear file from our project code built from Java 8. This works fine when using Gradle 3.1 but when we migrated to 5.1, the error below shows up when we run the script.

"* What went wrong: A problem occurred evaluating root project 'HKSLFDirectory'.

Could not set unknown property 'classesDir' for main classes of type org.gradl e.api.internal.tasks.DefaultSourceSetOutput."

  • this method `classesDir` has been deprecated in Gradle v4, and is no longer available in V5.x (see V4 release note: https://docs.gradle.org/4.0/release-notes.html#deprecated-apis ) You need to read the API/DSL for the current version you are using: check https://docs.gradle.org/current/dsl/org.gradle.api.tasks.SourceSet.html#org.gradle.api.tasks.SourceSet:output and https://docs.gradle.org/current/dsl/org.gradle.api.tasks.SourceSetOutput.html – M.Ricciuti Feb 05 '19 at 23:32
  • I think you could use : https://docs.gradle.org/current/dsl/org.gradle.api.tasks.SourceSetOutput.html#org.gradle.api.tasks.SourceSetOutput:classesDirs – M.Ricciuti Feb 05 '19 at 23:33

0 Answers0