[MNG-7005] Support Gradle style GAV form for dependencies
Chris Caspanello opened MNG-7005 and commented
I'm currently migrating a project from Gradle to Maven. One thing that makes pom files so large is the typical 5 lines for a dependnecy. It would be nice to be able to define the dependency similar to Gradle
Instead of :
<dependencies>
<dependency>
<groupId>myGroup</groupId>
<artifactId>myArtifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>anotherGroup</groupId>
<artifactId>anotherArtifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
It would be less verbose to use a <gav> block like this:
<dependencies>
<gav>myGruop:myArtifact:1.0.0-SNAPSHOT</gav>
<gav>anotherGroup:anotherArtifact:1.0.0-SNAPSHOT</gav>
</dependencies>
I think an improvement like this would make Maven less verbose; one of the things that is attractive about Gradle.
I may be over simplifying this; but under the covers we'd just split the gav block on the semi colon and popoulate the existing dependency model.
1 votes, 4 watchers
Michael Osipov commented
There is already a similar issue. This won't and cannot happen before version 4 or 5 with a model change. Moreover, you proposal does not scale, you cannot exclude transitive dependencies.
Chris Caspanello commented
@Michael Osipov - I'm not suggesting we get rid of the typical <dependency> block; that can still be used to exclude certain transitivie dependencies.
I'm veiewing the <gav> tag as a simple shortcut.
Optionally if you want to exclude all tranitive dependencies maybe you could add something like this <gav transitives="false">myGruop:myArtifact:1.0.0-SNAPSHOT</gav>
It is still shorter and easier to read than <dependency> <groupId>myGroup</groupId> <artifactId>myArtifact</artifactId> <version>1.0.0-SNAPSHOT</version> <exclusions> <exclusion> <groupId>*</groupId> <artifactId>*</artifactId> </exclusion> </exclusions> </dependency>
Chris Caspanello commented
Michael Osipov - Can you please elaborate why it won't be helpful? I've got a few people on my team that would be interested in a (alternate) short hand way of defining dependencies.
Michael Osipov commented
Supporting wildcard excludes all or nothing will not scale. People want/need to exclude selectively. Back to the topic, even if you consider is handy, pratical, etc. this is syntactical sugar and will likely lay around for years w/o being touched. Our resources are tight.
Chris Caspanello commented
Michael Osipov - Like I said; this is an additive feature for shorthand. Nothing prevents people from using the regular <dependency> block we all know and love
I can help contribute to this feature if you like
Michael Osipov commented
Thank you for the offer, but believe me, this will require busload of changes and won't be accepted anytime soon.
Delany commented
Dependencies are the busiest part of the pom and managing them is Maven's main job. I think you underestimate how much tedium it would save having a one line tag that matches command line arguments/log output.
Even if you retain the dependency tag for exclusions its still a big improvement.
<dependencies>
<dependency>
<gav>myGroup:myArtifact:1.0.0-SNAPSHOT:compile</gav>
</dependency>
<dependency>
<gav>anotherGroup:anotherArtifact:1.0.0-SNAPSHOT:test</gav>
</dependency>
</dependencies>
Delany commented
Im not a fan of the attributes tag in https://issues.apache.org/jira/browse/MNG-6288
It feels like dependencyManagement is the appropriate place for customizations, i.e. <dependencyManagement><exclusions>
Then could have like the OP suggested <dependencies><gav>
Guillaume Nodet commented
FWIW https://github.com/maveniverse/mason Note that it should now be easy to add in mason a slightly different XML parser supporting the compact syntax.
- Out of curiosity, I want to know whether
pom.yaml,pom.json,pom.conf,pom.hocon,pom.tomlused by https://github.com/maveniverse/mason will replacepom.xmlas the default in Maven 4 or Maven 5?
- Out of curiosity, I want to know whether
pom.yaml,pom.json,pom.conf,pom.hocon,pom.tomlused by https://github.com/maveniverse/mason will replacepom.xmlas the default in Maven 4 or Maven 5?
I personally doubt that (and would vote against it, as XML is the only format you can validate with a schema)