Hello Florent,

i'll suggest something while I know this is not exactly what you asked for.
But i'll try nevertheless, it may help :)

If you could change your requirements a bit to change the *version* instead
of the artifactId, then you could use the
ci-friendly concept in Maven (
https://maven.apache.org/maven-ci-friendly.html ). This in conjonction with
the flatten plugin
that ensures pom.xml are correctly alterned before being deployed could
help to have something quite similar to what you asked.

So my idea is to run a command similar to:

mvn deploy -Drevision=1.2.3-2.12
or
mvn deploy -Drevision=1.2.3-2.13

The consumer of your artifacts would have to update the version as well as
the artifactId, but they are usually colocated so it may be acceptable.
This is compatible with multi-module Maven projects where each child just
reference the parent pom with the ${revision} variable.
Hope this helps

François


Le lun. 12 juin 2023 à 15:21, Florent Biville <florent.bivi...@gmail.com> a
écrit :

> Hello,
>
> I'm working on a multi-module Maven project where part of the artifact ID
> includes the Scala version it is built against (2.12, 2.13, ...), as it is
> common with Scala projects, since Scala minor version bumps often break (or
> so I read).
>
> I'm currently trying to fix the project setup, since it relies on dynamic
> expressions in some of the module artifact IDs to achieve the above effect
> and that does not really work (and litters the build with warnings,
> rightfully so).
>
> My current approach is to script the whole thing, something like
> "./build-for-scala.sh 2.12" or "./build-for-scala-2.13". Sprinkle some sed
> and it kinda works.
>
> However, it is very fragile. Not only must the module artifact IDs change,
> but so must any reference to the parent POM and the artifact ID of each
> dependency sibling.
>
> Reading about this problem led me to
> https://stackoverflow.com/a/35023562/277128 but the solution is not very
> compelling.
>
> And of course, since that's an established project, I cannot afford to
> change the artifact IDs before the next major version.
>
> I would not even mind writing my own plugin or extension if that could
> solve this particular dynamic artifact ID resolution.
>
> Has anyone faced this before? How did you manage to solve this problem "the
> Maven way"?
>
> Best regards,
> Florent
>

Reply via email to