You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Konrad Windszus <kw...@apache.org> on 2022/07/29 14:05:58 UTC

Mojo parameters of type java.nio.file.Path

Hi,
According to https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories only java.io.File type parameters are supported for dealing with file paths. 
I was assuming that every complex type is supported which has a constructor taking a single String value which is used for coercion/construction.
That is true for https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String) but not for https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html. Is there already a ticket for supporting NIO Path parameters?

Which tool is used for doing the injection of parameters under the hood? Is that also Eclipse Sisu?
It would be really nice to extend https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects and https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects a bit, as it does not really state how the object is actually instantiated. Is it using the default constructor and field reflection only? If so, how does it do type coercion as everything given in the pom.xml or on the CLI is a String?

Thanks in advance for giving some insights on this,
Konrad
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Mojo parameters of type java.nio.file.Path

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Injections can work, the small note on path converter is that it must have
the same handling than file one and be relative to basedir by default
probably (and not the working dir) which seems missed in the linked commit.

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le ven. 29 juil. 2022 à 16:34, Konrad Windszus <kw...@apache.org> a écrit :

> I now created https://github.com/eclipse/sisu.plexus/issues/21, but I am
> not sure if we always need a dedicated plexus converter or the Plexus shim
> can also rely on the one provided by Sisu.Inject.
> As soon as I have some feedback in the ticket I am gonna work on a PR for
> it and also for https://issues.apache.org/jira/browse/MNG-7524.
>
> Thanks,
> Konrad
>
> On 2022/07/29 14:27:05 Jorge Solórzano wrote:
> > Hi Konrad,
> >
> > If I'm not wrong, Eclipse Sisu handles the conversion of parameters, so
> yes
> > right now only java.io.File type is supported.
> >
> > Maven currently uses Sisu 0.3.5
> > <https://github.com/eclipse/sisu.inject/releases/tag/releases%2F0.3.5>,
> > and there
> > is a pre-release of Sisu (0.9.0.M1
> > <
> https://github.com/eclipse/sisu.inject/releases/tag/milestones%2F0.9.0.M1
> >)
> > that includes the PathTypeConverter
> > <https://github.com/eclipse/sisu.inject/pull/39> (available in
> 0.9.0.M1),
> > yet this means that right now it's not possible to use
> java.nio.file.Path.
> >
> > So yes, you are bound to using File parameters, yet it's pretty easy to
> > convert from/to Path using File.toPath()
> > <https://docs.oracle.com/javase/7/docs/api/java/io/File.html#toPath()>
> >
> > On Fri, Jul 29, 2022 at 4:06 PM Konrad Windszus <kw...@apache.org> wrote:
> > >
> > > Hi,
> > > According to
> >
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
> > only java.io.File type parameters are supported for dealing with file
> paths.
> > > I was assuming that every complex type is supported which has a
> > constructor taking a single String value which is used for
> > coercion/construction.
> > > That is true for
> >
> https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
> > but not for
> > https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html. Is
> there
> > already a ticket for supporting NIO Path parameters?
> > >
> > > Which tool is used for doing the injection of parameters under the
> hood?
> > Is that also Eclipse Sisu?
> > > It would be really nice to extend
> >
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
> > and
> >
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
> > a bit, as it does not really state how the object is actually
> instantiated.
> > Is it using the default constructor and field reflection only? If so, how
> > does it do type coercion as everything given in the pom.xml or on the CLI
> > is a String?
> > >
> > > Thanks in advance for giving some insights on this,
> > > Konrad
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: dev-help@maven.apache.org
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Mojo parameters of type java.nio.file.Path

Posted by Konrad Windszus <kw...@apache.org>.
I now created https://github.com/eclipse/sisu.plexus/issues/21, but I am not sure if we always need a dedicated plexus converter or the Plexus shim can also rely on the one provided by Sisu.Inject.
As soon as I have some feedback in the ticket I am gonna work on a PR for it and also for https://issues.apache.org/jira/browse/MNG-7524.

Thanks,
Konrad

