Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven Plugin - the option to set extraClasspath in the plugin configuration isn't working randomly #11732

Open
rinnnn opened this issue May 1, 2024 · 15 comments
Labels
Bug For general bugs on Jetty side

Comments

@rinnnn
Copy link

rinnnn commented May 1, 2024

Jetty version(s)
jetty 12.0.8

Jetty Environment
Is not relevant for the issue

Java version/vendor
Is not relevant, Java 17 in my case

OS type/version
Is not relevant, Linux in my case.

Description
Exactly the same issue as in the #7970, just a newer jetty version.

How to reproduce?
With the attached maven project
test-extra-classpath.zip
Run the following command in Linux (the command is easy to adapt for other systems, it is only needed because the issue happens randomly, so we need to repeatedly run the project until it fails):

while true; do  mvn integration-test; if [ $? -eq 0 ]; then echo ' --------- '; else break; fi; done;

Wait for the project to eventually fail with the Cannot create instance of class org.eclipse.jetty.util.resource.Resource error (can be after tens of iterations). On this sample project it fails 1 in say 20 times, but on my big project it is vice-verse (fails 19 of 20 times).

Here is the sample output (only the last i.e. failed iteration):

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< foo.bar.baz:test-extra-classpath >------------------
[INFO] Building test-extra-classpath 1.0
[INFO] from pom.xml
[INFO] --------------------------------[ war ]---------------------------------
[WARNING] Parameter 'daemon' is unknown for plugin 'jetty-ee10-maven-plugin:12.0.8:start (start-jetty)'
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ test-extra-classpath ---
[INFO] skip non existing resourceDirectory /home/me/tmp/test-extra-classpath/src/main/resources
[INFO]
[INFO] --- compiler:3.11.0:compile (default-compile) @ test-extra-classpath ---
[INFO] No sources to compile
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ test-extra-classpath ---
[INFO] skip non existing resourceDirectory /home/me/tmp/test-extra-classpath/src/test/resources
[INFO]
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ test-extra-classpath ---
[INFO] No sources to compile
[INFO]
[INFO] --- surefire:3.1.2:test (default-test) @ test-extra-classpath ---
[INFO] No tests to run.
[INFO]
[INFO] --- war:3.4.0:war (default-war) @ test-extra-classpath ---
[INFO] Packaging webapp
[INFO] Assembling webapp [test-extra-classpath] in [/home/me/tmp/test-extra-classpath/target/test-extra-classpath]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/me/tmp/test-extra-classpath/src/main/webapp]
[INFO] Building war: /home/me/tmp/test-extra-classpath/target/test-extra-classpath.war
[INFO]
[INFO] --- jetty:12.0.8:start (start-jetty) @ test-extra-classpath ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.149 s
[INFO] Finished at: 2024-05-01T18:27:55+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jetty.ee10:jetty-ee10-maven-plugin:12.0.8:start (start-jetty) on project test-extra-classpath: Unable to parse configuration of mojo org.eclipse.jetty.ee10:jetty-ee10-maven-plugin:12.0.8:start for parameter #: Cannot create instance of class org.eclipse.jetty.util.resource.Resource: InstantiationException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException

@rinnnn rinnnn added the Bug For general bugs on Jetty side label May 1, 2024
@rinnnn rinnnn changed the title Maven Plugin - the option to set extraClasspath in the plugin configuration isn't working randomely Maven Plugin - the option to set extraClasspath in the plugin configuration isn't working randomly May 1, 2024
@janbartel
Copy link
Contributor

Running with mvn -e integration-test yields the stacktrace:

