*Does `-i` affect a task's class path?* That is t...
# plugin-development
y
Does
-i
affect a task's class path?
That is the headline question, let me explain. I was testing up-to-date status of some tasks in plugin using testKit. Effectively, what I was doing in the test is something like
Copy code
GradleRunner.create().withArguments('task1')
GradleRunner.create().withArguments('task2')
basically
task2
depend on
task1
which depends on
task0
Thus in the first invocation
task0
and
task1
will have an outcome of
SUCCESS
. In the 2nd invocation, those two should have an outcome of
UP_TO_DATE
, and
task2
will be
SUCCESS
. Not problem with that, until I did...
Copy code
GradleRunner.create().withArguments('task1')
GradleRunner.create().withArguments('task2', '-i')
Suddenly, on the 2nd invocation the outcome of
task0
was
SUCCESS
instead of
UP_TO_DATE
and Gradle logs stated that
Copy code
Task ':task0' is not up-to-date because:
  Class path of task ':task0' has changed from 58046a25460590d169a1847f193c5177 to b72b7af69ca1f7306a1e3a2dcf54a21a.
I find that unexpected behaviour. WDYT?
👀 2
v
Yes, sounds strange aaand I cannot reproduce it with an MCVE.
Tried with
Copy code
@Shared
   @TempDir
   FileSystemFixture tmp

   def foo() {
      given:
         tmp.create {
            file('settings.gradle.kts') << '''
                rootProject.name = "test"
            '''.stripIndent(true)

            file('build.gradle.kts') << '''
                val task0 by tasks.registering {
                    outputs.upToDateWhen { true }
                    doLast {
                        println("task0")
                    }
                }
                val task1 by tasks.registering {
                    outputs.upToDateWhen { true }
                    dependsOn(task0)
                    doLast {
                        println("task1")
                    }
                }
                val task2 by tasks.registering {
                    outputs.upToDateWhen { true }
                    dependsOn(task1)
                    doLast {
                        println("task2")
                    }
                }
            '''.stripIndent(true)
         }

      when:
         def result = GradleRunner.create().withProjectDir(tmp.currentPath.toFile()).withArguments('task1').build()
         println "result.task(':task0').outcome = ${result.task(':task0').outcome}"
         println "result.task(':task1').outcome = ${result.task(':task1').outcome}"
         result = GradleRunner.create().withProjectDir(tmp.currentPath.toFile()).withArguments('task2', '-i').build()
         println "result.task(':task0').outcome = ${result.task(':task0').outcome}"
         println "result.task(':task1').outcome = ${result.task(':task1').outcome}"
         println "result.task(':task2').outcome = ${result.task(':task2').outcome}"

      then:
         true
   }
}
and it behaves as expected
y
Yes, I don't think it is reproducible with a simple example.