Skip to content

Consider allowing to modify Maven 4 dependency types to mitigate incompatibility with other build tools #75

@Xasmedy

Description

@Xasmedy

Unfortunately other build tools are not up to date with the new Maven 4 types.
Meaning that if I publish a library, and I have a dependency with the type modular-jar inside my publishing pom.xml, build tools like gradle will fail to include my library.

This could be resolved by being able to provide the dependency type manually when I include() the dependency, or when I provide the publishing information, or in some other way. Otherwise when I include a dependency with module(), the modular-jar type is always going to be used.

Taking for example this JSpecify dependency having the modular-jar type, and the following gradle error when trying to find it:

<dependency>
    <groupId>org.jspecify</groupId>
    <artifactId>jspecify</artifactId>
    <version>1.0.0</version>
    <type>modular-jar</type>
    <scope>compile</scope>
</dependency>
> Could not find jspecify-1.0.0.modular-jar (org.jspecify:jspecify:1.0.0).
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/jspecify/jspecify/1.0.0/jspecify-1.0.0.modular-jar

The problem can be mitigated by replacing the dependency before publising, from a modular one to a normal one:

private void patchPublishJSpecify() {
    // Gradle does not support Maven 4 new types, so I'm forced to patch the type, making it `jar` instead of `modular-jar`.
    scope(compile).clear();
    scope(compile).include(dependency("org.jspecify", "jspecify", version(1, 0, 0)));
}

Another reasonable option is to do nothing and wait for an official Maven 4 release and the following adoption from other build tools. Using the mitigation above before support arrives.

In my opinion, waiting is the right option, having to do some changes just because other build tools are behind, does not feel reasonable. I mainly created this issue for discussion and making this problem known.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions