Jules
Jules

Reputation: 411

Maven dependency weird bug

I have 4 projects in my eclipse workspace. They are all 4 maven projects. The names are API, Games, Faction, Board.

API is used in all the other maven projects (Games, Faction, Board) and itself depends of a jar into my PC and also HikariCP.

I declare this dependencies in my API pom.xml

<dependency>
  <groupId>org.github.paperspigot</groupId>
  <artifactId>paperspigot-api</artifactId>
  <version>1.7.10-R0.1-SNAPSHOT</version>
  <scope>system</scope>
  <systemPath>${basedir}\lib\paperspigot-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>

<dependency>
  <groupId>com.zaxxer</groupId>
  <artifactId>HikariCP</artifactId>
  <version>2.7.8</version>
  <scope>compile</scope>
</dependency>

Then I declare on my 3 other projects that they depend of API

<dependency>
  <groupId>net.onima</groupId>
  <artifactId>onimaapi</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <scope>compile</scope>
</dependency>

But I have a big warning on the API and the error log says this:

I don't understand why is there this error as I can code with the API in my classes. Can someone explain me? Thanks

EDIT: As requested the text of the screenshot:
Description Resource Path Location Type Project 'OnimaAPI' is missing required Java project: 'paperspigot' OnimaAPI Build path Build Path Problem


Description Resource Path Location Type Project 'OnimaGames' is missing required Java project: 'onimaapi' OnimaGames Build path Build Path Problem

I don't know why I can't set the pom.xml here so here's a link: https://ghostbin.com/paste/r4u62

Upvotes: 0

Views: 264

Answers (1)

Matt
Matt

Reputation: 3760

You're declaring paperspigot with system scope.

<dependency>
  <groupId>org.github.paperspigot</groupId>
  <artifactId>paperspigot-api</artifactId>
  <version>1.7.10-R0.1-SNAPSHOT</version>
  <scope>system</scope>
  <systemPath>${basedir}\lib\paperspigot-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>

Dependencies with the scope system are always available and are not looked up in repository. They are usually used to tell Maven about dependencies which are provided by the JDK or the VM.

https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies

You should declare it with compile scope:

This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.

Upvotes: 1

Related Questions