You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Mark Raynsford <or...@io7m.com.INVALID> on 2022/11/08 20:36:19 UTC

Adding extra "scope" type metadata to dependencies?

Hello!

I'd like to be able to add extra metadata to dependencies in a POM file.
Specifically:

  1. I'd like to be able to specify whether a dependency goes on the
     class or module path rather than have Maven decide for me.

  2. I'd like to be able to specify that a dependency _doesn't_ go on
     either path (possibly because it's going to be added manually
     elsewhere during deployment as an OSGi bundle, or as part of a
     dynamically created module layer, or something similar).

Ideally, the second point would be handled properly by IDEs such that
clicking "Run" wouldn't result in artifacts being added to the
classpath/modulepath of the program the IDE runs.

I remember reading (possibly over a year ago now) that there might be
some possibility of an extension that allows for adding extra
information to a <dependency> element, but I'm now unable to find any
evidence this existed.

Is there some way to do this today? If not... Will there be some way in
Maven 4.0.0+?

-- 
Mark Raynsford | https://www.io7m.com


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


Re: Adding extra "scope" type metadata to dependencies?

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

AFAIK all commands are customizable enough to ensure you control
module-path and class-path. It requires some work but it is doable when the
good enough default (convention) is not matching your expectation - the
main issue can be that 99% of modules are used in classpath and plexus
would define them as module implicitly as of today by the usage (war,
custom launcher etc).

On the ability to have scopes being like *configuration* of gradle, ie
defining a set of dependencies not belonging to any plugin and semantic
defined in maven, it is already doable by using a custom plugin which does
what you need with the resolver system and it is compliant with maven being
more about conventions. The only issue can happen when it must be
integrated with existing plugins like surefire or compiler but these ones
are customizable so guess we are good enough for edge cases as mentionned
Robert.


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 jeu. 10 nov. 2022 à 08:56, Christoph Läubrich <ma...@laeubi-soft.de> a
écrit :

> I also sometimes though about it would be useful to have additional data
> attached to some items in the maven model. In my case it was profile
> activation, what currently seems limited to hard coded defaults as well...
>
> For example with <configuration> one can just add everything there that
> is valid XML and then plugins can inspect this.
>
> As XML *can* be extensible, why not simply allow extension elements
> (e.g. from Maven 4.0 on!) on all the major items like dependency,
> profiles and so on?
>
> Then extensions to the model can live in an own namespace and one only
> needs to have a way to access those from the model classes .
>
> For sure this might break older maven versions, but it is often feasible
> to tell people "this project requires maven <insert your version here>
> to build"
>
> Am 10.11.22 um 08:45 schrieb Robert Scholte:
> > Regarding #1 you need to be more precise.
> > The jigsaw-team also thought it would be easy to extend the pom for this.
> > However, in the end I discovered there's no need to do this.
> > The plexus-java library has code which you feed the module descriptor
> > and all jars and it is able to decide if they belong to the modulepath
> > or classpath.
> > Only for testing you might want want to decide where services or static
> > required modules belongs. That's a per-test decision, so can't be done
> > at pom-level.
> > plexus-java[1] has proven itself since Java 9, only edge cases are
> > tricky, but most of the time it is in the details of the specification
> > of the java module system.
> >
> > Robert
> >
> > [1]
> >
> https://codehaus-plexus.github.io/plexus-languages/plexus-java/usage.html
> >
> >
> > ------ Oorspronkelijke bericht ------
> > Van "Ralph Goers" <ra...@dslextreme.com>
> > Aan "Maven Developers List" <de...@maven.apache.org>
> > Datum 10-11-2022 06:08:27
> > Onderwerp Re: Adding extra "scope" type metadata to dependencies?
> >
> >> Extending the pom.xml has been discussed for years. Unfortunately, it
> >> validates the XSD, so when the pom is extended with new attributes
> >> older versions of Maven will fail. This is the main reason why import
> >> scope was introduced rather than using a new element.
> >> There were many discussions about adding provides/requires concepts to
> >> the pom as well as other constructs but they always failed due to this.
> >> Ralph
> >>
> >>> On Nov 8, 2022, at 1:36 PM, Mark Raynsford
> >>> <or...@io7m.com.INVALID> wrote:
> >>>
> >>> Hello!
> >>>
> >>> I'd like to be able to add extra metadata to dependencies in a POM
> file.
> >>> Specifically:
> >>>
> >>>  1. I'd like to be able to specify whether a dependency goes on the
> >>>     class or module path rather than have Maven decide for me.
> >>>
> >>>  2. I'd like to be able to specify that a dependency _doesn't_ go on
> >>>     either path (possibly because it's going to be added manually
> >>>     elsewhere during deployment as an OSGi bundle, or as part of a
> >>>     dynamically created module layer, or something similar).
> >>>
> >>> Ideally, the second point would be handled properly by IDEs such that
> >>> clicking "Run" wouldn't result in artifacts being added to the
> >>> classpath/modulepath of the program the IDE runs.
> >>>
> >>> I remember reading (possibly over a year ago now) that there might be
> >>> some possibility of an extension that allows for adding extra
> >>> information to a <dependency> element, but I'm now unable to find any
> >>> evidence this existed.
> >>>
> >>> Is there some way to do this today? If not... Will there be some way in
> >>> Maven 4.0.0+?
> >>>
> >>> -- Mark Raynsford | https://www.io7m.com
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Adding extra "scope" type metadata to dependencies?