[ERROR] Failed to execute goal org.eclipse.jetty.ee10:jetty-ee10-maven-plugin:12.0.8:start (start-jetty) on project test-extra-classpath: Unable to parse configuration of mojo org.eclipse.jetty.ee10:jetty-ee10-maven-plugin:12.0.8:start for parameter #: Cannot create instance of class org.eclipse.jetty.util.resource.Resource: InstantiationException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.jetty.ee10:jetty-ee10-maven-plugin:12.0.8:start (start-jetty) on project test-extra-classpath: Unable to parse configuration of mojo org.eclipse.jetty.ee10:jetty-ee10-maven-plugin:12.0.8:start for parameter #: Cannot create instance of class org.eclipse.jetty.util.resource.Resource
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:578)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
Caused by: org.apache.maven.plugin.PluginConfigurationException: Unable to parse configuration of mojo org.eclipse.jetty.ee10:jetty-ee10-maven-plugin:12.0.8:start for parameter #: Cannot create instance of class org.eclipse.jetty.util.resource.Resource
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populateMojoExecutionFields (DefaultMavenPluginManager.java:640)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo (DefaultMavenPluginManager.java:573)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:114)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:578)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
Caused by: org.codehaus.plexus.component.configurator.ComponentConfigurationException: Cannot create instance of class org.eclipse.jetty.util.resource.Resource
at org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter.instantiateObject (AbstractConfigurationConverter.java:147)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.fromConfiguration (ObjectWithFieldsConverter.java:54)
at org.codehaus.plexus.component.configurator.converters.composite.AbstractCollectionConverter.fromChildren (AbstractCollectionConverter.java:54)
at org.codehaus.plexus.component.configurator.converters.composite.CollectionConverter.fromConfiguration (CollectionConverter.java:73)
at org.eclipse.sisu.plexus.CompositeBeanHelper.convertProperty (CompositeBeanHelper.java:268)
at org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty (CompositeBeanHelper.java:174)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration (ObjectWithFieldsConverter.java:101)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.fromConfiguration (ObjectWithFieldsConverter.java:57)
at org.eclipse.sisu.plexus.CompositeBeanHelper.convertProperty (CompositeBeanHelper.java:273)
at org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty (CompositeBeanHelper.java:210)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration (ObjectWithFieldsConverter.java:101)
at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent (BasicComponentConfigurator.java:34)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populateMojoExecutionFields (DefaultMavenPluginManager.java:617)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo (DefaultMavenPluginManager.java:573)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:114)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:578)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
Caused by: java.lang.InstantiationException
at jdk.internal.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance (InstantiationExceptionConstructorAccessorImpl.java:48)
at java.lang.reflect.Constructor.newInstanceWithCaller (Constructor.java:500)
at java.lang.reflect.ReflectAccess.newInstance (ReflectAccess.java:128)
at jdk.internal.reflect.ReflectionFactory.newInstance (ReflectionFactory.java:306)
at java.lang.Class.newInstance (Class.java:684)
at org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter.instantiateObject (AbstractConfigurationConverter.java:143)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.fromConfiguration (ObjectWithFieldsConverter.java:54)
at org.codehaus.plexus.component.configurator.converters.composite.AbstractCollectionConverter.fromChildren (AbstractCollectionConverter.java:54)
at org.codehaus.plexus.component.configurator.converters.composite.CollectionConverter.fromConfiguration (CollectionConverter.java:73)
at org.eclipse.sisu.plexus.CompositeBeanHelper.convertProperty (CompositeBeanHelper.java:268)
at org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty (CompositeBeanHelper.java:174)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration (ObjectWithFieldsConverter.java:101)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.fromConfiguration (ObjectWithFieldsConverter.java:57)
at org.eclipse.sisu.plexus.CompositeBeanHelper.convertProperty (CompositeBeanHelper.java:273)
at org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty (CompositeBeanHelper.java:210)
at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration (ObjectWithFieldsConverter.java:101)
at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent (BasicComponentConfigurator.java:34)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populateMojoExecutionFields (DefaultMavenPluginManager.java:617)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo (DefaultMavenPluginManager.java:573)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:114)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:578)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException

@janbartel
Copy link
Contributor

I wonder if maven is chosing between matching these 2 methods on WebAppContext:

  • public void setExtraClasspath(String extraClasspath)
  • public void setExtraClasspath(List<Resource> extraClasspath)

and is somehow chosing the second one and trying to directly convert the String to a Resource? That would be odd, as jetty-10 has exactly the same two methods and you are saying that it never happens with jetty-10?

@janbartel
Copy link
Contributor

@olamy can you take a look at the stacktrace and see if you can understand what's going on?

@olamy
Copy link
Member

olamy commented May 2, 2024

