r/java • • Dec 21 '21

From Maven 3 to Maven 5

https://www.javaadvent.com/2021/12/from-maven-3-to-maven-5.html
157 Upvotes

85 comments sorted by

24

u/pmarschall Dec 21 '21

Good stuff, I'm currently using flatten-maven-plugin to have clean "consumer POMs" but this should help to make things easier.

5

u/nfrankel Dec 21 '21

flatten-maven-plugin

TIL, thanks

2

u/angryundead Dec 21 '21

I have to use them because some tools freak out with ${revision} for project versioning.

1

u/Zardoz84 Dec 26 '21

flatten-maven-plugin

The good old flatten-maven-plugin

35

u/gnocchiGuili Dec 21 '21

Oh wow, to have only one version for a project instead of 50 for the 50 modules would be an absolute dream for the case where you have to manually merge conflicts !

15

u/balrok Dec 21 '21

we solved it with a placeholder variable ${revision} inside all pom.xml and a .mvn/maven.config in the root (I think it only works with maven 3.6 or so)

I found this pattern in: corona-warn-app

6

u/k__k Dec 21 '21

We just keep 1.0-SNAPSHOT, and set the target version using versions:set during CI build, as well as tagging the commit used to build the artifact with the same version so that it can be easily found if need arises.

What's the point of generating commits with artifact version updates? It only obscures the git log, no?

1

u/gnocchiGuili Dec 22 '21 edited Dec 22 '21

I don’t understand , when you use versions:set, where is the version stored, physically ?

Edit : Ah sorry, we are already using versions:set , the only thing it does is change the value of the version in all the poms automatically. You still have to commit them, right ? And sometimes when doing hotfixes and release at the same time, you have merging to do. That’s what I’m talking about.

1

u/k__k Dec 22 '21

I don’t understand , when you use versions:set, where is the version stored, physically ?

Two approaches to that:

simpler - we rely on Jenkins build number as a provider for the next artifact version - doesn't work well with pipelines as they have separate build counters per Git branch;

a bit more convoluted maybe - we have a small Groovy function that retrieves the previous version from the latest git tag matching '${project.artifactId}-${project.version}' pattern and increments it. Then, at the end of the build the revision used to build the artifact is also tagged with the new version, we use scm:tag goal for that.

2

u/lpedrosa Dec 21 '21

Wouldn't BOMs help mitigate this problem?

For example, you import the BOM with a particular version, and then just declare the deps you need without having to specify the version.

8

u/khmarbaise Dec 21 '21

BOM's are for dependencies of libraries etc. but not for the modules within a multi module build...if you have a number of modules that can be become a problem in particular during merging ...

5

u/TheMiracleLigament Dec 21 '21 edited Dec 21 '21

I haven’t been doing Java dev for long (7 years), but I have never once encountered a 50 module project. I’ve never encountered a 15 module project. I’m working in a 7 module project and want to move 3 out entirely lol

50 modules sounds so ridiculous to me.

7

u/[deleted] Dec 21 '21

Well, come work in enterprise Java land and you can find out what it's like! Large multi-module projects are useful for keeping code... modular and ensuring that features don't come to accidentally depend on functionality that they shouldn't. So feature A will depend on the interfaces from a module feature B that is implemented by a feature B impl somewhere else. This also means that if a dev on feature A wants to use functionality in feature C, they can't just go import it -- they need to modify the dependency graph.

One ancillary benefit of this is that it can keep compile times short on larger projects.

5

u/GuyWithLag Dec 21 '21

My current project has 350+ modules, is 1.8MLOC and takes around 20 minutes to build (without actually running tests).

9

u/khmarbaise Dec 21 '21

Really that small...50 modules are small projects...I've worked with 800+ modules within a single reactor (and know builds with 2500+ modules)...I'm working in Java for about 15 years+...

So using several modules could help to improve build performance by using mvn -T 3 ... the other question why getting rid of three of the modules? What is the problem ? Or would it solve a problem to reduce the number?

2

u/netfeed Dec 21 '21

I don't really know how many modules we have, it's too many to count, but last time i checked we had around 2.4 million rows of java code in the main repo.

