0

In my project I am using maven in that I have added a third party library dependency in my project pom.xml using

<dependency>
    <groupId>com.google.android</groupId>
    <artifactId>support-v4</artifactId>
    <version>r6</version>
</dependency>

now so this jar is coming in my local repo at the time of compiling I am able be see in maven dependency. Now I want to make a super jar which include three jar file two are in my eclipse work space and one in local repo . So I am able to include two file using below code

<property name="First.jar" value="${basedir}/../Some/bin/SomeFirst-${project.version}.jar" />
<available file="${First.jar}" type="file" property="First-found" />
<fail unless="First-found" message="ERROR: failed to find First.jar, looked here: ${First.jar}" />

<!-- verify second.jar is available -->
<property name="second.jar" value="${basedir}/bin/some-project-name-${project.version}.jar" />
<available file="${second.jar}" type="file" property="second-found" />
<fail unless="second-found" message="ERROR: failed to find second.jar, looked here: ${second.jar}" />



<!-- glue all jars together into a super jar -->
<zip destfile="${super.jar}">
    <zipfileset src="${Second.jar}" />
    <zipfileset src="${First.jar}" excludes="META-INF/*,connectors/*" />
    <zipfileset src="Need third file relative path here " excludes="META-INF/*" />
</zip>

I am able to work with full path like:

<zipfileset src="C:/Users/xxx/.m2/repository/com/google/android/support-v4/r7/support-v4-r7.jar"  /> 

But I am sure this will not work on others system. So how can i refer support-v4-r7.jar from local repo to Pom.xml relatively.

Raedwald
  • 46,613
  • 43
  • 151
  • 237
neeraj t
  • 4,654
  • 2
  • 27
  • 30
  • possible duplicate of [How can I create an executable jar with dependencies using Maven?](http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven) – Thorbjørn Ravn Andersen Jun 24 '13 at 11:49
  • 1
    Your "below code" is ant. You are using maven... Err... Using the maven-antrun plugin or something? – fge Jun 24 '13 at 11:50
  • 1
    What's the reason for putting two JARs in your Eclipse Workspace and one into the local maven repo and not putting all jars into the local maven repo? Sounds very strange to me. – andih Jun 24 '13 at 11:54

3 Answers3

1

The simple way to create an "uber JAR" in Maven is to use the Maven "shade" plugin. This will generate a JAR with the "content" of all of the dependent JARs. There are various options for reorganizing content and excluding things. The plugin documentation should be enough to get you started.

It may be possible to do this via the Mavan Ant plugin (as you seem to be doing), but that's not a good solution. For a start, your build is liable to break if / when you change the dependencies.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
0

You can define a local repository for your Maven by setting

 <localRepository>D:/Maven/LocalRepo</localRepository>   

in

  config/settings.xml 

when you build your maven project once successfully. All dependencies will download to your local repository.

In your case if you are using your own jar you can add that jar as follows to pom.xml

<dependency>
    <groupId>your.group.id</groupId>
    <artifactId>your.art.id</artifactId>
    <version>SNAPSHOT</version>
    <scope>provided</scope>
</dependency>
Ruchira Gayan Ranaweera
  • 34,993
  • 17
  • 75
  • 115
0

This change worked for me

<zipfileset src="${settings.localRepository}/com/google/android/support-v4/r7/support-v4-r7.jar" />
neeraj t
  • 4,654
  • 2
  • 27
  • 30