On 2022/07/29 14:27:05 Jorge Solórzano wrote:
> Hi Konrad,
> 
> If I'm not wrong, Eclipse Sisu handles the conversion of parameters, so yes
> right now only java.io.File type is supported.
> 
> Maven currently uses Sisu 0.3.5
> <https://github.com/eclipse/sisu.inject/releases/tag/releases%2F0.3.5>,
> and there
> is a pre-release of Sisu (0.9.0.M1
> <https://github.com/eclipse/sisu.inject/releases/tag/milestones%2F0.9.0.M1>)
> that includes the PathTypeConverter
> <https://github.com/eclipse/sisu.inject/pull/39> (available in 0.9.0.M1),
> yet this means that right now it's not possible to use java.nio.file.Path.
> 
> So yes, you are bound to using File parameters, yet it's pretty easy to
> convert from/to Path using File.toPath()
> <https://docs.oracle.com/javase/7/docs/api/java/io/File.html#toPath()>
> 
> On Fri, Jul 29, 2022 at 4:06 PM Konrad Windszus <kw...@apache.org> wrote:
> >
> > Hi,
> > According to
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
> only java.io.File type parameters are supported for dealing with file paths.
> > I was assuming that every complex type is supported which has a
> constructor taking a single String value which is used for
> coercion/construction.
> > That is true for
> https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
> but not for
> https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html. Is there
> already a ticket for supporting NIO Path parameters?
> >
> > Which tool is used for doing the injection of parameters under the hood?
> Is that also Eclipse Sisu?
> > It would be really nice to extend
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
> and
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
> a bit, as it does not really state how the object is actually instantiated.
> Is it using the default constructor and field reflection only? If so, how
> does it do type coercion as everything given in the pom.xml or on the CLI
> is a String?
> >
> > Thanks in advance for giving some insights on this,
> > Konrad
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Mojo parameters of type java.nio.file.Path

Posted by Jorge Solórzano <jo...@gmail.com>.
Hi Konrad,

If I'm not wrong, Eclipse Sisu handles the conversion of parameters, so yes
right now only java.io.File type is supported.

Maven currently uses Sisu 0.3.5
<https://github.com/eclipse/sisu.inject/releases/tag/releases%2F0.3.5>,
and there
is a pre-release of Sisu (0.9.0.M1
<https://github.com/eclipse/sisu.inject/releases/tag/milestones%2F0.9.0.M1>)
that includes the PathTypeConverter
<https://github.com/eclipse/sisu.inject/pull/39> (available in 0.9.0.M1),
yet this means that right now it's not possible to use java.nio.file.Path.

So yes, you are bound to using File parameters, yet it's pretty easy to
convert from/to Path using File.toPath()
<https://docs.oracle.com/javase/7/docs/api/java/io/File.html#toPath()>

On Fri, Jul 29, 2022 at 4:06 PM Konrad Windszus <kw...@apache.org> wrote:
>
> Hi,
> According to
https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
only java.io.File type parameters are supported for dealing with file paths.
> I was assuming that every complex type is supported which has a
constructor taking a single String value which is used for
coercion/construction.
> That is true for
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
but not for
https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html. Is there
already a ticket for supporting NIO Path parameters?
>
> Which tool is used for doing the injection of parameters under the hood?
Is that also Eclipse Sisu?
> It would be really nice to extend
https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
and
https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
a bit, as it does not really state how the object is actually instantiated.
Is it using the default constructor and field reflection only? If so, how
does it do type coercion as everything given in the pom.xml or on the CLI
is a String?
>
> Thanks in advance for giving some insights on this,
> Konrad
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

Re: Mojo parameters of type java.nio.file.Path

Posted by Konrad Windszus <kw...@apache.org>.
Thanks for the answer.
I meanwhile found https://github.com/eclipse/sisu.inject/commit/2676001d31a06fe94d2d9a167c5f078c2eba4f5a, but IMHO SISU 0.9.0-M1 is not used in any released Maven yet, so for the time being I am bound to using File parameters, right?

Konrad

On 2022/07/29 14:21:57 Romain Manni-Bucau wrote:
> Hi Konrad,
> 
> Guess what you are looking for is
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/eclipse/sisu/plexus/CompositeBeanHelper.java#L250
> which uses
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java#L46
> so supporting Path is mainly about adding a PathConverter inspired from
> FileConverter (
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java#L23
> ).
> 
> We could have a constructor or factory support like in JAX-RS or most CLI
> libraries (fromString, Parse, of etc) but not sure the actual usage so
> maybe just supporting the JVM types is sufficient.
> 
> Hope it helps.
> 
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
> 
> 
> Le ven. 29 juil. 2022 à 16:06, Konrad Windszus <kw...@apache.org> a écrit :
> 
> > Hi,
> > According to
> > https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
> > only java.io.File type parameters are supported for dealing with file
> > paths.
> > I was assuming that every complex type is supported which has a
> > constructor taking a single String value which is used for
> > coercion/construction.
> > That is true for
> > https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
> > but not for
> > https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html. Is
> > there already a ticket for supporting NIO Path parameters?
> >
> > Which tool is used for doing the injection of parameters under the hood?
> > Is that also Eclipse Sisu?
> > It would be really nice to extend
> > https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
> > and
> > https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
> > a bit, as it does not really state how the object is actually instantiated.
> > Is it using the default constructor and field reflection only? If so, how
> > does it do type coercion as everything given in the pom.xml or on the CLI
> > is a String?
> >
> > Thanks in advance for giving some insights on this,
> > Konrad
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Mojo parameters of type java.nio.file.Path

Posted by Konrad Windszus <kw...@apache.org>.
Hi Stuart,
thanks a lot for the valuable input, I finalised the PR at https://github.com/eclipse/sisu.plexus/pull/22 and added some tests for path injections (as a start).

Regarding the converters being used, I already figured out that an arbitrary class with a string constructor does not work (e.g. https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#BigInteger(java.lang.String) is not being used. IIUC this would be supported by Guice TypeConverterts. Would it make sense to also use 3 as fallback when not dealing with beans but with Mojos (treated as Plexus components)?

Thanks,
Konrad

On 2022/07/31 09:40:27 Stuart McCulloch wrote:
> That's correct, Maven still uses the Plexus configuration API to convert
> XML configuration to mojo parameters.
> 
> Sisu looks for the best matching converter as follows for Plexus
> configuration requests:
> 
> 1. custom converters registered via ConverterLookup (Plexus API)
> 2. built-in converters that mimic Plexus behaviour
> 3. built-in converters registered with Guice as TypeConverter bindings
> (used when configuring beans)
> 
> By default Plexus' File converter doesn't do any base directory alignment -
> but Maven registers an evaluator that provides some custom alignment rules:
> 
> https://github.com/apache/maven/blob/maven-3.8.6/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java#L461
> 
> To provide the same custom alignment for Path we just need to copy this
> class and replace 'File' with 'Path':
> 
> https://github.com/eclipse/sisu.plexus/blob/releases/0.3.5/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java
> 
> 
> On Sun, 31 Jul 2022 at 09:24, Konrad Windszus <kw...@apache.org> wrote:
> 
> > At least for Maven 3.8.6 this is not true.
> > Plexus Container API is still used in
> > https://github.com/apache/maven/blob/84538c9988a25aec085021c365c560670ad80f63/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L625
> >
> > A complete stack trace for injecting File parameters in Mojos looks like
> > this:
> > Thread [main] (Suspended (breakpoint at line 35 in FileConverter))
> >         FileConverter.fromString(String) line: 35
> >
> > FileConverter(AbstractBasicConverter).fromConfiguration(ConverterLookup,
> > PlexusConfiguration, Class<?>, Class<?>, ClassLoader, ExpressionEvaluator,
> > ConfigurationListener) line: 43
> >         FileConverter.fromConfiguration(ConverterLookup,
> > PlexusConfiguration, Class<?>, Class<?>, ClassLoader, ExpressionEvaluator,
> > ConfigurationListener) line: 45
> >         CompositeBeanHelper.convertProperty(Class<?>, Class<?>, Type,
> > PlexusConfiguration) line: 273
> >         CompositeBeanHelper.setProperty(Object, String, Class<?>,
> > PlexusConfiguration) line: 210
> >         ObjectWithFieldsConverter.processConfiguration(ConverterLookup,
> > Object, ClassLoader, PlexusConfiguration, ExpressionEvaluator,
> > ConfigurationListener) line: 101
> >         BasicComponentConfigurator.configureComponent(Object,
> > PlexusConfiguration, ExpressionEvaluator, ClassRealm,
> > ConfigurationListener) line: 34
> >         DefaultMavenPluginManager.populatePluginFields(Object,
> > MojoDescriptor, ClassRealm, PlexusConfiguration, ExpressionEvaluator) line:
> > 635
> >         DefaultMavenPluginManager.getConfiguredMojo(Class<T>,
> > MavenSession, MojoExecution) line: 597
> >         DefaultBuildPluginManager.executeMojo(MavenSession, MojoExecution)
> > line: 124
> >         MojoExecutor.doExecute2(MavenSession, MojoExecution) line: 370
> >         MojoExecutor.doExecute(MavenSession, MojoExecution, ProjectIndex,
> > DependencyContext) line: 351
> >         MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex,
> > DependencyContext) line: 215
> >         MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex,
> > DependencyContext, PhaseRecorder) line: 171
> >         MojoExecutor.execute(MavenSession, List<MojoExecution>,
> > ProjectIndex) line: 163
> >         LifecycleModuleBuilder.buildProject(MavenSession, MavenSession,
> > ReactorContext, MavenProject, TaskSegment) line: 117
> >         LifecycleModuleBuilder.buildProject(MavenSession, ReactorContext,
> > MavenProject, TaskSegment) line: 81
> >         SingleThreadedBuilder.build(MavenSession, ReactorContext,
> > ProjectBuildList, List<TaskSegment>, ReactorBuildStatus) line: 56
> >         LifecycleStarter.execute(MavenSession) line: 128
> >         DefaultMaven.doExecute(MavenExecutionRequest, MavenSession,
> > MavenExecutionResult, DefaultRepositorySystemSession) line: 294
> >         DefaultMaven.doExecute(MavenExecutionRequest) line: 192
> >         DefaultMaven.execute(MavenExecutionRequest) line: 105
> >         MavenCli.execute(CliRequest) line: 960
> >         MavenCli.doMain(CliRequest) line: 293
> >         MavenCli.main(String[], ClassWorld) line: 196
> >         NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
> > not available [native method]
> >         NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
> >         DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
> >         Method.invoke(Object, Object...) line: 566
> >         Launcher.launchEnhanced(String[]) line: 282
> >         Launcher.launch(String[]) line: 225
> >         Launcher.mainWithExitCode(String[]) line: 406
> >         Launcher.main(String[]) line: 347
> >
> > Even in Maven 4 (
> > https://github.com/apache/maven/blob/a53a1aa232bc383baf055d884a7c66319d10d404/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L644)
> > the Plexus API is still used.
> >
> > So I think that sisu.plexus is really the project that needs the
> > enhancement/fix.
> > Is there any plan to get rid of Plexus Containers API for Maven 4?
> >
> > Thanks,
> > Konrad
> >
> >
> > On 2022/07/29 17:17:30 Tamás Cservenák wrote:
> > > Don't mix in plexus (is dead). You need Guice spi TypeConverter.
> > >
> > > T
> > >
> > > On Fri, Jul 29, 2022, 16:22 Romain Manni-Bucau <rm...@gmail.com>
> > > wrote:
> > >
> > > > Hi Konrad,
> > > >
> > > > Guess what you are looking for is
> > > >
> > > >
> > https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/eclipse/sisu/plexus/CompositeBeanHelper.java#L250
> > > > which uses
> > > >
> > > >
> > https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java#L46
> > > > so supporting Path is mainly about adding a PathConverter inspired from
> > > > FileConverter (
> > > >
> > > >
> > https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java#L23
> > > > ).
> > > >
> > > > We could have a constructor or factory support like in JAX-RS or most
> > CLI
> > > > libraries (fromString, Parse, of etc) but not sure the actual usage so
> > > > maybe just supporting the JVM types is sufficient.
> > > >
> > > > Hope it helps.
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <https://rmannibucau.metawerx.net/> | Old Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> > > > <
> > > >
> > https://www.packtpub.com/application-development/java-ee-8-high-performance
> > > > >
> > > >
> > > >
> > > > Le ven. 29 juil. 2022 à 16:06, Konrad Windszus <kw...@apache.org> a
> > écrit :
> > > >
> > > > > Hi,
> > > > > According to
> > > > >
> > > >
> > https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
> > > > > only java.io.File type parameters are supported for dealing with file
> > > > > paths.
> > > > > I was assuming that every complex type is supported which has a
> > > > > constructor taking a single String value which is used for
> > > > > coercion/construction.
> > > > > That is true for
> > > > >
> > > >
> > https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
> > > > > but not for
> > > > > https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html.
> > Is
> > > > > there already a ticket for supporting NIO Path parameters?
> > > > >
> > > > > Which tool is used for doing the injection of parameters under the
> > hood?
> > > > > Is that also Eclipse Sisu?
> > > > > It would be really nice to extend
> > > > >
> > > >
> > https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
> > > > > and
> > > > >
> > > >
> > https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
> > > > > a bit, as it does not really state how the object is actually
> > > > instantiated.
> > > > > Is it using the default constructor and field reflection only? If
> > so, how
> > > > > does it do type coercion as everything given in the pom.xml or on
> > the CLI
> > > > > is a String?
> > > > >
> > > > > Thanks in advance for giving some insights on this,
> > > > > Konrad
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > > > For additional commands, e-mail: dev-help@maven.apache.org
> > > > >
> > > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Mojo parameters of type java.nio.file.Path

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Guess we should plan that+support mojo jar hosted converters for mvn 4?
For mvn 3 gain would be low since it would couple mojo to mvn version too
much probably as of today.

Wdyt?

Le dim. 31 juil. 2022 à 11:40, Stuart McCulloch <mc...@gmail.com> a
écrit :

> That's correct, Maven still uses the Plexus configuration API to convert
> XML configuration to mojo parameters.
>
> Sisu looks for the best matching converter as follows for Plexus
> configuration requests:
>
> 1. custom converters registered via ConverterLookup (Plexus API)
> 2. built-in converters that mimic Plexus behaviour
> 3. built-in converters registered with Guice as TypeConverter bindings
> (used when configuring beans)
>
> By default Plexus' File converter doesn't do any base directory alignment -
> but Maven registers an evaluator that provides some custom alignment rules:
>
>
> https://github.com/apache/maven/blob/maven-3.8.6/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java#L461
>
> To provide the same custom alignment for Path we just need to copy this
> class and replace 'File' with 'Path':
>
>
> https://github.com/eclipse/sisu.plexus/blob/releases/0.3.5/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java
>
>
> On Sun, 31 Jul 2022 at 09:24, Konrad Windszus <kw...@apache.org> wrote:
>
> > At least for Maven 3.8.6 this is not true.
> > Plexus Container API is still used in
> >
> https://github.com/apache/maven/blob/84538c9988a25aec085021c365c560670ad80f63/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L625
> >
> > A complete stack trace for injecting File parameters in Mojos looks like
> > this:
> > Thread [main] (Suspended (breakpoint at line 35 in FileConverter))
> >         FileConverter.fromString(String) line: 35
> >
> > FileConverter(AbstractBasicConverter).fromConfiguration(ConverterLookup,
> > PlexusConfiguration, Class<?>, Class<?>, ClassLoader,
> ExpressionEvaluator,
> > ConfigurationListener) line: 43
> >         FileConverter.fromConfiguration(ConverterLookup,
> > PlexusConfiguration, Class<?>, Class<?>, ClassLoader,
> ExpressionEvaluator,
> > ConfigurationListener) line: 45
> >         CompositeBeanHelper.convertProperty(Class<?>, Class<?>, Type,
> > PlexusConfiguration) line: 273
> >         CompositeBeanHelper.setProperty(Object, String, Class<?>,
> > PlexusConfiguration) line: 210
> >         ObjectWithFieldsConverter.processConfiguration(ConverterLookup,
> > Object, ClassLoader, PlexusConfiguration, ExpressionEvaluator,
> > ConfigurationListener) line: 101
> >         BasicComponentConfigurator.configureComponent(Object,
> > PlexusConfiguration, ExpressionEvaluator, ClassRealm,
> > ConfigurationListener) line: 34
> >         DefaultMavenPluginManager.populatePluginFields(Object,
> > MojoDescriptor, ClassRealm, PlexusConfiguration, ExpressionEvaluator)
> line:
> > 635
> >         DefaultMavenPluginManager.getConfiguredMojo(Class<T>,
> > MavenSession, MojoExecution) line: 597
> >         DefaultBuildPluginManager.executeMojo(MavenSession,
> MojoExecution)
> > line: 124
> >         MojoExecutor.doExecute2(MavenSession, MojoExecution) line: 370
> >         MojoExecutor.doExecute(MavenSession, MojoExecution, ProjectIndex,
> > DependencyContext) line: 351
> >         MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex,
> > DependencyContext) line: 215
> >         MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex,
> > DependencyContext, PhaseRecorder) line: 171
> >         MojoExecutor.execute(MavenSession, List<MojoExecution>,
> > ProjectIndex) line: 163
> >         LifecycleModuleBuilder.buildProject(MavenSession, MavenSession,
> > ReactorContext, MavenProject, TaskSegment) line: 117
> >         LifecycleModuleBuilder.buildProject(MavenSession, ReactorContext,
> > MavenProject, TaskSegment) line: 81
> >         SingleThreadedBuilder.build(MavenSession, ReactorContext,
> > ProjectBuildList, List<TaskSegment>, ReactorBuildStatus) line: 56
> >         LifecycleStarter.execute(MavenSession) line: 128
> >         DefaultMaven.doExecute(MavenExecutionRequest, MavenSession,
> > MavenExecutionResult, DefaultRepositorySystemSession) line: 294
> >         DefaultMaven.doExecute(MavenExecutionRequest) line: 192
> >         DefaultMaven.execute(MavenExecutionRequest) line: 105
> >         MavenCli.execute(CliRequest) line: 960
> >         MavenCli.doMain(CliRequest) line: 293
> >         MavenCli.main(String[], ClassWorld) line: 196
> >         NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
> > not available [native method]
> >         NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
> >         DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
> >         Method.invoke(Object, Object...) line: 566
> >         Launcher.launchEnhanced(String[]) line: 282
> >         Launcher.launch(String[]) line: 225
> >         Launcher.mainWithExitCode(String[]) line: 406
> >         Launcher.main(String[]) line: 347
> >
> > Even in Maven 4 (
> >
> https://github.com/apache/maven/blob/a53a1aa232bc383baf055d884a7c66319d10d404/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L644
> )
> > the Plexus API is still used.
> >
> > So I think that sisu.plexus is really the project that needs the
> > enhancement/fix.
> > Is there any plan to get rid of Plexus Containers API for Maven 4?
> >
> > Thanks,
> > Konrad
> >
> >
> > On 2022/07/29 17:17:30 Tamás Cservenák wrote:
> > > Don't mix in plexus (is dead). You need Guice spi TypeConverter.
> > >
> > > T
> > >
> > > On Fri, Jul 29, 2022, 16:22 Romain Manni-Bucau <rm...@gmail.com>
> > > wrote:
> > >
> > > > Hi Konrad,
> > > >
> > > > Guess what you are looking for is
> > > >
> > > >
> >
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/eclipse/sisu/plexus/CompositeBeanHelper.java#L250
> > > > which uses
> > > >
> > > >
> >
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java#L46
> > > > so supporting Path is mainly about adding a PathConverter inspired
> from
> > > > FileConverter (
> > > >
> > > >
> >
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java#L23
> > > > ).
> > > >
> > > > We could have a constructor or factory support like in JAX-RS or most
> > CLI
> > > > libraries (fromString, Parse, of etc) but not sure the actual usage
> so
> > > > maybe just supporting the JVM types is sufficient.
> > > >
> > > > Hope it helps.
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <https://rmannibucau.metawerx.net/> | Old Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> > > > <
> > > >
> >
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> > > > >
> > > >
> > > >
> > > > Le ven. 29 juil. 2022 à 16:06, Konrad Windszus <kw...@apache.org> a
> > écrit :
> > > >
> > > > > Hi,
> > > > > According to
> > > > >
> > > >
> >
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
> > > > > only java.io.File type parameters are supported for dealing with
> file
> > > > > paths.
> > > > > I was assuming that every complex type is supported which has a
> > > > > constructor taking a single String value which is used for
> > > > > coercion/construction.
> > > > > That is true for
> > > > >
> > > >
> >
> https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
> > > > > but not for
> > > > > https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html.
> > Is
> > > > > there already a ticket for supporting NIO Path parameters?
> > > > >
> > > > > Which tool is used for doing the injection of parameters under the
> > hood?
> > > > > Is that also Eclipse Sisu?
> > > > > It would be really nice to extend
> > > > >
> > > >
> >
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
> > > > > and
> > > > >
> > > >
> >
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
> > > > > a bit, as it does not really state how the object is actually
> > > > instantiated.
> > > > > Is it using the default constructor and field reflection only? If
> > so, how
> > > > > does it do type coercion as everything given in the pom.xml or on
> > the CLI
> > > > > is a String?
> > > > >
> > > > > Thanks in advance for giving some insights on this,
> > > > > Konrad
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > > > For additional commands, e-mail: dev-help@maven.apache.org
> > > > >
> > > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
>