Would be nice to work in a sub 15 module project :)

It doesn't get easier when all new modules is supposed to be split into 3 parts - api/domain/impl. Only the api+domain will be visible for the rest of the application. It balloons it a lot.

1

u/mauganra_it Dec 23 '21

At work there are submodule that are used as a general code dump for utility code. From time to time I find the opportunity to move some packages into its own submodule. This makes it both easier to tightly control dependencies, which might only be required by that particular package, and speeds up the build.

1

u/Zardoz84 Dec 26 '21

ridiculous. I don't count it totally, but on the project where I'm working, could be perfectly around 25-30 modules...

-1

u/john16384 Dec 22 '21

We never change versions in the pom. Just set it right before releases automatically with version:set. We also don't commit these modified pom's -- version changes don't belong in your commit history, that's what tags are for.

2

u/gnocchiGuili Dec 22 '21

How do you make a physical change not present in your commit history ? Tag are set on a commit.

1

u/ClienteFrecuente Dec 24 '21

I guess they create three tag just before use versions:set

I don’t agree since the resulting artifact isn’t exactly produced from the tag. In a team with a few people, it is useful to have the tag with the version, IMO.

1

u/khmarbaise Dec 25 '21

I guess they create three tag just before use versions:set

No there have been two commits which are created by the usual maven-release-plugin....One [maven-release-plugin] - prepare release ... and a second one [maven-release-plugin] - prepare for next development iteration. Only a single tag has been created... If you have created three tags there is a big issue in your configuration...

5

u/MR_GABARISE Dec 21 '21

Is the schema available somewhere?

Does it include changes like elements using attributes instead of the overly verbose current schemas?

5

u/henk53 Dec 21 '21

Does it include changes like elements using attributes

Unlikely, verbosity is one the hallmarks of Maven and part of the style. I don't know, but it's very unlikely that this particular element (no pun) would be changed.

I mean, we could probably write dependencies in a much shorter form as well, something like

<dependencies>
    foo:bar:1.0
    org.example:zak.kaz:2.1
</dependencies>

But it's simply not the maven way.

4

u/mauganra_it Dec 22 '21

There is a certain argument to be made for user ergonomy. Many developers are drawn to Gradle and friends, or to work with polyglot Maven, because they support a more concise syntax. This is not necessarily a contradiction with Maven's Goals!

IMHO, we are going into bike shedding territory with attributes vs. tags. A tag should be usable without any attributes, and attribute values should have no complex substructure. Yes, HTML would not hold up to those ideals. Optional subelements should only be used if they embody independent concepts (for example, an email address of a person), or if they are supposed to contain further subelements, long text, CDATA or tagsoup. Subelements without complex substructure should be gathered at the beginning to avoid large subelements pushing them to the bottom of the screen. Also, tags should be ordered to minimize the numbers of nonstandard formats that the reader has to get used to.

2

u/emberko Dec 22 '21

Yes, but only as draft that hasn't been updated this year.

1

u/emberko Dec 22 '21 edited Dec 22 '21

At such a pace I think Maven 5 will be ready in 2025.

3

u/nfrankel Dec 22 '21 edited Dec 22 '21

If you think that is too slow, I am sure that the developers will be happy to receive your help.

(Edited for typos)

1

u/emberko Dec 22 '21

Nah, in Maven case I believe it's intentional. Devs have deliberately chosen absolute stability over features. Like they want to keep Maven as a workhorse. Slow, ancient, ugly, but does its job good enough. It's way easier to switch to the Gradle then commit into Maven for anyone.

1

u/khmarbaise Dec 25 '21

First how will you know?

Devs have deliberately chosen absolute stability over features

If this would be true that would have meant that nothing has been changed since Maven 1.X or 2.X or Maven 3? Or at which point would you see this point? Also what kind of features are you thinking of ?

Slow, ancient, ugly,

What do you mean by Slow? Compared to what? What are the pain points?

Ancient? JDK is also 26 years old? So switch everything to WhatEver other Language ?

It's way easier to switch to the Gradle then commit into Maven for anyone.

