britter / maven-plugin-development

Gradle plugin for building Apache Maven plugins
https://plugins.gradle.org/plugin/de.benediktritter.maven-plugin-development
Apache License 2.0
29 stars 6 forks source link

Support for configuration cache #8

Open britter opened 4 years ago

britter commented 4 years ago

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

nedtwigg commented 1 year ago

For now this workaround seems to be enough

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

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

Goooler commented 1 year ago

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
britter commented 8 months ago

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

sschuberth commented 2 months ago

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.
britter commented 2 months ago

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.

sschuberth commented 2 months ago

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

britter commented 2 months ago

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.