0

I use Maven and have external library(soot). I want to add this library to my project with Maven, and then package into 1 uber jar.

1)To add library, i can use local repo(example).

2)To get a jar with dependencies, i can use shade-plugin or other.

But together it isn't work, because on first step dependency have scope , and this dependency will not be added to uber jar.

I understand that i can do mvn install, but it will work only on my machine.

Is it possible to achieve my initial goal?

Community
  • 1
  • 1
watson94
  • 63
  • 1
  • 1
  • 5
  • what kind of scope?? have you tried https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html ? – sodik Apr 30 '15 at 17:38
  • mvn install works fine, but i need to do it on every computer – watson94 Apr 30 '15 at 17:42
  • and what scope do you use?? it should work fine – sodik Apr 30 '15 at 18:04
  • and maybe check this question in case you have similar problems http://stackoverflow.com/questions/22015685/maven-3-does-not-update-snapshot-dependency-from-local-repository – sodik Apr 30 '15 at 18:06
  • It works. In this solution i should install this file on every computer(where i will run my programm). I want to modify something that can be under vcs(pom.xml or another files in my project). – watson94 Apr 30 '15 at 18:11
  • but dummy question: what's wrong with in-project local repo (as from your example)? – sodik Apr 30 '15 at 18:25
  • As i understand dependency from local repository has scope . Am i wrong? – watson94 Apr 30 '15 at 19:25
  • not at all, local repository is as any other. system scope has complete different purpose. – sodik Apr 30 '15 at 19:43

1 Answers1

0

Maybe the simplest solution for you would be to use your local (company?) repository like Artifactory.

However if it is not possible, you can use local in-project repository (as from your example) and keep it in your vcs.

<repository>
    <id>in-project</id>
    <name>In Project Repo</name>
    <url>file://${project.basedir}/libs</url>
</repository>

The only trick is how to get artifacts (jars) to that local repository:

mvn deploy:deploy-file -Dfile=fooLib.jar  -DgroupId=com.test -DartifactId=fooLib -Dversion=1.0.1 -Dpackaging=jar -Durl=file://pathTo/libRepo -DrepositoryId=in-project

And you just use it as any other dependency

<dependency>
        <groupId>com.test</groupId>
        <artifactId>fooLib</artifactId>
        <version>1.0.1</version>
</dependency>

Definitely don't use system scope, since such dependencies are expected to be found in system and therefore are not bundled with JAR.

Community
  • 1
  • 1
sodik
  • 4,675
  • 2
  • 29
  • 47