Re: Mojo parameters of type java.nio.file.Path

Posted by Stuart McCulloch <mc...@gmail.com>.
That's correct, Maven still uses the Plexus configuration API to convert
XML configuration to mojo parameters.

Sisu looks for the best matching converter as follows for Plexus
configuration requests:

1. custom converters registered via ConverterLookup (Plexus API)
2. built-in converters that mimic Plexus behaviour
3. built-in converters registered with Guice as TypeConverter bindings
(used when configuring beans)

By default Plexus' File converter doesn't do any base directory alignment -
but Maven registers an evaluator that provides some custom alignment rules:

https://github.com/apache/maven/blob/maven-3.8.6/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java#L461

To provide the same custom alignment for Path we just need to copy this
class and replace 'File' with 'Path':

https://github.com/eclipse/sisu.plexus/blob/releases/0.3.5/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java


On Sun, 31 Jul 2022 at 09:24, Konrad Windszus <kw...@apache.org> wrote:

> At least for Maven 3.8.6 this is not true.
> Plexus Container API is still used in
> https://github.com/apache/maven/blob/84538c9988a25aec085021c365c560670ad80f63/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L625
>
> A complete stack trace for injecting File parameters in Mojos looks like
> this:
> Thread [main] (Suspended (breakpoint at line 35 in FileConverter))
>         FileConverter.fromString(String) line: 35
>
> FileConverter(AbstractBasicConverter).fromConfiguration(ConverterLookup,
> PlexusConfiguration, Class<?>, Class<?>, ClassLoader, ExpressionEvaluator,
> ConfigurationListener) line: 43
>         FileConverter.fromConfiguration(ConverterLookup,
> PlexusConfiguration, Class<?>, Class<?>, ClassLoader, ExpressionEvaluator,
> ConfigurationListener) line: 45
>         CompositeBeanHelper.convertProperty(Class<?>, Class<?>, Type,
> PlexusConfiguration) line: 273
>         CompositeBeanHelper.setProperty(Object, String, Class<?>,
> PlexusConfiguration) line: 210
>         ObjectWithFieldsConverter.processConfiguration(ConverterLookup,
> Object, ClassLoader, PlexusConfiguration, ExpressionEvaluator,
> ConfigurationListener) line: 101
>         BasicComponentConfigurator.configureComponent(Object,
> PlexusConfiguration, ExpressionEvaluator, ClassRealm,
> ConfigurationListener) line: 34
>         DefaultMavenPluginManager.populatePluginFields(Object,
> MojoDescriptor, ClassRealm, PlexusConfiguration, ExpressionEvaluator) line:
> 635
>         DefaultMavenPluginManager.getConfiguredMojo(Class<T>,
> MavenSession, MojoExecution) line: 597
>         DefaultBuildPluginManager.executeMojo(MavenSession, MojoExecution)
> line: 124
>         MojoExecutor.doExecute2(MavenSession, MojoExecution) line: 370
>         MojoExecutor.doExecute(MavenSession, MojoExecution, ProjectIndex,
> DependencyContext) line: 351
>         MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex,
> DependencyContext) line: 215
>         MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex,
> DependencyContext, PhaseRecorder) line: 171
>         MojoExecutor.execute(MavenSession, List<MojoExecution>,
> ProjectIndex) line: 163
>         LifecycleModuleBuilder.buildProject(MavenSession, MavenSession,
> ReactorContext, MavenProject, TaskSegment) line: 117
>         LifecycleModuleBuilder.buildProject(MavenSession, ReactorContext,
> MavenProject, TaskSegment) line: 81
>         SingleThreadedBuilder.build(MavenSession, ReactorContext,
> ProjectBuildList, List<TaskSegment>, ReactorBuildStatus) line: 56
>         LifecycleStarter.execute(MavenSession) line: 128
>         DefaultMaven.doExecute(MavenExecutionRequest, MavenSession,
> MavenExecutionResult, DefaultRepositorySystemSession) line: 294
>         DefaultMaven.doExecute(MavenExecutionRequest) line: 192
>         DefaultMaven.execute(MavenExecutionRequest) line: 105
>         MavenCli.execute(CliRequest) line: 960
>         MavenCli.doMain(CliRequest) line: 293
>         MavenCli.main(String[], ClassWorld) line: 196
>         NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line:
> not available [native method]
>         NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62
>         DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
>         Method.invoke(Object, Object...) line: 566
>         Launcher.launchEnhanced(String[]) line: 282
>         Launcher.launch(String[]) line: 225
>         Launcher.mainWithExitCode(String[]) line: 406
>         Launcher.main(String[]) line: 347
>
> Even in Maven 4 (
> https://github.com/apache/maven/blob/a53a1aa232bc383baf055d884a7c66319d10d404/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L644)
> the Plexus API is still used.
>
> So I think that sisu.plexus is really the project that needs the
> enhancement/fix.
> Is there any plan to get rid of Plexus Containers API for Maven 4?
>
> Thanks,
> Konrad
>
>
> On 2022/07/29 17:17:30 Tamás Cservenák wrote:
> > Don't mix in plexus (is dead). You need Guice spi TypeConverter.
> >
> > T
> >
> > On Fri, Jul 29, 2022, 16:22 Romain Manni-Bucau <rm...@gmail.com>
> > wrote:
> >
> > > Hi Konrad,
> > >
> > > Guess what you are looking for is
> > >
> > >
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/eclipse/sisu/plexus/CompositeBeanHelper.java#L250
> > > which uses
> > >
> > >
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java#L46
> > > so supporting Path is mainly about adding a PathConverter inspired from
> > > FileConverter (
> > >
> > >
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java#L23
> > > ).
> > >
> > > We could have a constructor or factory support like in JAX-RS or most
> CLI
> > > libraries (fromString, Parse, of etc) but not sure the actual usage so
> > > maybe just supporting the JVM types is sufficient.
> > >
> > > Hope it helps.
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <https://rmannibucau.metawerx.net/> | Old Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> > > <
> > >
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> > > >
> > >
> > >
> > > Le ven. 29 juil. 2022 à 16:06, Konrad Windszus <kw...@apache.org> a
> écrit :
> > >
> > > > Hi,
> > > > According to
> > > >
> > >
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
> > > > only java.io.File type parameters are supported for dealing with file
> > > > paths.
> > > > I was assuming that every complex type is supported which has a
> > > > constructor taking a single String value which is used for
> > > > coercion/construction.
> > > > That is true for
> > > >
> > >
> https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
> > > > but not for
> > > > https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html.
> Is
> > > > there already a ticket for supporting NIO Path parameters?
> > > >
> > > > Which tool is used for doing the injection of parameters under the
> hood?
> > > > Is that also Eclipse Sisu?
> > > > It would be really nice to extend
> > > >
> > >
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
> > > > and
> > > >
> > >
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
> > > > a bit, as it does not really state how the object is actually
> > > instantiated.
> > > > Is it using the default constructor and field reflection only? If
> so, how
> > > > does it do type coercion as everything given in the pom.xml or on
> the CLI
> > > > is a String?
> > > >
> > > > Thanks in advance for giving some insights on this,
> > > > Konrad
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > > For additional commands, e-mail: dev-help@maven.apache.org
> > > >
> > > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Mojo parameters of type java.nio.file.Path

Posted by Konrad Windszus <kw...@apache.org>.
At least for Maven 3.8.6 this is not true.
Plexus Container API is still used in https://github.com/apache/maven/blob/84538c9988a25aec085021c365c560670ad80f63/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L625

A complete stack trace for injecting File parameters in Mojos looks like this:
Thread [main] (Suspended (breakpoint at line 35 in FileConverter))	
	FileConverter.fromString(String) line: 35	
	FileConverter(AbstractBasicConverter).fromConfiguration(ConverterLookup, PlexusConfiguration, Class<?>, Class<?>, ClassLoader, ExpressionEvaluator, ConfigurationListener) line: 43	
	FileConverter.fromConfiguration(ConverterLookup, PlexusConfiguration, Class<?>, Class<?>, ClassLoader, ExpressionEvaluator, ConfigurationListener) line: 45	
	CompositeBeanHelper.convertProperty(Class<?>, Class<?>, Type, PlexusConfiguration) line: 273	
	CompositeBeanHelper.setProperty(Object, String, Class<?>, PlexusConfiguration) line: 210	
	ObjectWithFieldsConverter.processConfiguration(ConverterLookup, Object, ClassLoader, PlexusConfiguration, ExpressionEvaluator, ConfigurationListener) line: 101	
	BasicComponentConfigurator.configureComponent(Object, PlexusConfiguration, ExpressionEvaluator, ClassRealm, ConfigurationListener) line: 34	
	DefaultMavenPluginManager.populatePluginFields(Object, MojoDescriptor, ClassRealm, PlexusConfiguration, ExpressionEvaluator) line: 635	
	DefaultMavenPluginManager.getConfiguredMojo(Class<T>, MavenSession, MojoExecution) line: 597	
	DefaultBuildPluginManager.executeMojo(MavenSession, MojoExecution) line: 124	
	MojoExecutor.doExecute2(MavenSession, MojoExecution) line: 370	
	MojoExecutor.doExecute(MavenSession, MojoExecution, ProjectIndex, DependencyContext) line: 351	
	MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex, DependencyContext) line: 215	
	MojoExecutor.execute(MavenSession, MojoExecution, ProjectIndex, DependencyContext, PhaseRecorder) line: 171	
	MojoExecutor.execute(MavenSession, List<MojoExecution>, ProjectIndex) line: 163	
	LifecycleModuleBuilder.buildProject(MavenSession, MavenSession, ReactorContext, MavenProject, TaskSegment) line: 117	
	LifecycleModuleBuilder.buildProject(MavenSession, ReactorContext, MavenProject, TaskSegment) line: 81	
	SingleThreadedBuilder.build(MavenSession, ReactorContext, ProjectBuildList, List<TaskSegment>, ReactorBuildStatus) line: 56	
	LifecycleStarter.execute(MavenSession) line: 128	
	DefaultMaven.doExecute(MavenExecutionRequest, MavenSession, MavenExecutionResult, DefaultRepositorySystemSession) line: 294	
	DefaultMaven.doExecute(MavenExecutionRequest) line: 192	
	DefaultMaven.execute(MavenExecutionRequest) line: 105	
	MavenCli.execute(CliRequest) line: 960	
	MavenCli.doMain(CliRequest) line: 293	
	MavenCli.main(String[], ClassWorld) line: 196	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 566	
	Launcher.launchEnhanced(String[]) line: 282	
	Launcher.launch(String[]) line: 225	
	Launcher.mainWithExitCode(String[]) line: 406	
	Launcher.main(String[]) line: 347	