Posted by Christoph Läubrich <ma...@laeubi-soft.de>.
I also sometimes though about it would be useful to have additional data 
attached to some items in the maven model. In my case it was profile 
activation, what currently seems limited to hard coded defaults as well...

For example with <configuration> one can just add everything there that 
is valid XML and then plugins can inspect this.

As XML *can* be extensible, why not simply allow extension elements 
(e.g. from Maven 4.0 on!) on all the major items like dependency, 
profiles and so on?

Then extensions to the model can live in an own namespace and one only 
needs to have a way to access those from the model classes .

For sure this might break older maven versions, but it is often feasible 
to tell people "this project requires maven <insert your version here> 
to build"

Am 10.11.22 um 08:45 schrieb Robert Scholte:
> Regarding #1 you need to be more precise.
> The jigsaw-team also thought it would be easy to extend the pom for this.
> However, in the end I discovered there's no need to do this.
> The plexus-java library has code which you feed the module descriptor 
> and all jars and it is able to decide if they belong to the modulepath 
> or classpath.
> Only for testing you might want want to decide where services or static 
> required modules belongs. That's a per-test decision, so can't be done 
> at pom-level.
> plexus-java[1] has proven itself since Java 9, only edge cases are 
> tricky, but most of the time it is in the details of the specification 
> of the java module system.
> 
> Robert
> 
> [1] 
> https://codehaus-plexus.github.io/plexus-languages/plexus-java/usage.html
> 
> 
> ------ Oorspronkelijke bericht ------
> Van "Ralph Goers" <ra...@dslextreme.com>
> Aan "Maven Developers List" <de...@maven.apache.org>
> Datum 10-11-2022 06:08:27
> Onderwerp Re: Adding extra "scope" type metadata to dependencies?
> 
>> Extending the pom.xml has been discussed for years. Unfortunately, it 
>> validates the XSD, so when the pom is extended with new attributes 
>> older versions of Maven will fail. This is the main reason why import 
>> scope was introduced rather than using a new element.
>> There were many discussions about adding provides/requires concepts to 
>> the pom as well as other constructs but they always failed due to this.
>> Ralph
>>
>>> On Nov 8, 2022, at 1:36 PM, Mark Raynsford 
>>> <or...@io7m.com.INVALID> wrote:
>>>
>>> Hello!
>>>
>>> I'd like to be able to add extra metadata to dependencies in a POM file.
>>> Specifically:
>>>
>>>  1. I'd like to be able to specify whether a dependency goes on the
>>>     class or module path rather than have Maven decide for me.
>>>
>>>  2. I'd like to be able to specify that a dependency _doesn't_ go on
>>>     either path (possibly because it's going to be added manually
>>>     elsewhere during deployment as an OSGi bundle, or as part of a
>>>     dynamically created module layer, or something similar).
>>>
>>> Ideally, the second point would be handled properly by IDEs such that
>>> clicking "Run" wouldn't result in artifacts being added to the
>>> classpath/modulepath of the program the IDE runs.
>>>
>>> I remember reading (possibly over a year ago now) that there might be
>>> some possibility of an extension that allows for adding extra
>>> information to a <dependency> element, but I'm now unable to find any
>>> evidence this existed.
>>>
>>> Is there some way to do this today? If not... Will there be some way in
>>> Maven 4.0.0+?
>>>
>>> -- Mark Raynsford | https://www.io7m.com
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
> 

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


