You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Thomas Chang <th...@yahoo.de> on 2008/01/26 06:48:28 UTC

How to include the dependencies in the built jar?

Hi all,
   
  assumed we have a project with packaging jar. When we build the project with "mvn package", a jar is build. But the dependencies in the project are not included in the built jar. Is it possible to include the dependencies in the built jar?
   
  Regards
   
  Thomas

       
---------------------------------
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit dem  neuen Yahoo! Mail. 

Re: How to include the dependencies in the built jar?

Posted by Thomas Chang <th...@yahoo.de>.
If you say "there is no such convention for a .jar file", what does ahd for what use is "jar-with-dependencies"?
   
   
  **********************************
  What do you mean?

As far as I know, while the .war and .ear formats allow jars to be
nested inside jars, there is no such convention for a .jar file.

If you use a maven package type of "war" or "ear" in the pom, then
a .war or .ear does get created, and the dependencies are present.

Regards,
Simon

   
  On Sat, 2008-01-26 at 06:48 +0100, Thomas Chang wrote:
> Hi all,
>    
>   assumed we have a project with packaging jar. When we build the
 project with "mvn package", a jar is build. But the dependencies in the
 project are not included in the built jar. Is it possible to include the
 dependencies in the built jar?




       
---------------------------------
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit dem  neuen Yahoo! Mail. 

Re: How to include the dependencies in the built jar?

Posted by simon <si...@chello.at>.
On Sat, 2008-01-26 at 06:48 +0100, Thomas Chang wrote:
> Hi all,
>    
>   assumed we have a project with packaging jar. When we build the project with "mvn package", a jar is build. But the dependencies in the project are not included in the built jar. Is it possible to include the dependencies in the built jar?

What do you mean?

As far as I know, while the .war and .ear formats allow jars to be
nested inside jars, there is no such convention for a .jar file.

If you use a maven package type of "war" or "ear" in the pom, then
a .war or .ear does get created, and the dependencies are present.

Regards,
Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to include the dependencies in the built jar?

Posted by Thomas Chang <th...@yahoo.de>.
Thanks!
   
  **********************************
   
  Wendy Smoak wrote:
> On Jan 25, 2008 10:48 PM, Thomas Chang <th...@yahoo.de> wrote:
> 
>>   assumed we have a project with packaging jar. When we build the
 project with "mvn package", a jar is build. But the dependencies in the
 project are not included in the built jar. Is it possible to include the
 dependencies in the built jar?
> 
> Take a look at the assembly plugin.  There are a few standard
> assemblies... it sounds like jar-with-dependencies might be what you
> want.

Yup, Wendy's right. Here's a sample we've used:

<plugin>
         <artifactId>maven-assembly-plugin</artifactId>
         <configuration>
           <descriptorId>jar-with-dependencies</descriptorId>
           <finalName>the-jar-name</finalName>
           <outputDirectory>target/</outputDirectory>
           <workDirectory>target/assembly/work</workDirectory>
           <!-- include runtime deps -->
           <scope>runtime</scope>
           <archive>
             <manifest>
               <!-- a main class for using the jar from a shell -->
               <mainClass>gr.abiss.someproject.App</mainClass>
               <addClasspath>true</addClasspath>
             </manifest>
           </archive>
         </configuration>

         <executions>
           <execution>
             <id>make-assembly</id>
             <!-- this is used for inheritance merges -->
             <phase>package</phase>
             <!-- append to the packaging phase. -->
             <goals>
               <goal>attached</goal>
             </goals>
           </execution>
         </executions>
       </plugin>

hth,

Manos


       
---------------------------------
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit dem  neuen Yahoo! Mail. 

Re: How to include the dependencies in the built jar?

Posted by Manos Batsis <ma...@geekologue.com>.
Wendy Smoak wrote:
> On Jan 25, 2008 10:48 PM, Thomas Chang <th...@yahoo.de> wrote:
> 
>>   assumed we have a project with packaging jar. When we build the project with "mvn package", a jar is build. But the dependencies in the project are not included in the built jar. Is it possible to include the dependencies in the built jar?
> 
> Take a look at the assembly plugin.  There are a few standard
> assemblies... it sounds like jar-with-dependencies might be what you
> want.

Yup, Wendy's right. Here's a sample we've used:

<plugin>
         <artifactId>maven-assembly-plugin</artifactId>
         <configuration>
           <descriptorId>jar-with-dependencies</descriptorId>
           <finalName>the-jar-name</finalName>
           <outputDirectory>target/</outputDirectory>
           <workDirectory>target/assembly/work</workDirectory>
           <!-- include runtime deps -->
           <scope>runtime</scope>
           <archive>
             <manifest>
               <!-- a main class for using the jar from a shell -->
               <mainClass>gr.abiss.someproject.App</mainClass>
               <addClasspath>true</addClasspath>
             </manifest>
           </archive>
         </configuration>

         <executions>
           <execution>
             <id>make-assembly</id>
             <!-- this is used for inheritance merges -->
             <phase>package</phase>
             <!-- append to the packaging phase. -->
             <goals>
               <goal>attached</goal>
             </goals>
           </execution>
         </executions>
       </plugin>

hth,

Manos

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: A question about log4j and the location of "log4j.properties"

Posted by Thomas Chang <th...@yahoo.de>.
Hi Simon,
   
  thanks for the answer.
   
  And sorry, I will put my question by the mailinglist by logger.
   
  Regards
   
  Thomas
   
   
  ****************
   
  Hi Thomas,

On Sat, 2008-01-26 at 09:12 +0100, Thomas Chang wrote:
>   1.
>   Where should I save the "log4j.properties"? I think it should be
 under /webapp//WEB-INF?


This is really the wrong mailing list. See:
  http://logging.apache.org

However the answer is that the file needs to be in the *classpath*. The
WEB-INF directory of a webapp is not in the classpath.

The directory WEB-INF/classes is in the classpath.

>    
>   2.
>   How can the program find this file (I mean how to write in the
 java)?

Do you mean you want to dynamically create a configuration file at
runtime? Don't do that, it is a bad idea.

In most cases, there is no reason to set the logging configuration from
your program; just use a normal configuration file. That allows someone
to modify the configuration after installing the webapp.

However if you really must configure log4j from your code, then use the
log4j api to do this instead of writing a configuration file.

Please send all further questions to the log4j email list, NOT to this
list.

Regards,
Simon



       
---------------------------------
Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit dem  neuen Yahoo! Mail. 

Re: A question about log4j and the location of "log4j.properties"

Posted by simon <si...@chello.at>.
Hi Thomas,

On Sat, 2008-01-26 at 09:12 +0100, Thomas Chang wrote:
>   1.
>   Where should I save the "log4j.properties"? I think it should be under /webapp//WEB-INF?


This is really the wrong mailing list. See:
  http://logging.apache.org

However the answer is that the file needs to be in the *classpath*. The
WEB-INF directory of a webapp is not in the classpath.

The directory WEB-INF/classes is in the classpath.

>    
>   2.
>   How can the program find this file (I mean how to write in the java)?

Do you mean you want to dynamically create a configuration file at
runtime? Don't do that, it is a bad idea.

In most cases, there is no reason to set the logging configuration from
your program; just use a normal configuration file. That allows someone
to modify the configuration after installing the webapp.

However if you really must configure log4j from your code, then use the
log4j api to do this instead of writing a configuration file.

Please send all further questions to the log4j email list, NOT to this
list.

Regards,
Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


A question about log4j and the location of "log4j.properties"

Posted by Thomas Chang <th...@yahoo.de>.
Hi all,
   
  1.
  Where should I save the "log4j.properties"? I think it should be under /webapp//WEB-INF?
   
  2.
  How can the program find this file (I mean how to write in the java)?
   
  Regards
   
  Thomas

       
---------------------------------
Ihre erste Baustelle? Wissenswertes für Bastler und Hobby Handwerker. 

Re: How to include the dependencies in the built jar?

Posted by Wendy Smoak <ws...@gmail.com>.
On Jan 25, 2008 10:48 PM, Thomas Chang <th...@yahoo.de> wrote:

>   assumed we have a project with packaging jar. When we build the project with "mvn package", a jar is build. But the dependencies in the project are not included in the built jar. Is it possible to include the dependencies in the built jar?

Take a look at the assembly plugin.  There are a few standard
assemblies... it sounds like jar-with-dependencies might be what you
want.

If not, you can define your own descriptor to create what you need.

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org