TBH I don't know how this could work with public void setExtraClasspath(List<Resource> extraClasspath) because in both cases (10 and 12) Resource is an abstract class so Maven plugin configuration converter will not be able to instantiate a new instance.
but why is it random this is weird.
Normally something such <extraClasspath implementation="java.lang.String">${basedir}/config</extraClasspath> should fix it.
but I was able to reproduce again with your script (maybe less often but it's not scientific measurement :))
I need to look at Maven core sources.

@olamy
Copy link
Member

olamy commented May 2, 2024

uhm not sure about the implementation attribute as it's a field of a more complex Object.

@olamy
Copy link
Member

olamy commented May 2, 2024

haha the javadoc here says

The elements in the returned array are not sorted and are not in any particular order.

After some test I can confirm the returned order may be different when Maven try to figure the setter method associate with the field name see https://github.com/eclipse/sisu.plexus/blob/5e8587eac8c4c079566dcd0ccb0d5dba40cb4169/org.eclipse.sisu.plexus/src/main/java/org/eclipse/sisu/plexus/CompositeBeanHelper.java#L269

so sometimes the converter will pick the right method and sometimes not.
very brittle I agree.

@olamy
Copy link
Member

olamy commented May 2, 2024

using <extraClasspath implementation="java.lang.String">${basedir}/config</extraClasspath> could work but the found value type is not taken into account when filtering methods here
https://github.com/eclipse/sisu.plexus/blob/5e8587eac8c4c079566dcd0ccb0d5dba40cb4169/org.eclipse.sisu.plexus/src/main/java/org/eclipse/sisu/plexus/CompositeBeanHelper.java#L143

@olamy
Copy link
Member

olamy commented May 2, 2024

@rinnnn you can have a look at the patch here eclipse-sisu/sisu.plexus#52
To test it you will need to install the jar locally.
I'm doing it this way;

mvn clean install && cp org.eclipse.sisu.plexus/target/org.eclipse.sisu.plexus-0.9.0-SNAPSHOT.jar ~/.sdkman/candidates/maven/3.9.6/lib/org.eclipse.sisu.plexus-0.9.0.M2.jar 

please note my Maven home $M2_HOME=~/.sdkman/candidates/maven/3.9.6

@rinnnn
Copy link
Author

rinnnn commented May 2, 2024

Thanks, it works well for me.

Just a note for others: for it to work one needs both:

  • the patch above to the org.eclipse.sisu.plexus in maven,
  • and the implementation="java.lang.String" part inside the <extraClasspath implementation="java.lang.String">${basedir}/config</extraClasspath> (without it it will fail with Cannot create instance of class org.eclipse.jetty.util.resource.Resource: InstantiationException)

@olamy
Copy link
Member

olamy commented May 3, 2024

FTR Apache Maven issue https://issues.apache.org/jira/browse/MNG-8116

@cstamas
Copy link
Contributor

cstamas commented May 3, 2024

Unsure can this issue be fixed in Maven 3.9.7, as its release is scheduled for upcoming days, while this is downstream bug in Eclipse Sisu Plexus Shim. Moreover, Plexus Shim cannot be released "alone", it must go with with Eclipse Sisu, so that would be two releases downstream Maven to have 3.9.7 possible to happen. Would it be simple(r) to just deprecate one of double named methods and introduce one like one singular (for String) and plural (for list) maybe?

@olamy
Copy link
Member

olamy commented May 5, 2024

The more natural, modern and elegant method here is public void setExtraClasspath(List<Resource> extraClasspath).
But Maven cannot support this so we have to keep the other method to help Maven and to be backward compatible.
Keeping only the public void setExtraClasspath(String extraClasspath) doesn't make really sense.
It's a bit like not being able to have method such setFiles(List<File> files) but only having setFiles(String files) and asking users of the method "hey you need to pass a List<File> as a comma separated String instead of using some modern collection.

@janbartel
Copy link
Contributor

@cstamas that method has been released in our public api, so no, we can't just delete it. I'm quite surprised this problem exists as it seems a pretty fundamental concept in object oriented programming not to be supported?

@cstamas
Copy link
Contributor

cstamas commented May 5, 2024

@janbartel am not questioning method overload as valid thing in Java, am just stating that here you deal with ton of layers, from Mojo config, Maven internal, Plexus (that is phased out) and finally Sisu as DI implementation. This problem seems existed in whole Maven 3.x line. I avoided overloading mojo config in all my life, that's all. Exposing APIs like this is a brave thing, that's all am saying 😄

@janbartel
Copy link
Contributor

@cstamas heh heh, I wasn't expecting a problem as jetty xml configuration code has dealt with overloaded methods for 20+ years 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

4 participants