Kotlin-dsl-samples: Custom actions in Kotlin build script break task up-to-date check

Created on 14 Feb 2017  路  5Comments  路  Source: gradle/kotlin-dsl-samples

Using the following Groovy build script:

apply plugin: 'java'

task emptyJar(type: Jar) {
    classifier = 'empty'

    doFirst {
        println 'Test'
    }
}

The :emptyJar task is run only once, further invocations of the task report UP-TO-DATE.

When I write the same thing using a Kotlin build script:

import org.gradle.jvm.tasks.Jar

plugins {
    java
}

task<Jar>("emptyJar") {
    classifier = "empty"

    doFirst {
        println("Test")
    }
}

The JAR is always re-built because Gradle detects the task as out-of-date. If I enable debug logging it shows the following:

Executing task ':emptyJar' (up-to-date check took 0.009 secs) due to:
  Task ':emptyJar' has a custom action that was loaded with an unknown classloader

I think adding a custom task action using a Kotlin build script should behave similar to Groovy without affecting the up-to-date check.

Tested with gradle-script-kotlin-3.5-20170207151802+0000

bug kotlin-dsl-runtime blocked

All 5 comments

Thanks for the report!

Blocked by #171.

Resolved in 174f72c1263183ea49520b6820bcdc72252f930b.

Thanks for the report, @Minecrell!

@bamboo I've tested it and it works fine using the latest snapshot distribution. Thanks for the fix!

Was this page helpful?
0 / 5 - 0 ratings