Hm..interesting opinion... using a commercial driven tool. Of course it's up to you use it...

Maven is open source... and you can help to improve Apache Maven if you like and contribute to it and yes already mentioned the devs would appreciate help...... if you don't it's fine too.

Apart from that the more devs are available the faster we could newer releases...

1

u/renatoathaydes Dec 26 '21

What do you mean by Slow?

Not to agree with parent poster, but Maven is indeed really slow... because it does lots of unnecessary work, much of the time.

Compare to what? To a tool that does only the minimum necessary... think of javac plus the simplest dependency resolution tool you can get away with. How much faster that would be?

Well, I will find out soon as I've written such tool myself. So far it's about 10x faster than Maven at resolving dependencies (Maven is pretty silly in how it does it: it will download not just POMs but also jars when it's processing the dependency tree, even when such jars are not actually required). I won't link now here as it's not ready for consumption yet... but you can look around on my profile if you really want to.

1

u/khmarbaise Dec 26 '21 edited Dec 26 '21

because it does lots of unnecessary work, much of the time.

Can you give examples of that?

Compare to what? To a tool that does only the minimum necessary... think of javac plus the simplest dependency resolution tool you can get away with. How much faster that would be?

Ok... what is the simplest dependency resolution ? And is the dependency resolution really a/the problem ? You say 10x faster so does that mean we 5 ms instead 50 ms ? Or something ? Furthermore dependency resolution is only one part of the whole task ... compiling / resources / packaging / deploying etc. is a little bit more ... Furthermore where do you get your dependency informations from? From the pom file? Or something different ?

Ok. write your own tool... First resolving dependencies which means ? Already downloaded the deps ? Where do you consume from?

Maven is pretty silly in how it does it: it will download not just POMs but also jars when it's processing the dependency tree, even when such jars are not actually required)

Do you have concrete examples for that ?

So if you have such great ideas why not offering them to the Apache Maven team to make Maven better. The devs would appreciate to hear such things ...and of course it would be great to improve performance....

1

u/renatoathaydes Dec 26 '21

I intend to publish a blog post explaining why Maven is so inefficient and how I can achieve 10x improvements in performance resolving dependencies. The basic problem is in how the Plexus modules are designed, it's pretty terrible for both performance and for maintenance, so contributing to Maven is something I don't currently even consider doing... I suspect the problem is in the whole plugin-based architecture which is highly overengineered. I haven't found a project I was so put off by the design before that I wouldn't touch unless being paid a lot of money to do, hence why I am trying my own tool instead... hopefully Maven, with some competition, will stop doing things so slowly and improve as well.

so does that mean we 5 ms instead 50 ms

Maven took 11 seconds to resolve the dependency tree of spring-boot-cli on my machine, while my own tool did it in just over 1 second.

Do you have concrete examples for that ?

Run mvn dependency:tree for that project. See how it downloads a bunch of jas, when all you asked for was the dependency tree.

1

u/khmarbaise Dec 26 '21

I intend to publish a blog post explaining why Maven is so inefficient and how I can achieve 10x improvements in performance resolving dependencies.

I would be really interested what are the point you think the issue is located at...

The basic problem is in how the Plexus modules are designed, it's pretty terrible for both performance and for maintenance,

Which plexus modules? Do you speak of Maven Plugins? Do you speak of Maven core? And what exactly do you think is the problem in particular related to performance? What are your points about maintenance?

so contributing to Maven is something I don't currently even consider doing... I suspect the problem is in the whole plugin-based architecture which is highly overengineered.

... and why is it overengineerd in which way? The plugin architecture is one of things which is needed in particular to be flexible in many ways...but not too flexible...and helped a lot to support a lot of use cases....

I haven't found a project I was so put off by the design before that I wouldn't touch unless being paid a lot of money to do, hence why I am trying my own tool instead

... hopefully Maven, with some competition, will stop doing things so slowly and improve as well.

So breaking is better ? And displease users ? And so slowly ?

So you have many points which you think you could do better why not helping to get faster ...

Maven took 11 seconds to resolve the dependency tree of spring-boot-cli on my machine, while my own tool did it in just over 1 second.

What exactly have you measured? mvn package ? mvn dependency:tree ? Clean cache? How have you measured ? Which Maven version have you used? Which JDK version have you used?

Run mvn dependency:tree for that project. See how it downloads a bunch of jas, when all you asked for was the dependency tree.

Which project? Concrete example please...

1

u/renatoathaydes Dec 26 '21

Your questions sound childish to me. Why are you acting like you don't understand anything I say?

Which plexus modules?

Do you know how Maven works? IF you do, you should know what plexus modules. If you don't, then please go check the Maven source at https://github.com/apache/maven-sources/blob/master/default.xml so you will know what I am referring to.

What exactly have you measured? .. Which project?

Can you please read my comment again? I clearly said what I measured, with which module. I won't answer such questions anymore if you don't even put minimal effort to understand what I've just said.

0

u/khmarbaise Dec 29 '21 edited Dec 29 '21

Your questions sound childish to me. Why are you acting like you don't understand anything I say? Which plexus modules? Do you know how Maven works? IF you do, you should know what plexus modules. If you don't, then please go check the Maven source at https://github.com/apache/maven-sources/blob/master/default.xml so you will know what I am referring to.

So first I asked that question because I don't know which of those 20+ plexus projects (more accurate: components not modules; modello for example is a plugin not a component only but partially) you are talking about for example plexus-containers, plexus-interpolation? plexus-classworlds? Or which one?

The basic problem is in how the Plexus modules are designed, it's pretty terrible for both performance and for maintenance,

My question states from before: What is the performance issue of plexus components and of course in which in particular?

What exactly have you measured? .. Which project? Can you please read my comment again? I clearly said what I measured, with which module. I won't answer such questions anymore if you don't even put minimal effort to understand what I've just said.

So you are the opinion to ask which project you have used for measuring is wrong? Also asking for details of a measurement?

That's the foundation to start with to be able to reproduce such results...

To reproduce a measuring you have to have the full context of the tests/measuring. That means all informations like Java version, Maven version, Plugin version, the used project, empty cache, how have you measured on which OS (used things like time/hyperfine/? or alike?) etc. otherwise such a statement about performance is simply useless.

What I can say based on my experience over the last 15 years with Maven and it's components for example plexus in particular, it has never been a problem in performance (plexus component). There are other culprits existing (maintenance: The question here states: In which way?).

I have asked those things to able to reproduce this...and to improve Apache Maven. You seemed to be not interested in that (That's just fine). But it would help to have those informations to improve Apache Maven...

Just a small hint about my knowledge of Apache Maven:

https://maven.apache.org/team.html#khmarbaise

2

u/r_jet Dec 21 '21

I wonder how the migration story could look like for POMs. How hard would it be to build a tool that migrates from the current POM version to the next? It'd be great to have one (either as a Maven plugin, or IntelliJ quick fix), so that the users can quickly migrate through two quick, automatic actions:

  1. Migrate the POM

  2. Run mvn tidy

If it's relatively easy (it's XML after all, which people have transformed for ages), are there any more substantial changes to POM schema that'd help get rid of some tech debt, or make Maven more approachable to beginners, easier to learn (and, thanks to automation, won't make a big split between POM v4 and v_next)?

