This message was deleted.
# plugin-development
s
This message was deleted.
g
Log under TestKit looks like this:
Copy code
# first run:
Configuration cache is an incubating feature.
Calculating task graph as no configuration cache is available for tasks: approveRelease
Inferred project: test, version: 0.2.0-dev.1+3ffa845

Release 0.2.0-dev.1+3ffa845 version? [yes, no] 

> Task :approveRelease
answer: true

BUILD SUCCESSFUL in 177ms
1 actionable task: 1 executed
Configuration cache entry stored.

# second run:
Configuration cache is an incubating feature.
Reusing configuration cache.

Release 0.2.0-dev.1+3ffa845 version? [yes, no] 

> Task :approveRelease FAILED
answer: null
Real world run:
Copy code
# ➜ gradle approveRelease --configuration-cache
executing gradlew instead of gradle
Configuration cache is an incubating feature.
Calculating task graph as configuration cache cannot be reused because an input to task ':private-repo:compileKotlin' has changed.
> Task :build-logic:generateExternalPluginSpecBuilders UP-TO-DATE
> Task :build-logic:extractPrecompiledScriptPluginPlugins UP-TO-DATE
> Task :build-logic:compilePluginsBlocks UP-TO-DATE
> Task :build-logic:generatePrecompiledScriptPluginAccessors UP-TO-DATE
> Task :build-logic:generateScriptPluginAdapters UP-TO-DATE
> Task :build-logic:compileKotlin UP-TO-DATE
> Task :build-logic:compileJava NO-SOURCE
> Task :build-logic:pluginDescriptors UP-TO-DATE
> Task :build-logic:processResources UP-TO-DATE
> Task :build-logic:classes UP-TO-DATE
> Task :build-logic:inspectClassesForKotlinIC UP-TO-DATE
> Task :build-logic:jar UP-TO-DATE
locking FileBasedConfig[/home/gross/.config/jgit/config] failed after 5 retries

> Configure project :private-repo
Inferred project: private-repo, version: 0.14.0-dev.2.uncommitted+8fda41b

> Task :private-repo:compileKotlin UP-TO-DATE
> Task :private-repo:compileJava NO-SOURCE
> Task :private-repo:pluginDescriptors UP-TO-DATE
> Task :private-repo:processResources UP-TO-DATE
> Task :private-repo:classes UP-TO-DATE
> Task :private-repo:inspectClassesForKotlinIC
> Task :private-repo:jar
locking FileBasedConfig[/home/gross/.config/jgit/config] failed after 5 retries

Release 0.1.0-dev.0.uncommitted version? [yes, no] yes


> Task :approveRelease
answer: true

0 problems were found storing the configuration cache.

See the complete report at file:///home/gross/repo/dev-infra/[redacted]/build/reports/configuration-cache/9f4g5irc79mlsbjt5bhvn1n3y/acr0wm9gt2pmg5vvajfbmyfbr/configuration-cache-report.html

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See <https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings>

BUILD SUCCESSFUL in 12s
16 actionable tasks: 3 executed, 13 up-to-date
Configuration cache entry stored.
# at [03:15:05] ➜ gradle approveRelease --configuration-cache
executing gradlew instead of gradle
Configuration cache is an incubating feature.
Reusing configuration cache.

Release 0.1.0-dev.0.uncommitted version? [yes, no] yes


> Task :approveRelease
answer: true

BUILD SUCCESSFUL in 2s
1 actionable task: 1 executed
Configuration cache entry reused.
Versions are irrelevant, since they use different repos, task itself is quite trivial which is why I decided to try test infra on it:
Copy code
abstract class ReleaseApproveTask : DefaultTask() {
  @get:Input
  abstract val projectVersion: Property<String>

  @get:Input
  abstract val approve: Property<String>

  @TaskAction
  fun run() {
    if (approve.get() == "true") {
      return
    } else if (approve.get() == "false") {
      throw GradleException("Not approved, use -Prelease.approve=true for non-interactive mode to approve release")
    }

    val userInputHandler = services.get(UserInputHandler::class.java)
    val answer = userInputHandler.askYesNoQuestion("Release ${projectVersion.get()} version?")
    logger.lifecycle("answer: $answer") // tmp
    if (answer == null || !answer) {
      throw GradleException("Not approved, use -Prelease.approve=true for non-interactive mode to approve release")
    }
  }
}
g
It doesn't seem so, non-interactive would return
null
in both calls but first call gets
true
. I only see such behaviour when configuration cache is reused.
After reviewing my code I found that I forgot to reset input stream that provides that answer on second run. And since it was added only for testing configuration cache it was suspect.