Even in Maven 4 (https://github.com/apache/maven/blob/a53a1aa232bc383baf055d884a7c66319d10d404/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java#L644) the Plexus API is still used.

So I think that sisu.plexus is really the project that needs the enhancement/fix.
Is there any plan to get rid of Plexus Containers API for Maven 4?

Thanks,
Konrad


On 2022/07/29 17:17:30 Tamás Cservenák wrote:
> Don't mix in plexus (is dead). You need Guice spi TypeConverter.
> 
> T
> 
> On Fri, Jul 29, 2022, 16:22 Romain Manni-Bucau <rm...@gmail.com>
> wrote:
> 
> > Hi Konrad,
> >
> > Guess what you are looking for is
> >
> > https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/eclipse/sisu/plexus/CompositeBeanHelper.java#L250
> > which uses
> >
> > https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java#L46
> > so supporting Path is mainly about adding a PathConverter inspired from
> > FileConverter (
> >
> > https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java#L23
> > ).
> >
> > We could have a constructor or factory support like in JAX-RS or most CLI
> > libraries (fromString, Parse, of etc) but not sure the actual usage so
> > maybe just supporting the JVM types is sufficient.
> >
> > Hope it helps.
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <https://rmannibucau.metawerx.net/> | Old Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> > <
> > https://www.packtpub.com/application-development/java-ee-8-high-performance
> > >
> >
> >
> > Le ven. 29 juil. 2022 à 16:06, Konrad Windszus <kw...@apache.org> a écrit :
> >
> > > Hi,
> > > According to
> > >
> > https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
> > > only java.io.File type parameters are supported for dealing with file
> > > paths.
> > > I was assuming that every complex type is supported which has a
> > > constructor taking a single String value which is used for
> > > coercion/construction.
> > > That is true for
> > >
> > https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
> > > but not for
> > > https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html. Is
> > > there already a ticket for supporting NIO Path parameters?
> > >
> > > Which tool is used for doing the injection of parameters under the hood?
> > > Is that also Eclipse Sisu?
> > > It would be really nice to extend
> > >
> > https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
> > > and
> > >
> > https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
> > > a bit, as it does not really state how the object is actually
> > instantiated.
> > > Is it using the default constructor and field reflection only? If so, how
> > > does it do type coercion as everything given in the pom.xml or on the CLI
> > > is a String?
> > >
> > > Thanks in advance for giving some insights on this,
> > > Konrad
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: dev-help@maven.apache.org
> > >
> > >
> >
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Mojo parameters of type java.nio.file.Path

Posted by Tamás Cservenák <ta...@cservenak.net>.
Don't mix in plexus (is dead). You need Guice spi TypeConverter.

T

On Fri, Jul 29, 2022, 16:22 Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Hi Konrad,
>
> Guess what you are looking for is
>
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/eclipse/sisu/plexus/CompositeBeanHelper.java#L250
> which uses
>
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java#L46
> so supporting Path is mainly about adding a PathConverter inspired from
> FileConverter (
>
> https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java#L23
> ).
>
> We could have a constructor or factory support like in JAX-RS or most CLI
> libraries (fromString, Parse, of etc) but not sure the actual usage so
> maybe just supporting the JVM types is sufficient.
>
> Hope it helps.
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
> <
> https://www.packtpub.com/application-development/java-ee-8-high-performance
> >
>
>
> Le ven. 29 juil. 2022 à 16:06, Konrad Windszus <kw...@apache.org> a écrit :
>
> > Hi,
> > According to
> >
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
> > only java.io.File type parameters are supported for dealing with file
> > paths.
> > I was assuming that every complex type is supported which has a
> > constructor taking a single String value which is used for
> > coercion/construction.
> > That is true for
> >
> https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
> > but not for
> > https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html. Is
> > there already a ticket for supporting NIO Path parameters?
> >
> > Which tool is used for doing the injection of parameters under the hood?
> > Is that also Eclipse Sisu?
> > It would be really nice to extend
> >
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
> > and
> >
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
> > a bit, as it does not really state how the object is actually
> instantiated.
> > Is it using the default constructor and field reflection only? If so, how
> > does it do type coercion as everything given in the pom.xml or on the CLI
> > is a String?
> >
> > Thanks in advance for giving some insights on this,
> > Konrad
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
>

Re: Mojo parameters of type java.nio.file.Path

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Konrad,

Guess what you are looking for is
https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/eclipse/sisu/plexus/CompositeBeanHelper.java#L250
which uses
https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java#L46
so supporting Path is mainly about adding a PathConverter inspired from
FileConverter (
https://github.com/eclipse/sisu.plexus/blob/27a29dc633e6b03753a3c8d29a033648630c8831/org.eclipse.sisu.plexus/src/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java#L23
).

We could have a constructor or factory support like in JAX-RS or most CLI
libraries (fromString, Parse, of etc) but not sure the actual usage so
maybe just supporting the JVM types is sufficient.

Hope it helps.

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le ven. 29 juil. 2022 à 16:06, Konrad Windszus <kw...@apache.org> a écrit :

> Hi,
> According to
> https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#files-and-directories
> only java.io.File type parameters are supported for dealing with file
> paths.
> I was assuming that every complex type is supported which has a
> constructor taking a single String value which is used for
> coercion/construction.
> That is true for
> https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String)
> but not for
> https://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html. Is
> there already a ticket for supporting NIO Path parameters?
>
> Which tool is used for doing the injection of parameters under the hood?
> Is that also Eclipse Sisu?
> It would be really nice to extend
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects
> and
> https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-simple-objects
> a bit, as it does not really state how the object is actually instantiated.
> Is it using the default constructor and field reflection only? If so, how
> does it do type coercion as everything given in the pom.xml or on the CLI
> is a String?
>
> Thanks in advance for giving some insights on this,
> Konrad
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>