0

I got a maven project with some third-party dependencies, wich later are provided automatically to my application, and thus may not be included into my JAR.

Additionally I got some other dependencies, wich are my own libraries and are only available locally outside of an repository. So I created a local repo:

<!-- local repo -->
<repository>
    <id>local-maven-repo</id>
    <url>file:///${project.basedir}/lib</url>
</repository>

I then added the dependency as usual:

<dependency>
    <groupId>de.cydhra</groupId>
    <artifactId>ABCommands</artifactId>
    <version>1.0-SNAPSHOT</version>
    <scope>compile</scope>
</dependency>

When I remember the maven spec correctly, the dependency should now be included into my JAR, because the scope is "compile" (I've also tried runtime: same result). But the dependency is completly ignored when running "mvn package".

Again: I do not want to know, how to INCLUDE dependencies into my project, but how to COMPILE them into the finished App.

I currently use the maven-compiler plugin to generate my jar. While googling, I've heard about the maven jar plugin, wich has an option to "include classpath", which writes my dependencies into the manifest and nothing further, well thanks. Furthermore the maven assembly plugin can generate a jar-with-dependencies, which contains ALL of my dependencies, also those, which should be provided. So what am I missing?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Cydhra
  • 581
  • 1
  • 7
  • 17
  • `ABCommands` does not have a `provided` scope but `compile`. Why are you mentioning `provided` dependencies? Do you want to make an uber jar with provided dependencies? [Like here](http://stackoverflow.com/questions/8166753/how-to-include-dependency-with-provided-scope-with-maven-assembly-plugin)? – Tunaki Sep 05 '16 at 19:04
  • No, ABCommands is not the only dependency. Some others have provided as their scope. – Cydhra Sep 05 '16 at 19:18
  • The shade plugin will not include provided dependencies. It will only include compile and runtime dependencies. And the `jar-with-dependencies` of the Assembly Plugin will not include `provided` dependencies as well (by default) – Tunaki Sep 05 '16 at 19:23
  • Yeah, but my problem was, that the compiler plugin by default did not include any of the deps, even compile and runtime ones. Shade does. – Cydhra Sep 05 '16 at 20:38

1 Answers1

1

Use maven's shade plugin and when you compile your project,
the jar will include inside of it your project's dependencies

Evyatar
  • 176
  • 1
  • 9
  • It works. Without any further configuration. Wow. This never happened to me while using maven :D Thanks. – Cydhra Sep 05 '16 at 18:48
  • @Cydhra glad to hear it and I will appreciate if you choose this answer as accepted if thats really the answer you were looking for – Evyatar Sep 05 '16 at 19:00
  • Yes sure, I wasn't able to when I commented, because SO blocks it for some minutes ;) – Cydhra Sep 05 '16 at 19:17