defano / wyldcard

A clone of Apple's HyperCard and HyperTalk scripting language.
https://github.com/defano/wyldcard/wiki
MIT License
117 stars 12 forks source link

FIXED: Deprecated-To-Be "JacocoReportBase.setClassDirectories(FileCollection)" function in gradle build file #70

Closed Jimw338 closed 5 years ago

Jimw338 commented 5 years ago

(Duplicate post so that it "gets seen" by the project owner defano - I accidentally closed my own issue, and am not sure if it notifies people of issues that are "open-then-immediately-closed")

I'm getting a deprecated error with: JacocoReportBase.setClassDirectories(FileCollection), with the recommendation to use "getClassDirectories().from(...)" A Google turns up a similar error someone else got (https://github.com/gradle/gradle/issues/7753). I changed the WyldCard build script as follows, updating the "jacocoTestReport" block:

//
// ****** Deprecation error ******
// (Gradle 5.2.1, will be deprecated in 6.0)
// [jw 3/5/2019]
//
// *** ORIGINAL (works with Gradle 5.2.1):
/*
jacocoTestReport {
    afterEvaluate {
        classDirectories = files(classDirectories.files.collect {
            fileTree(dir: it, exclude: 'com/defano/hypertalk/parser/**')
        })
    }
}
*/

// *** Fix:

jacocoTestReport {
    afterEvaluate {
        getClassDirectories().setFrom(classDirectories.files.collect {
            fileTree(dir: it, exclude: 'com/defano/hypertalk/parser/**')
        })

//*     classDirectories = files(classDirectories.files.collect {
//*         fileTree(dir: it, exclude: 'com/defano/hypertalk/parser/**')
//*     })
    }
}

// ****** End of deprecation error fix ******
defano commented 5 years ago

I agree that newer versions of Gradle produce a deprecation warning. However, the project's build.gradle script was written for use with Gradle 4.6, which neither complains about this use, nor accepts the updated syntax.

I'd upgrade to use Gradle 5.2, but the gradle-aspectj-binary plugin appears to be incompatible with it.

In general, when working with a project built using Gradle, it's recommended to use the Gradle wrapper script (gradlew) packaged with the project. The wrapper will always assure you're using the same version of Gradle as the author, even downloading it if necessary. See: https://docs.gradle.org/current/userguide/gradle_wrapper.html

I'll update the build documents to make this more clear.