Issue
Hello Stackoverflow community,
i recently started working with maven to see what is possible or better to see if its easier to have a dependency manager or including everything to your own.
Basic Informations
Repository
href="https://github.com/JXCoding/MavenTests" rel="nofollow noreferrer">https://github.com/JXCoding/MavenTests
Reactor
<groupId>de.jxson.maven</groupId>
<artifactId>MavenTests</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>API</module>
<module>v1_18_R1</module>
</modules>
submodule API
<parent>
<artifactId>MavenTests</artifactId>
<groupId>de.jxson.maven</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>API</artifactId>
<dependencies>
...
</dependencies>
Which depends of reactor as parent
submodule v1_18_R1
<parent>
<artifactId>MavenTests</artifactId>
<groupId>de.jxson.maven</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>v1_18_R1</artifactId>
<dependencies>
<dependency>
<groupId>de.jxson.maven</groupId>
<artifactId>API</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
Which depends of API and reactor as parent
My Problem is:
When I build with mvn clean package
, there is an error on my module v1_18_R1 in which a class from API is not found.
Questions:
Why a class is not found if the required dependency is already added?
Solution
Usually maven reactor is used for:
- Collects all the available modules to build
- Sorts the projects into the correct build order
- Builds the selected projects in order
And not to be as parent of another projects. If you need to centralize libraries , versions, etc create a extra project with <packaging>pom</packaging>
.
Solution
- Remove the parent from your submodules
- Add this to all of your submodules which requires spigot jars
<repositories>
<repository>
<id>elmakers-repo</id>
<url>https://maven.elmakers.com/repository/</url>
</repository>
</repositories>
WIth these fixes, I was able to build your git repository with mvn clean package
Spigot notes
- offical git repository don't build https://hub.spigotmc.org/stash/projects/SPIGOT
- Official repository don't works: https://www.spigotmc.org/wiki/spigot-maven/
- Only this repository works https://maven.elmakers.com/repository/org/spigotmc/spigot/
Answered By - JRichardsz
Answer Checked By - Cary Denson (JavaFixing Admin)