Le ven. 12 juil. 2024 à 15:55, Martin Desruisseaux < martin.desruisse...@geomatys.com> a écrit :
> Le 2024-07-12 à 15 h 26, Guillaume Nodet a écrit : > > > I've been working on migrating the build-helper-maven-plugin to the > > Maven 4.x API. (…snip…). This plugin in particular is used a lot (to > > add generated source/resources and attach artifacts) and there's no > > other way to do it. This is essentially a core feature of Maven, and > > thus, I think it should be provided by a Maven plugin. (…snip…) It > > just feels weird that Maven does not provide the required plugins > > directly... > > > Alternatively, should we open the "multi-sources" discussion? We can > leave apart all the aspects related to JPMS for now. Reminder: it is > about changing the POM model for replacing: > > <build> > <sourceDirectory>src/main/java</sourceDirectory> > </build> > > By something like below (the addition of "generated/main/java" is what > build-helper-maven-plugin is used for): > > <build> > <sources> > <source>src/main/java</source> > <source>generated/main/java</source> > <sources> > </build> > > Additional attributes (release version, module name) may be added later, > but I would like to avoid this debate for now. But if we add a "type" > attribute now, the above proposal can actually replace all the following > (from the current POM model): > > <build> > <sourceDirectory>src/main/java</sourceDirectory> > <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> > <testSourceDirectory>src/test/java</testSourceDirectory> > <resources> > <resource> > <directory>src/main/resources</directory> > </resource> > </resources> > <testResources> > <testResource> > <directory>src/test/resources</directory> > </testResource> > </testResources> > </build> > > By a more uniform pattern like below. Keep in mind that the core of this > proposal is that all <source> elements are repeatable, not only the > <resource> or <testResource> ones: > > <sources> > <source type="main">src/main/java</source> > <source type="script">src/main/scripts</source> > <source type="test">src/test/java</source> > <source type="resource">src/main/resources</source> > <source type="test-resource">src/test/resources</source> > <sources> > I like it a lot. This could also prove very useful to better support multi-release JARs. However, resources have many more fields, see https://maven.apache.org/pom.html#resources, so I'm not really sure they can really be merged together. But we could have two sets: <build> <sources> <source scope="main">src/main/java</source> <source scope="main" multi-release="11">src/main/java11</source> <source scope="test">src/test/java</source> </sources> <resources> <resource type="main"> ... </resource> <resource type="test"> ... </resource> </resources> I used `scope` above, because we have `ProjectScope`defined in the API for that already. > > Martin > >