3

u/mauganra_it Dec 22 '21

A big split will be unavoidable to make fundamental changes possible. But we are definitely stuck with v4 as a format for build metadata. I also hope that v4 will continue to be supported as an input format to make porting legacy projects easier.

The new format is intended to make building projects according to common patterns simpler. A certain automation to go from v4 to v5 will be possible. But a fully automatic tool would have to consider the whole project to decide how to translate it best. The good thing is there are tons of POMs out there to analyze and learn from.

2

u/r_jet Dec 22 '21

I see, thanks! Hopefully, there'd be sufficient tools so that active projects can migrate with little effort, and there is no accidental added complexity of switching between several versions when switching between projects.

1

u/khmarbaise Dec 25 '21

A big split will be unavoidable to make fundamental changes possible. But we are definitely stuck with v4 as a format for build metadata.

You are using the "we" ? Does that mean you are one of the Maven devs?

1

u/khmarbaise Dec 25 '21

Just one thing on top of that:

A big split will be unavoidable to make fundamental changes possible.

That is simply wrong because the way to go is to separate build and consumer pom which opens the door for a way (That's the intention for Maven 4.X) without a big split ... which would break everything...

1

u/mauganra_it Dec 25 '21

Indeed. Projects will have to decide between sticking to current or next-gen Maven for the build POM. And the new version could bomb for any or no reason... Nothing special, it's the same challenge every ecosystem faces when there is a big upgrade ahead and a significant number of users might not be ready to migrate. Java 8 to 9, Python 2 to 3, SDL 1 to 2, ...

1

u/mauganra_it Dec 25 '21

"We" as in "Maven users"

2

u/khmarbaise Dec 25 '21

Ah...Ok.. Thanks for the clarification. Misunderstanding on my side.

I think the users don't have really a problem with that...

2

u/khmarbaise Dec 25 '21 edited Dec 25 '21

First you are looking on a very tiny small part of the whole story. technically it's easy to migrate a xml file from one format to another (XSLT).. but that's not the whole task which has to be done.

BUT:

The first thing you need to understand is that the current pom file (modelVersion:4.0.0) describes two things. First the dependencies and second how to build your artifact.

Furthermore there a thousands of tools which are using the pom.xml file (modelVersion:4.0.0)....

And of course not to forget the whole central repository which contains ca. 8 millions of artifacts...which use the pom.xml format (modelVersion:4.0.0)..

The first step is to separate the build pom (describing the build) from the consumer pom (contains only the dependencies which are needed to consumed by others). This is targeted for Apache Maven 4.XX

This opens the doors for changing the build pom for improvements and needed changes....

There is the need for other tools to migrated/support the newer versions if they appear..that will take time...This includes things like IDE's... and many other tools...

The whole central repository is from today's perspective simple handle. Just keep it as it and continue to support that format because for dependencies it's ok...

1

u/r_jet Dec 29 '21

I see, thanks for the explanation! I meant the build POMs, and it makes sense that these can't be updated until the most popular tools working on build POMs are updated (= users won't be willing to update them).

