maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jorge Infante Osorio" <jorg...@uci.cu>
Subject RE: Include maven dependencies inside jar file
Date Wed, 12 Jun 2013 17:37:35 GMT
Hi Anders.

I put this inside my pom.xml


<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
 
<outputDirectory>${project.build.directory}/classes</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <!--classpathPrefix></classpathPrefix-->
                        <mainClass>test.org.Cliente</mainClass>
                    </manifest>
            <manifestEntries>
                <Class-Path>/</Class-Path>
            </manifestEntries>					
                </archive>
            </configuration>
        </plugin>		

Now I see all the dependencies include inside my execute jar like Eclipse do
it, but when I try it I see this error:

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/axis2/AxisFault
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.AxisFault
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 6 more


Any idea?

Saludos,
Ing. Jorge Infante Osorio.
CDAE.
Fac. 5.
UCI.
“En un mundo perfecto las pizzas serían una comida saludable, las laptops se
cargarían desde una fuente de corriente inalámbrica y todos los JAR serían
bundles de OSGI ”

-----Mensaje original-----
De: anders.g.hammar@gmail.com [mailto:anders.g.hammar@gmail.com] En nombre
de Anders Hammar
Enviado el: miércoles, 12 de junio de 2013 1:51
Para: Maven Users List
Asunto: Re: Include maven dependencies inside jar file

If you want the deps extracted, you need to do a combination of [1] and [2].

If you want the dep jars included in the final jar, I think you best option
is to use the maven-assembly-plugin [3]. You also need to make the final jar
executable in this case.

[1]
http://maven.apache.org/plugins/maven-shade-plugin/examples/includes-exclude
s.html
[2]
http://maven.apache.org/plugins/maven-shade-plugin/examples/executable-jar.h
tml
[3] http://maven.apache.org/plugins/maven-assembly-plugin/

/Anders


On Wed, Jun 12, 2013 at 5:35 AM, Jorge Infante Osorio <jorgeio@uci.cu>wrote:

> Hi all.
>
> I´m newbie in maven.
>
> I have a Maven project and I need to build a jar file with the maven 
> dependencies inside, like I do with export jar as runnable in Eclipse 
> to execute the functionality from the command line.
>
> What plugin can I use for this with what config?
>
> Thanks.
>
> Saludos,
> Ing. Jorge Infante Osorio.
> CDAE.
> Fac. 5.
> UCI.
> “En un mundo perfecto las pizzas serían una comida saludable, las 
> laptops se cargarían desde una fuente de corriente inalámbrica y todos 
> los JAR serían bundles de OSGI ”
>
>
> http://www.uci.cu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

http://www.uci.cu


http://www.uci.cu

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


Mime
View raw message