Project using Dynmap Bukkit API suddenly fails to compile without any change
Programie opened this issue ยท 6 comments
I've a Bukkit plugin which uses Dynmap Bukkit API to add markers to the map.
Without any change, the plugin doesn't compile anymore as it now tries to use the Bukkit 1.7.10-R0.1-SNAPSHOT dependency instead of the one for Bukkit/Spigot 1.14.4 as defined in my project pom.
I'm adding the spigot-api dependency in my parent pom. Adding the spigot-api directly to the project pom fixes the issue. But why does this happen without any change on my side?
The issue can be reproduced this way:
Not working as my project is using classes not available in Bukkit 1.7.10 (dynmap-api first, then spigot-api, just like spigot-api would be included in the parent pom):
<project>
...
<dependencies>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Working (spigot-api first, dynmap-api last):
<project>
...
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>3.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Additionally to that issue, my shaded jar file now includes the bukkit API as Dynmap Bukkit API is including it in the project (which also didn't happen before). So I guess, there must be some change to the Maven repo (repo.mikeprimm.com).
was this ever fixed for you @Programie ? My maven fails to compile any version of dynmap-api
Scope should be 'provided' - and it definitely should be excluded if you are making a shaded JAR. The API has a transitive dependency on Bukkit API, since it does refer to Bukkit classes - if you put spigot first, it'll provide the bukkit-api based on its level and dependencies, while the older transitive dependency will apply in the other order...
You are right. Adding <scope>provided</scope>
to the dependency fixes both issues. Now my build is working again and the shaded JAR does not include the Dynmap API anymore.
Thanks for the hint!
But for some reason, it does not work if I define the spigot-api dependency in my parent pom (which I'm using to define common things like spigot-api repository and dependency as well as various plugins like maven-shade-plugin and maven-release-plugin).
In my case, I'm defining a property bukkit-api-version
in my pom.xml and using that property in my parent pom to define the version for the spigot-api dependency.
I guess, the way Maven resolves the Bukkit version in dynmap-api only works if the dependency has been defined in the projects pom.xml (instead of the parent pom). But I don't know whether that's an issue with the dynmap-api dependency or maybe even a Maven issue.
Yep - I know there can be some oddness when POM dependencies (particularly transitive ones) yield different versions. IIRC (I'm mostly doing Gradle these days :) ), there is a dependencyManagement section you can put at the top of a POM that is getting in to transitive dependency 'clash' to basically force the 'right' answer - this might help - https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html