maven-plugin-development icon indicating copy to clipboard operation
maven-plugin-development copied to clipboard

Support for configuration cache

Open britter opened this issue 5 years ago • 8 comments

Instant execution is one of the upcoming features in Gradle. The plugin should support this.

britter avatar Apr 10 '20 11:04 britter

For now this workaround seems to be enough

tasks.named('generateMavenPluginHelpMojoSources') {
  notCompatibleWithConfigurationCache('https://github.com/britter/maven-plugin-development/issues/8')
}

nedtwigg avatar Jan 19 '23 22:01 nedtwigg

Yes, that's true, but it will disable the configuration cache whenever this plugin is part of the build 😕

britter avatar Jan 23 '23 08:01 britter

Gradle 7.6.1

- Task `:plugin-maven:generateMavenPluginHelpMojoSources` of type `de.benediktritter.maven.plugin.development.task.GenerateHelpMojoSourcesTask`: cannot serialize object of type 'org.gradle.internal.io.LinePerThreadBufferingOutputStream', a subtype of 'java.io.OutputStream', as these are not supported with the configuration cache.
  See https://docs.gradle.org/7.6.1/userguide/configuration_cache.html#config_cache:requirements:disallowed_types
- Task `:plugin-maven:generateMavenPluginHelpMojoSources` of type `de.benediktritter.maven.plugin.development.task.GenerateHelpMojoSourcesTask`: value '[classpath, site]' failed Java Object Serialization
  See https://docs.gradle.org/7.6.1/userguide/configuration_cache.html#config_cache:not_yet_implemented:java_serialization
- Task `:plugin-maven:generateMavenPluginHelpMojoSources` of type `de.benediktritter.maven.plugin.development.task.GenerateHelpMojoSourcesTask`: value '[java.lang.Class, java.lang.ClassLoader, java.lang.Compiler, java.lang.InheritableThreadLocal, java.lang.Package, java.lang.Process, java.lang.Runtime, java.lang.RuntimePermission, java.lang.SecurityManager, java.lang.System, java.lang.Thread, java.lang.ThreadGroup, java.lang.ThreadLocal]' failed Java Object Serialization
  See https://docs.gradle.org/7.6.1/userguide/configuration_cache.html#config_cache:not_yet_implemented:java_serialization
- Task `:plugin-maven:generateMavenPluginHelpMojoSources` of type `de.benediktritter.maven.plugin.development.task.GenerateHelpMojoSourcesTask`: value '[org.apache.velocity.runtime.log.AvalonLogChute, org.apache.velocity.runtime.log.Log4JLogChute, org.apache.velocity.runtime.log.CommonsLogLogChute, org.apache.velocity.runtime.log.ServletLogChute, org.apache.velocity.runtime.log.JdkLogChute]' failed Java Object Serialization
  See https://docs.gradle.org/7.6.1/userguide/configuration_cache.html#config_cache:not_yet_implemented:java_serialization

* What went wrong: Configuration cache state could not be cached: field `inputStream` of `org.apache.velocity.runtime.parser.VelocityCharStream` bean found in field `input_stream` of `org.apache.velocity.runtime.parser.ParserTokenManager` bean found in field `token_source` of `org.apache.velocity.runtime.parser.Parser` bean found in field `pool` of `org.apache.velocity.util.SimplePool` bean found in field `pool` of `org.apache.velocity.runtime.ParserPoolImpl` bean found in field `parserPool` of `org.apache.velocity.runtime.RuntimeInstance` bean found in field `ri` of `org.apache.velocity.app.VelocityEngine` bean found in field `engine` of `org.codehaus.plexus.velocity.DefaultVelocityComponent` bean found in field `velocityComponent` of `org.apache.maven.tools.plugin.generator.PluginHelpGenerator` bean found in field `generator` of task `:plugin-maven:generateMavenPluginHelpMojoSources` of type `de.benediktritter.maven.plugin.development.task.GenerateHelpMojoSourcesTask`: error writing value of type 'java.io.InputStreamReader'
> Unable to make field private final sun.nio.cs.StreamDecoder java.io.InputStreamReader.sd accessible: module java.base does not "opens java.io" to unnamed module @15e5409c

Goooler avatar Feb 26 '23 08:02 Goooler

This is not possible without breaking API, so I'll put this into the 1.0 milestone.

britter avatar Feb 28 '24 19:02 britter

Just to chime in what I'm running into:

* What went wrong:
Configuration cache state could not be cached: field `configuration` of `org.apache.velocity.runtime.RuntimeInstance` bean found in field `ri` of `org.apache.velocity.app.VelocityEngine` bean found in field `engine` of `org.codehaus.plexus.velocity.DefaultVelocityComponent` bean found in field `velocityComponent` of `org.apache.maven.tools.plugin.generator.PluginHelpGenerator` bean found in field `generator` of task `:plugins:package-managers:maven-plugin:generateMavenPluginHelpMojoSources` of type `de.benediktritter.maven.plugin.development.task.GenerateHelpMojoSourcesTask`: error writing value of type 'org.apache.commons.collections.ExtendedProperties'
> 'ObjectOutputStream.putFields' is not supported by the Gradle configuration cache. See https://docs.gradle.org/8.10/userguide/configuration_cache.html#config_cache:not_yet_implemented:java_serialization for details.

sschuberth avatar Aug 30 '24 15:08 sschuberth

yeah, this is still on my backlog. I hope to have some more time to work on this project again in the near future. For now the only workaround is to explicitly disable to configuration cache for the tasks in the plugin.

britter avatar Aug 31 '24 08:08 britter

Does it make sense to finish and merge https://github.com/britter/maven-plugin-development/pull/148 until then?

sschuberth avatar Aug 31 '24 10:08 sschuberth

No, #148 is going to replaced by a different approach. The challenge with the current state of the code is that the tasks unnecessarily reference types that can't be serialized into the configuration cache. My plan is to change that while moving to the org.gradlex namespace because then binary compatibility will be broken anyway.

britter avatar Aug 31 '24 17:08 britter