Slackbot
07/03/2023, 12:52 PMAdam
07/03/2023, 12:58 PMserviceOf<>() out of doLast {}Vampire
07/03/2023, 12:58 PMserviceOf is also to be considered internal even without it being in an *.internal.* package.
The serviceOf call should also be the problem as far as I can see, as it is called on the build script reference which can then not be serialized by the configuation cache.Adam
07/03/2023, 12:59 PMtasks.named<Jar>("jar") {
val styledText = serviceOf<StyledTextOutputFactory>()
doLast {
val out = styledText.create("detekt-rules")
// ...
}
}Vampire
07/03/2023, 12:59 PMVampire
07/03/2023, 1:00 PMSebastian Schuberth
07/03/2023, 1:00 PM* What went wrong:
Configuration cache state could not be cached: field `dateFormat` of `org.gradle.internal.logging.console.StyledTextOutputBackedRenderer` bean found in field `stdoutChain` of `org.gradle.internal.logging.sink.LogEventDispatcher` bean found in field `delegate` of `org.gradle.internal.logging.sink.OutputEventRenderer$LazyListener` bean found in field `target` of `org.gradle.internal.dispatch.ReflectionDispatch` bean found in field `dispatch` of `org.gradle.internal.event.BroadcastDispatch$SingletonDispatch` bean found in field `dispatchers` of `org.gradle.internal.event.BroadcastDispatch$CompositeDispatch` bean found in field `broadcast` of `org.gradle.internal.event.ListenerBroadcast` bean found in field `formatters` of `org.gradle.internal.logging.sink.OutputEventRenderer` bean found in field `renderer` of `org.gradle.internal.logging.sink.OutputEventListenerManager` bean found in field `this$0` of `org.gradle.internal.logging.sink.OutputEventListenerManager$1` bean found in field `listener` of `org.gradle.internal.logging.services.TextStreamOutputEventListener` bean found in field `outputEventListener` of `org.gradle.internal.logging.services.DefaultStyledTextOutputFactory` bean found in field `$styledText` of `Build_gradle$$$result$1$1` bean found in field `action` of `org.gradle.api.internal.AbstractTask$TaskActionWrapper` bean found in field `actions` of task `:detekt-rules:jar` of type `org.gradle.api.tasks.bundling.Jar`: error writing value of type 'java.text.SimpleDateFormat'
> Unable to make private void java.text.SimpleDateFormat.readObject(java.io.ObjectInputStream) throws java.io.IOException,java.lang.ClassNotFoundException accessible: module java.base does not "opens java.text" to unnamed module @2511e3efVampire
07/03/2023, 1:01 PMSebastian Schuberth
07/03/2023, 1:01 PMVampire
07/03/2023, 1:02 PMSebastian Schuberth
07/03/2023, 1:03 PMVampire
07/03/2023, 1:05 PMJendrik Johannes
07/03/2023, 1:05 PM@Inject and do not need to access the project for the serviceOf (which is also kind of internal I think)Vampire
07/03/2023, 1:05 PMVampire
07/03/2023, 1:05 PMabstract class Foo : DefaultTask() {
@get:Inject
abstract val foo: StyledTextOutputFactory
@TaskAction
fun foo() {
val out = foo.create("detekt-rules")
val message = "The detekt-rules have changed. You need to stop the Gradle daemon to allow the detekt plugin " +
"to reload for the rule changes to take effect."
out.withStyle(<http://StyledTextOutput.Style.Info|StyledTextOutput.Style.Info>).println(message)
}
}
val foo by tasks.registering(Foo::class)Sebastian Schuberth
07/03/2023, 1:07 PMVampire
07/03/2023, 1:09 PMinterface Foo {
@get:Inject
val foo: StyledTextOutputFactory
}
val help by tasks.existing {
val objects = objects
doLast {
val out = objects.newInstance<Foo>().foo.create("detekt-rules")
val message = "The detekt-rules have changed. You need to stop the Gradle daemon to allow the detekt plugin " +
"to reload for the rule changes to take effect."
out.withStyle(<http://StyledTextOutput.Style.Info|StyledTextOutput.Style.Info>).println(message)
}
}Adam
07/03/2023, 1:21 PMWhat went wrong: Configuration cache state could not be cached: fielddβoh, okay, also put the message in a providerof β¦dateFormat
val styleText by tasks.registering {
val styledText = serviceOf<StyledTextOutputFactory>()
val msg = providers.provider {
val out = styledText.create("detekt-rules")
val message = "The detekt-rules have changed. You need to stop the Gradle daemon to allow the detekt plugin " +
"to reload for the rule changes to take effect."
out.append(message).withStyle(StyledTextOutput.Style.Error).println(message)
}
doLast {
msg.get()
}
}
maybe thereβs a better way to get a string rather than calling println(message), but it seems to workSebastian Schuberth
07/03/2023, 1:39 PMAdam
07/03/2023, 1:40 PMVampire
07/03/2023, 1:41 PMAdam
07/03/2023, 1:43 PMSebastian Schuberth
07/03/2023, 1:43 PMSebastian Schuberth
07/03/2023, 1:44 PM