You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by maven_newbie99 <fr...@visign.ch> on 2009/11/04 13:09:13 UTC
Creating a JAR with dependencies
Hi all,
I'm a Maven Newbie, so please forgive me if you find my question stupid.
In my project I use libraries such as Apache commons-collections and many
more. When I create an executable .JAR file of my project using the
org.apache.maven.plugins:maven-jar-plugin:2.2:jar
Goal, which I configured like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>path.to.my.MainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
It creates a .JAR file in the target folder containing only the source of my
project. Additionally it creates a subfolder "dependencies" containing all
dependent JARs.
What I really want is
first: the sources and the dependencies should be contained in a single JAR
second: is it possible not to include the whole dependent JARs but only
those classes within my dependencies that I really use in my code? Because
now my dependencies folder is about 11MB large, however I use only a tiny
portion of my dependencies.
Thanks a lot for any help!
--
View this message in context: http://old.nabble.com/Creating-a-JAR-with-dependencies-tp26195103p26195103.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: Creating a JAR with dependencies
Posted by Jesse Farinacci <ji...@gmail.com>.
A-ha! Ok, glad to hear you figured it out. :-)
On Wed, Nov 4, 2009 at 9:30 AM, maven_newbie99 <fr...@visign.ch> wrote:
>
> Please forget about my last post.
>
> I have had, for some copy/paste reason, the following lines in my .pom:
> <dependency>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-dependency-plugin</artifactId>
> <version>2.1</version>
> </dependency>
>
> which caused all these maven-specific libs to be added to the target.
>
-Jesse
--
There are 10 types of people in this world, those
that can read binary and those that can not.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Creating a JAR with dependencies
Posted by maven_newbie99 <fr...@visign.ch>.
Please forget about my last post.
I have had, for some copy/paste reason, the following lines in my .pom:
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</dependency>
which caused all these maven-specific libs to be added to the target.
Sorry.
Best regards, Frank
maven_newbie99 wrote:
>
> Hi jieryn,
>
> I could achieve what I want using your link (ueberjar). Many thanks.
>
> The only thing I don't understand is why so many maven-specific libraries
> are included in my taret? For eample:
> mavenmodel, mavenmonitor, mavenpluginapi, mavenpluginregistry, ...
> plexusarchiver, plexuscontainerdefault, ...
> junit
>
> and many more. It's a total of 77 libraries of which only ~10 are really
> used in my project.
>
> What do I need to change in order to get rid of these libraries in the
> target?
>
> I appreciate any help.
>
> Frank
>
>
>
> jieryn wrote:
>>
>> Hi Frank,
>>
>> On Wed, Nov 4, 2009 at 7:09 AM, maven_newbie99 <fr...@visign.ch> wrote:
>>>
>>> second: is it possible not to include the whole dependent JARs but only
>>> those classes within my dependencies that I really use in my code?
>>
>> Try http://mojo.codehaus.org/minijar-maven-plugin/
>>
>> --
>> There are 10 types of people in this world, those
>> that can read binary and those that can not.
>>
>> ---------------------------------------------------------------------
>> 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://old.nabble.com/Creating-a-JAR-with-dependencies-tp26195103p26197274.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: Creating a JAR with dependencies
Posted by maven_newbie99 <fr...@visign.ch>.
Hi jieryn,
I could achieve what I want using your link (ueberjar). Many thanks.
The only thing I don't understand is why so many maven-specific libraries
are included in my taret? For eample:
mavenmodel, mavenmonitor, mavenpluginapi, mavenpluginregistry, ...
plexusarchiver, plexuscontainerdefault, ...
junit
and many more. It's a total of 77 libraries of which only ~10 are really
used in my project.
What do I need to change in order to get rid of these libraries in the
target?
I appreciate any help.
Frank
jieryn wrote:
>
> Hi Frank,
>
> On Wed, Nov 4, 2009 at 7:09 AM, maven_newbie99 <fr...@visign.ch> wrote:
>>
>> second: is it possible not to include the whole dependent JARs but only
>> those classes within my dependencies that I really use in my code?
>
> Try http://mojo.codehaus.org/minijar-maven-plugin/
>
> --
> There are 10 types of people in this world, those
> that can read binary and those that can not.
>
> ---------------------------------------------------------------------
> 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://old.nabble.com/Creating-a-JAR-with-dependencies-tp26195103p26196655.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: Creating a JAR with dependencies
Posted by Jesse Farinacci <ji...@gmail.com>.
Hi Frank,
On Wed, Nov 4, 2009 at 7:09 AM, maven_newbie99 <fr...@visign.ch> wrote:
>
> second: is it possible not to include the whole dependent JARs but only
> those classes within my dependencies that I really use in my code?
Try http://mojo.codehaus.org/minijar-maven-plugin/
--
There are 10 types of people in this world, those
that can read binary and those that can not.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org