Re: Adding extra "scope" type metadata to dependencies?

Posted by Robert Scholte <rf...@apache.org>.
Regarding #1 you need to be more precise.
The jigsaw-team also thought it would be easy to extend the pom for 
this.
However, in the end I discovered there's no need to do this.
The plexus-java library has code which you feed the module descriptor 
and all jars and it is able to decide if they belong to the modulepath 
or classpath.
Only for testing you might want want to decide where services or static 
required modules belongs. That's a per-test decision, so can't be done 
at pom-level.
plexus-java[1] has proven itself since Java 9, only edge cases are 
tricky, but most of the time it is in the details of the specification 
of the java module system.

Robert

[1] 
https://codehaus-plexus.github.io/plexus-languages/plexus-java/usage.html


------ Oorspronkelijke bericht ------
Van "Ralph Goers" <ra...@dslextreme.com>
Aan "Maven Developers List" <de...@maven.apache.org>
Datum 10-11-2022 06:08:27
Onderwerp Re: Adding extra "scope" type metadata to dependencies?

>Extending the pom.xml has been discussed for years. Unfortunately, it validates the XSD, so when the pom is extended with new attributes older versions of Maven will fail. This is the main reason why import scope was introduced rather than using a new element.
>There were many discussions about adding provides/requires concepts to the pom as well as other constructs but they always failed due to this.
>Ralph
>
>>On Nov 8, 2022, at 1:36 PM, Mark Raynsford <or...@io7m.com.INVALID> wrote:
>>
>>Hello!
>>
>>I'd like to be able to add extra metadata to dependencies in a POM file.
>>Specifically:
>>
>>  1. I'd like to be able to specify whether a dependency goes on the
>>     class or module path rather than have Maven decide for me.
>>
>>  2. I'd like to be able to specify that a dependency _doesn't_ go on
>>     either path (possibly because it's going to be added manually
>>     elsewhere during deployment as an OSGi bundle, or as part of a
>>     dynamically created module layer, or something similar).
>>
>>Ideally, the second point would be handled properly by IDEs such that
>>clicking "Run" wouldn't result in artifacts being added to the
>>classpath/modulepath of the program the IDE runs.
>>
>>I remember reading (possibly over a year ago now) that there might be
>>some possibility of an extension that allows for adding extra
>>information to a <dependency> element, but I'm now unable to find any
>>evidence this existed.
>>
>>Is there some way to do this today? If not... Will there be some way in
>>Maven 4.0.0+?
>>
>>-- Mark Raynsford | https://www.io7m.com
>>
>>
>>---------------------------------------------------------------------
>>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: Adding extra "scope" type metadata to dependencies?

Posted by Ralph Goers <ra...@dslextreme.com>.
Extending the pom.xml has been discussed for years. Unfortunately, 
it validates the XSD, so when the pom is extended with new attributes 
older versions of Maven will fail. This is the main reason why import 
scope was introduced rather than using a new element. 

There were many discussions about adding provides/requires concepts 
to the pom as well as other constructs but they always failed due to this. 

Ralph

> On Nov 8, 2022, at 1:36 PM, Mark Raynsford <or...@io7m.com.INVALID> wrote:
> 
> Hello!
> 
> I'd like to be able to add extra metadata to dependencies in a POM file.
> Specifically:
> 
>  1. I'd like to be able to specify whether a dependency goes on the
>     class or module path rather than have Maven decide for me.
> 
>  2. I'd like to be able to specify that a dependency _doesn't_ go on
>     either path (possibly because it's going to be added manually
>     elsewhere during deployment as an OSGi bundle, or as part of a
>     dynamically created module layer, or something similar).
> 
> Ideally, the second point would be handled properly by IDEs such that
> clicking "Run" wouldn't result in artifacts being added to the
> classpath/modulepath of the program the IDE runs.
> 
> I remember reading (possibly over a year ago now) that there might be
> some possibility of an extension that allows for adding extra
> information to a <dependency> element, but I'm now unable to find any
> evidence this existed.
> 
> Is there some way to do this today? If not... Will there be some way in
> Maven 4.0.0+?
> 
> -- 
> Mark Raynsford | https://www.io7m.com
> 
> 
> ---------------------------------------------------------------------
> 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