You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by mxc <ma...@jumpingbean.co.za> on 2007/01/03 23:04:51 UTC

Packaging application with dependent jars?

Hi all,

Is there a goal that will allow me to create a jar with all the dependencies
so that I can just send it to people and give them a command line to run
without them having to set their classpath?

ie. java -jar myjar.jar?


Thanks

http://www.jumpingbean.co.za/java Jumping Bean  
-- 
View this message in context: http://www.nabble.com/Packaging-application-with-dependent-jars--tf2916305s177.html#a8149683
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: Packaging application with dependent jars?

Posted by mxc <ma...@jumpingbean.co.za>.
Hi all,

Well this is what I have worked out.

1) Matthew's XML snippet runs the assembly as part of the build packaging
process. To run it using the mvn assembly:assembly command you need to edit
the pom.xml and add a configuration section.

2) You can use the default descriptor "targets" such as
bin/jar-with-dependencies etc or you can write your own assembly.xml files
and refer to them from your pom.xml. I.e under the plugin definition you
include

<configuration>
  <descriptors>
          <descriptor>yourassembly.xml </descriptor>
  </descriptors>
</configuration>

I copied the default descriptor for the jar-with-dependencies "target" and
edited my pom.xml appropriately. When I run mvn assembly:assembly I get the
error


[INFO]
------------------------------------------------------------------------
[INFO] An invalid artifact was detected.

This artifact might be in your project's POM, or it might have been included
transitively during the resolution process. Here is the information we do
have for this artifact:

    o GroupID:     za.co.jumpingbean
    o ArtifactID:  appgen
    o Version:     1.0-SNAPSHOT
    o Type:        jar

[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.artifact.InvalidArtifactRTException: For artifact
{za.co.jumpingbean:appgen:1.0-SNAPSHOT:jar}: An attached artifact must have
a different ID than its corresponding main artifact.



-- 
View this message in context: http://www.nabble.com/Packaging-application-with-dependent-jars--tf2916305s177.html#a8176705
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: Packaging application with dependent jars?

Posted by mxc <ma...@jumpingbean.co.za>.
Hi Mathew,

Thanks for the help. I have added the above XML to my pom.xml. When I run
the command




> [INFO] Unable to find descriptor:
> /home/mark/workspace/appgen/src/decriptor.xml (No such file or directory)
> 

-- 
View this message in context: http://www.nabble.com/Packaging-application-with-dependent-jars--tf2916305s177.html#a8173276
Sent from the Maven - Users mailing list archive at Nabble.com.

Re: Packaging application with dependent jars?

Posted by Tomasz Pik <to...@gmail.com>.
On 1/4/07, matthewadams <ma...@yahoo.com> wrote:
>
> I use the assembly plugin to create a jar that contains the contents of all
> jars that the application depends on.  From my pom:

[...]

> <descriptorRef>jar-with-dependencies</descriptorRef>

[...]

> Many things can be customized.  See the doc on the assembly plug in
> (http://maven.apache.org/plugins/maven-assembly-plugin,
> http://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html).

Do you know, how to configure name of executable class so
java -jar xxx-jar-with-dependencies.jar will work?
I was checking if 'mainClass' element of maven-jar-plugin will be
propagated to xxx-jar-with-dependencies.jar' but MANIFEST in
result jar is do not contain anything from project, only three lines:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: 1.5.0_07-b03 (Sun Microsystems Inc.)

Regards,
Tomek

>
> HTH,
> Matthew
>
>
> mxc wrote:
> >
> > Hi all,
> >
> > Is there a goal that will allow me to create a jar with all the
> > dependencies so that I can just send it to people and give them a command
> > line to run without them having to set their classpath?
> >
> > ie. java -jar myjar.jar?
> >
> >
> > Thanks
> >
> >  http://www.jumpingbean.co.za/java Jumping Bean
> >
>
> --
> View this message in context: http://www.nabble.com/Packaging-application-with-dependent-jars--tf2916305s177.html#a8154206
> 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


Re: Packaging application with dependent jars?

Posted by matthewadams <ma...@yahoo.com>.
I use the assembly plugin to create a jar that contains the contents of all
jars that the application depends on.  From my pom:
            ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <descriptorRefs>
                               
<descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                        </configuration>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...

Many things can be customized.  See the doc on the assembly plug in
(http://maven.apache.org/plugins/maven-assembly-plugin,
http://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html).

HTH,
Matthew


mxc wrote:
> 
> Hi all,
> 
> Is there a goal that will allow me to create a jar with all the
> dependencies so that I can just send it to people and give them a command
> line to run without them having to set their classpath?
> 
> ie. java -jar myjar.jar?
> 
> 
> Thanks
> 
>  http://www.jumpingbean.co.za/java Jumping Bean  
> 

-- 
View this message in context: http://www.nabble.com/Packaging-application-with-dependent-jars--tf2916305s177.html#a8154206
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