You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by dornad <do...@gmail.com> on 2008/01/25 21:03:45 UTC
mvn package: Generated JAR and external dependencies
Hello everybody,
I've been trying to look for this all over the forums but so far, I haven't
been able to find any answer.
I have a m2 project in Eclipse, which uses some external libraries via
Maven's Dependency Mechanism. As long as I run my project inside Eclipse,
everything's perfect. The problem is when I build my JAR via mvn package.
When I try to run the JAR, I get a NoClassDefFoundError:
org/apache/commons/logging/LogFactory.
Is there anyway to tell maven to set the classpath, so the JAR can find the
missing dependencies in the local repository ?
I also plan to distribute this app to some pcs, and some of them doesn't
have maven installed. I read somewhere that including those JAR inside my
JAR is a bad practice. Any ideas ?
I'm uploading my http://www.nabble.com/file/p15095045/pom.xml pom.xml , so
everyone can check it.
--
View this message in context: http://www.nabble.com/mvn-package%3A-Generated-JAR-and-external-dependencies-tp15095045s177p15095045.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: mvn package: Generated JAR and external dependencies
Posted by dornad <do...@gmail.com>.
Thanks for your suggestion,
Actually I found another solution in
http://dsd.lbl.gov/~ksb/Scratch/Maven_notes.html KSB's Maven Notes .
The only problem so far is that I can't seem to get the assembly plugin
working as part of the package lifecycle.
Thanks.
Olivier Lamy wrote:
>
> Hi,
> You can build a jar which include the dependencies.
> Add this in your pom :
>
> <plugin>
> <artifactId>maven-shade-plugin</artifactId>
> <executions>
> <execution>
> <phase>package</phase>
> <goals>
> <goal>shade</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
>
> --
> Olivier
>
> 2008/1/25, dornad <do...@gmail.com>:
>>
>> Hello everybody,
>>
>> I've been trying to look for this all over the forums but so far, I
>> haven't
>> been able to find any answer.
>>
>> I have a m2 project in Eclipse, which uses some external libraries via
>> Maven's Dependency Mechanism. As long as I run my project inside
>> Eclipse,
>> everything's perfect. The problem is when I build my JAR via mvn
>> package.
>>
>> When I try to run the JAR, I get a NoClassDefFoundError:
>> org/apache/commons/logging/LogFactory.
>>
>> Is there anyway to tell maven to set the classpath, so the JAR can find
>> the
>> missing dependencies in the local repository ?
>>
>> I also plan to distribute this app to some pcs, and some of them doesn't
>> have maven installed. I read somewhere that including those JAR inside
>> my
>> JAR is a bad practice. Any ideas ?
>>
>> I'm uploading my http://www.nabble.com/file/p15095045/pom.xml pom.xml ,
>> so
>> everyone can check it.
>> --
>> View this message in context:
>> http://www.nabble.com/mvn-package%3A-Generated-JAR-and-external-dependencies-tp15095045s177p15095045.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/mvn-package%3A-Generated-JAR-and-external-dependencies-tp15095045s177p15097636.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: mvn package: Generated JAR and external dependencies
Posted by "Ryan H." <wa...@gmail.com>.
configure the maven-jar-plugin to have additional directory be added to the
classpath. check out "addClasspath" and "classpathprefix" in the jar doc
On Jan 29, 2008 10:41 PM, crishantha <cr...@virtusa.com> wrote:
>
> Hi Oliver,
>
> I have the same issue as donald mentioned. Hence, I tried the shade plugin
> by adding the code snippet you gave to the POM. But I still get an error
> saying that,
>
> \target\HPMASReports-1.0-SNAPSHOT-shaded.pom (The system cannot find the
> path specified)
>
> Am I missing anything in the process?
>
> Please help
>
> Thank you very much
>
> Crishantha
>
> Olivier Lamy wrote:
> >
> > Hi,
> > You can build a jar which include the dependencies.
> > Add this in your pom :
> >
> > <plugin>
> > <artifactId>maven-shade-plugin</artifactId>
> > <executions>
> > <execution>
> > <phase>package</phase>
> > <goals>
> > <goal>shade</goal>
> > </goals>
> > </execution>
> > </executions>
> > </plugin>
> >
> > --
> > Olivier
> >
> > 2008/1/25, dornad <do...@gmail.com>:
> >>
> >> Hello everybody,
> >>
> >> I've been trying to look for this all over the forums but so far, I
> >> haven't
> >> been able to find any answer.
> >>
> >> I have a m2 project in Eclipse, which uses some external libraries via
> >> Maven's Dependency Mechanism. As long as I run my project inside
> >> Eclipse,
> >> everything's perfect. The problem is when I build my JAR via mvn
> >> package.
> >>
> >> When I try to run the JAR, I get a NoClassDefFoundError:
> >> org/apache/commons/logging/LogFactory.
> >>
> >> Is there anyway to tell maven to set the classpath, so the JAR can find
> >> the
> >> missing dependencies in the local repository ?
> >>
> >> I also plan to distribute this app to some pcs, and some of them
> doesn't
> >> have maven installed. I read somewhere that including those JAR inside
> >> my
> >> JAR is a bad practice. Any ideas ?
> >>
> >> I'm uploading my http://www.nabble.com/file/p15095045/pom.xml pom.xml,
> >> so
> >> everyone can check it.
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/mvn-package%3A-Generated-JAR-and-external-dependencies-tp15095045s177p15095045.html
> >> Sent from the Maven - Users mailing list archive at Nabble.com<http://nabble.com/>
> .
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: users-help@maven.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/mvn-package%3A-Generated-JAR-and-external-dependencies-tp15095045s177p15176393.html
> Sent from the Maven - Users mailing list archive at Nabble.com<http://nabble.com/>
> .
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: mvn package: Generated JAR and external dependencies
Posted by crishantha <cr...@virtusa.com>.
Hi Oliver,
I have the same issue as donald mentioned. Hence, I tried the shade plugin
by adding the code snippet you gave to the POM. But I still get an error
saying that,
\target\HPMASReports-1.0-SNAPSHOT-shaded.pom (The system cannot find the
path specified)
Am I missing anything in the process?
Please help
Thank you very much
Crishantha
Olivier Lamy wrote:
>
> Hi,
> You can build a jar which include the dependencies.
> Add this in your pom :
>
> <plugin>
> <artifactId>maven-shade-plugin</artifactId>
> <executions>
> <execution>
> <phase>package</phase>
> <goals>
> <goal>shade</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
>
> --
> Olivier
>
> 2008/1/25, dornad <do...@gmail.com>:
>>
>> Hello everybody,
>>
>> I've been trying to look for this all over the forums but so far, I
>> haven't
>> been able to find any answer.
>>
>> I have a m2 project in Eclipse, which uses some external libraries via
>> Maven's Dependency Mechanism. As long as I run my project inside
>> Eclipse,
>> everything's perfect. The problem is when I build my JAR via mvn
>> package.
>>
>> When I try to run the JAR, I get a NoClassDefFoundError:
>> org/apache/commons/logging/LogFactory.
>>
>> Is there anyway to tell maven to set the classpath, so the JAR can find
>> the
>> missing dependencies in the local repository ?
>>
>> I also plan to distribute this app to some pcs, and some of them doesn't
>> have maven installed. I read somewhere that including those JAR inside
>> my
>> JAR is a bad practice. Any ideas ?
>>
>> I'm uploading my http://www.nabble.com/file/p15095045/pom.xml pom.xml ,
>> so
>> everyone can check it.
>> --
>> View this message in context:
>> http://www.nabble.com/mvn-package%3A-Generated-JAR-and-external-dependencies-tp15095045s177p15095045.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/mvn-package%3A-Generated-JAR-and-external-dependencies-tp15095045s177p15176393.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: mvn package: Generated JAR and external dependencies
Posted by Olivier Lamy <ol...@apache.org>.
Hi,
You can build a jar which include the dependencies.
Add this in your pom :
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
--
Olivier
2008/1/25, dornad <do...@gmail.com>:
>
> Hello everybody,
>
> I've been trying to look for this all over the forums but so far, I haven't
> been able to find any answer.
>
> I have a m2 project in Eclipse, which uses some external libraries via
> Maven's Dependency Mechanism. As long as I run my project inside Eclipse,
> everything's perfect. The problem is when I build my JAR via mvn package.
>
> When I try to run the JAR, I get a NoClassDefFoundError:
> org/apache/commons/logging/LogFactory.
>
> Is there anyway to tell maven to set the classpath, so the JAR can find the
> missing dependencies in the local repository ?
>
> I also plan to distribute this app to some pcs, and some of them doesn't
> have maven installed. I read somewhere that including those JAR inside my
> JAR is a bad practice. Any ideas ?
>
> I'm uploading my http://www.nabble.com/file/p15095045/pom.xml pom.xml , so
> everyone can check it.
> --
> View this message in context: http://www.nabble.com/mvn-package%3A-Generated-JAR-and-external-dependencies-tp15095045s177p15095045.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org