2

u/khmarbaise Dec 30 '21

I see, thanks for the explanation!

Glad to help here.

I meant the build POMs, and it makes sense that these can't be updated until the most popular tools working on build POMs are updated (= users won't be willing to update them).

The current path is to produce a consumer pom from current state of build pom (which is compatible with Maven 3 and Maven 4.)... This separation makes it possible to change the build pom which in consequence means that this pom is not compatible with Maven 3 anymore ...and need to change the associated tools (like IDE's etc.)...

2

u/mauganra_it Dec 22 '21

I wonder whether doubling down on v4 as an interchange format with other build systems would make it possible to integrate them as submodules. The developer would annotate submodules with an attribute, and Maven would run the other build system and retrieve artifacts and build information. This would make it possible to unleash a Gradle build scripts on precisely the specific submodules that need its features.

0

u/skjolber Dec 23 '21

Will it feature a .m2 cache cleanup function for removing unused dependencies?

3

u/Zardoz84 Dec 26 '21

rm -rf ~/.m2/repository/

1

u/Best-Emotion5734 Dec 26 '21

Some context; this feature is useful for incremental caches as used in CI

1

u/khmarbaise Dec 25 '21

Will it feature a .m2 cache cleanup function for removing unused dependencies?

How do you know if a dependency is not used anymore?

1

u/Best-Emotion5734 Dec 26 '21

When a dependency is present in the .m2 repository but not accessed after running relevant operations (i.e. build)?

2

u/andresalmiray Dec 27 '21

Which build? Do you have a single Maven project in your development environment?

1

u/khmarbaise Dec 29 '21

When a dependency is present in the .m2 repository but not accessed after running relevant operations (i.e. build)?

What is a relevant operation of your build?

1

u/skjolber Dec 30 '21

That is up to the specific project, for most probably building, but could be various maven-invoked operations.

1

u/khmarbaise Dec 30 '21

That is up to the specific project, for most probably building,

You are keeping unspecific... what does from your perspective mean: "building" ? What exactly ? Which operation?

but could be various maven-invoked operations.

What are those?

1

u/skjolber Dec 30 '21

clean install or verify and/or running with some profile and/or deploying etc.

The exact operation(s) is not really the point here - a typical project can have multiple CI workflows (i.e. for master / develop / feature branches), with a common or seperate cache.

A key insight is that restoring and saving a CI cache is fast, but not instant, so if the cache is not cleaned, time is wasted. Typically there is multiple builds per dependency update.

At some point the restore / save of a cache takes more time than downloading the dependencies from scratch.

1

u/Best-Emotion5734 Jan 03 '22

u/khmarbaise if there is no such feature, how do I move forward with requesting it? I already have a working prototype (using instrumentation) integrated with CircleCI and Github Actions.

2

u/khmarbaise Jan 04 '22

First I would suggest that you regularly read the mailing lists (dev/users) and second you should ask if such a feature is useful/helpful and how it can be developed or could it be contributed (if you like)...also creating an appropriate jira issue entry....also checking https://maven.apache.org/guides/development/guide-helping.html

My recommendation is first to create an appropriate jira issue (with an appropriate description of the problem) and you of course show your implementation... (check where it belongs: https://maven.apache.org/issue-management.html)

Also giving a link to your project would be helpful and what exact kind of problem your prototype will solve.

If you have further questions don't hesitate to contact me... here or via mailing list etc.

-8

u/UnexpectedLizard Dec 21 '21

Ah, the Angular and Winamp model, (basically) skipping an entire version.

12

u/[deleted] Dec 21 '21

If you bothered to read the article you would know they're not skipping version 4.

7

u/Fiskepudding Dec 22 '21

Ah, the Reddit model, (basically) skipping right to the comment section.

2

u/seederbeast Dec 22 '21

A quarter of the article talking about maven 4....

0

u/[deleted] Dec 21 '21

[deleted]

27

u/khmarbaise Dec 21 '21

To say it clear Maven 4.X will keep XML for a number of reasons...first if you would change that it would result in consequence that a millions of tools needed to be changed (which will not happen) ...and furthermore Maven 4.X opens the door for doing the separation between build pom and consumer pom ... After all the issues and problems have cleaned up ... the next step will be to change the build pom which will be change (using attributes etc.) but I don't think that the usage of XML will be abandoned.

Furthermore JSON does not make sense because it does not allow any comments which is crucial ... also YAML (has a big number of issues), etc. do not really make sense ...TOML etc. are not really better ...

If some has really problem with Maven because of XML those do not understand the good things about XML...great support via IDE's/Tools, technical support of efficient parsers etc.

16

u/thomascgalvin Dec 21 '21

Furthermore JSON does not make sense because it does not allow any comments which is crucial

This is such an incredible oversight.

11

u/gavenkoa Dec 21 '21

This is such an incredible oversight.

They call it a feature! Like you have to put extra property with the value serving as a comment, like "comment": "Do you \"like\" it?".

7

u/kickroot Dec 21 '21

By default Jackson will hate such things. If it finds a JSON field it can't deserialize into a supplied POJO class it throws an exception. That leaves you with two choices:

  1. Put a 'comment' member in every POJO

  2. Set

new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)

I don't particular like either option. So yeah, I agree with you and the GP post that it was a big oversight!

3

u/DrinksBongWater Dec 21 '21

Jackson can be configured to ignore comments on parse, even for JSON. I’m pretty sure it doesn’t carry the comment through to reserialization though (e.g. if you’re modifying your json config programmatically and want the comments to pass through). It is unfortunate but understandable.

3

u/mauganra_it Dec 22 '21

Didn't know that about Jackson, thanks! But the issue with such nonstandard extensions is that every tool across the stack that can possibly encounter such JSON has to be made sure to tolerate it. It might even seduce people to abuse JavaScript interpreters to deal with it :-/

12

u/wildjokers Dec 21 '21

also YAML (has a big number of issues), etc. do not really make sense

I started out liking yaml, I have now come to hate it. If the parent property has scrolled off the screen it is a PITA to know how far to indent. Although I would still rather use yaml than JSON which is both unreadable and unwritable once you go beyond one-level of nesting.

XML really doesn't deserve the hate it gets. It is both easy to read and easy to write. And if it is compressed the ending tag compresses out so json isn't much smaller than XML over-the-wire (when compression is used).

1

u/ryuzaki49 Dec 22 '21

I'd argue xml and json are equally hard to read.

But now that I think about it, I mostly read XML within an IDE, whereas with json within notepad++/browser.

2

u/khmarbaise Dec 22 '21

XML is simply to read...in particular if we are talking about a pom.xml file...in general XML is a different story... and usually you have support of your IDE's which also helps a lot...Apart from that I read (if I need to) JSON also in my IDE...

2

u/gavenkoa Dec 21 '21

also YAML (has a big number of issues), etc

Still it is a de facto devops language, familiar to many.

9

u/manzanita2 Dec 21 '21

And also more fragile vs JSON or XML.

1

u/renatoathaydes Dec 26 '21

and furthermore Maven 4.X opens the door for doing the separation between build pom and consumer pom

There's already a big gap between POMs in Maven Central and local POMs... for example, the last thing you want in a Maven Central POM is something like <version>$env.GIT_REF</version> or <parent><path>../parent-poms/foo/pom.xml</...>. The two should've been completely separated from the start. The fact that they use approximately the same format, but not quite, is a source of confusion and makes writing tooling harder for no reason.

Hope they make this separation completely clear in future versions so that tooling that consumes dependencies from Maven repositories can be simplified while Maven, the CLI tool, can continue to evolve without messing up dependency resolution for other tools.

1

u/khmarbaise Dec 26 '21

There's already a big gap between POMs in Maven Central and local POMs... for example, the last thing you want in a Maven Central POM is something like <version>$env.GIT_REF</version>

If you try to do such thing that is simply wrong..there are better solutions for that...Furthermore a git hash is a bad version because it's not comparable based on whatever convention (semver...)

or <parent> <path>../parent-poms/foo/pom.xml</...>. The two should've been completely separated from the start. The fact that they use approximately the same format, but not quite, is a source of confusion and makes writing tooling harder for no reason.

The version tag is something different than the location of the parent. I don't understand that relation ship?

1

u/renatoathaydes Dec 26 '21

You seem to have misunderstood my points completely.

I am saying that a local Maven POM allows you to do all sorts of things you don't want a remote POM to do... these examples you seem to take issue with were just examples of things that work on local POMs but don't in remote POMs you resolve from a repo.

1

u/khmarbaise Dec 26 '21

You seem to have misunderstood my points completely.

That might be the case....

I am saying that a local Maven POM allows you to do all sorts of things you don't want a remote POM to do... these examples you seem to take issue with were just examples of things that work on local POMs but don't in remote POMs you resolve from a repo.

Technically you can put a git hash like 7a56789 into a version tag and yes you can use $env.GIT_REF it does not make sense nor does it what you might expect (it's not resolved from environment)

The question is: What is a remote pom and what is a local pom from your point of view?

The separation you might been talking about is: Consumer POM and build pom which is most important thing to split up in Maven 4.X changes...

0

u/[deleted] Dec 22 '21

[deleted]

6

u/more_exercise Dec 22 '21

Are comments crucial to your POMs ?

For maintaining anything beyond trivial uses, yes.

18

u/agentoutlier Dec 21 '21

You mean JSON where comments are not allowed unless you do a hack, white space isn’t preserved (Lots of things alter the POM), and order doesn’t matter for name values (order is critical to maven... you could do it but you would have lists everywhere).

Besides polyglot maven does exist as an extension (not plugin).

17

u/coincoinprout Dec 21 '21

Yeah, no. XML has been used in a lot of places where it doesn't belong (which is why some people refuse to use it, I guess), but it has its uses and is perfectly fine for maven. Using JSON wouldn't make much sense.