I don't think that you can embed the dependent jars with the jar. IIRC the
spec doesn't allow that. But you can shade the classes from the dependent
jars to make one uber-jar.
There are lots of examples of making executable jars with Maven on the
Internet. There are also lots of examples on how to shade.

/Anders
On Mon, Mar 7, 2011 at 11:15, Ankit Jain <mr.ankitja...@gmail.com> wrote:

> Hi
>
> I am sorry for attaching a wrong pom.
>
> I will try to redefine my problem.
>
> I have a small project which has a main method in class file
> CheckResources.
>
>
> I have some more classes which are dependent on external jar. I need to
> make
> a executable jar file for this program which contains the dependent jars
> and
> main class file.
>
> when i execute the executable jar with the help of the following pom.... it
> runs the main method but fails to load jar files.
>
>
>
>    <build>
>        <directory>target</directory>
>        <outputDirectory>target/classes</outputDirectory>
>        <finalName>testMaven</finalName>
>        <testOutputDirectory>target/test-classes</testOutputDirectory>
>        <resources>
>            <resource>
>                 <directory>WSScheduler</directory>
>                 <excludes>
>                    <exclude>**/*.java</exclude>
>                </excludes>
>            </resource>
>        </resources>
>         <sourceDirectory>WSScheduler</sourceDirectory>
>        <scriptSourceDirectory>WSScheduler</scriptSourceDirectory>
>         <plugins>
>            <plugin>
>                <artifactId>maven-compiler-plugin</artifactId>
>                <version>2.3.1</version>
>                <configuration>
>                    <source>1.5</source>
>                    <target>1.5</target>
>                </configuration>
>            </plugin>
>            <plugin>
>                 <artifactId>maven-jar-plugin</artifactId>
>                <version>2.2</version>
>                 <configuration>
>                    <archive>
>                        <manifest>
>                            <addClasspath>true</addClasspath>
>
> <classpathPrefix>WebContent/WEB-INF/lib/</classpathPrefix>
>
> <mainClass>CheckResources</mainClass>
>                        </manifest>
>                    </archive>
>                </configuration>
>            </plugin>
>            <plugin>
>                <groupId>org.apache.maven.plugins</groupId>
>                <artifactId>maven-surefire-report-plugin</artifactId>
>                <version>2.4.2</version>
>            </plugin>
>
>        </plugins>
>    </build>
>
>    <dependencies>
>        <!-- Depending on your requirements you may need more or fewer
> modules from cxf -->
>        <dependency>
>            <groupId>axis</groupId>
>            <artifactId>axis</artifactId>
>            <version>1.4</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>org.codehaus.castor</groupId>
>            <artifactId>castor</artifactId>
>            <version>1.2</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>com_lgc_ph_common</groupId>
>            <artifactId>com_lgc_ph_common</artifactId>
>            <version>1.0</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>com_lgc_ph_client</groupId>
>            <artifactId>com_lgc_ph_client</artifactId>
>            <version>1.0</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>commons-discovery</groupId>
>            <artifactId>commons-discovery</artifactId>
>            <version>0.2</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>commons-logging</groupId>
>            <artifactId>commons-logging</artifactId>
>            <version>1.1</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>jaxrpc</groupId>
>            <artifactId>jaxrpc</artifactId>
>            <version>1.1</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>log4j</groupId>
>            <artifactId>log4j</artifactId>
>            <version>1.2.15</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>log4j-props</groupId>
>            <artifactId>log4j-props</artifactId>
>            <version>1.1</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>saaj-api</groupId>
>            <artifactId>saaj-api</artifactId>
>            <version>1.3</version>
>            <type>jar</type>
>        </dependency>
>        <dependency>
>            <groupId>wsdl4j</groupId>
>            <artifactId>wsdl4j</artifactId>
>            <version>1.5.1</version>
>             <type>jar</type>
>        </dependency>
>    </dependencies>
>
>
> On Mon, Mar 7, 2011 at 2:45 PM, Anders Hammar <and...@hammar.net> wrote:
>
> > I don't understand what the problem is?
> >
> > Also, it looks like your trying to create a war artifact in a jar
> project.
> > You should split your project into a multi-module build, where you have
> on
> > module creating the jar and one module building the war. There are
> examples
> > of this on the Internet.
> >
> > /Anders
> > On Mon, Mar 7, 2011 at 09:59, Ankit Jain <mr.ankitja...@gmail.com>
> wrote:
> >
> > > Hi
> > >
> > > I am facing problem while creating jar for my project.
> > >
> > > I have added the dependencies. it adds all the jar file path in my
> class
> > > path in manifest file. dependency scope is set as "compile"
> > >
> > > <project xmlns="http://maven.apache.org/POM/4.0.0";
> > >    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > >    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > > http://maven.apache.org/maven-v4_0_0.xsd";>
> > >    <modelVersion>4.0.0</modelVersion>
> > >    <groupId>org.apache.maven</groupId>
> > >    <artifactId>Scheduler</artifactId>
> > >    <packaging>jar</packaging>
> > >    <name>Scheduler</name>
> > >    <url>http://Dream.release.epecds.com</url>
> > >    <description>Scheduler.</description>
> > >    <version>1.0</version>
> > >    <build>
> > >        <directory>target</directory>
> > >        <outputDirectory>target/classes</outputDirectory>
> > >        <finalName>testMaven</finalName>
> > >        <testOutputDirectory>target/test-classes</testOutputDirectory>
> > >        <resources>
> > >            <resource>
> > >                <directory>WSScheduler/src</directory>
> > >                <excludes>
> > >                    <exclude>**/*.java</exclude>
> > >                </excludes>
> > >            </resource>
> > >        </resources>
> > >        <sourceDirectory>WSScheduler/src</sourceDirectory>
> > >        <scriptSourceDirectory>WSScheduler/src</scriptSourceDirectory>
> > >        <plugins>
> > >            <plugin>
> > >                <artifactId>maven-compiler-plugin</artifactId>
> > >                <version>2.3.1</version>
> > >                <configuration>
> > >                    <source>1.5</source>
> > >                    <target>1.5</target>
> > >                </configuration>
> > >            </plugin>
> > >            <plugin>
> > >                <artifactId>maven-war-plugin</artifactId>
> > >                <configuration>
> > >                    <archive>
> > >                        <manifest>
> > >                            <addClasspath>true</addClasspath>
> > >
> > > <classpathLayoutType>custom</classpathLayoutType>
> > >
> > >
> > >
> >
> <customClasspathLayout>WEB-INF/lib/$${artifact.groupIdPath}/$${artifact.artifactId}-$${artifact.version}$${dashClassifier?}.$${artifact.extension}</customClasspathLayout>
> > >                            <mainClass>CheckResources</mainClass>
> > >                        </manifest>
> > >                    </archive>
> > >                </configuration>
> > >            </plugin>
> > >            <plugin>
> > >                <groupId>org.apache.maven.plugins</groupId>
> > >                <artifactId>maven-surefire-report-plugin</artifactId>
> > >                <version>2.4.2</version>
> > >            </plugin>
> > >
> > >        </plugins>
> > >    </build>
> > >
> > >    <dependencies>
> > >        <!-- Depending on your requirements you may need more or fewer
> > > modules from cxf -->
> > >        <dependency>
> > >            <groupId>axis</groupId>
> > >            <artifactId>axis</artifactId>
> > >            <version>1.4</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>org.codehaus.castor</groupId>
> > >            <artifactId>castor</artifactId>
> > >            <version>1.2</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>com_lgc_ph_common</groupId>
> > >            <artifactId>com_lgc_ph_common</artifactId>
> > >            <version>1.0</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>com_lgc_ph_client</groupId>
> > >            <artifactId>com_lgc_ph_client</artifactId>
> > >            <version>1.0</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>commons-discovery</groupId>
> > >            <artifactId>commons-discovery</artifactId>
> > >            <version>0.2</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>commons-logging</groupId>
> > >            <artifactId>commons-logging</artifactId>
> > >            <version>1.1</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>jaxrpc</groupId>
> > >            <artifactId>jaxrpc</artifactId>
> > >            <version>1.1</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>log4j</groupId>
> > >            <artifactId>log4j</artifactId>
> > >            <version>1.2.15</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>log4j-props</groupId>
> > >            <artifactId>log4j-props</artifactId>
> > >            <version>1.1</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>saaj-api</groupId>
> > >            <artifactId>saaj-api</artifactId>
> > >            <version>1.3</version>
> > >            <type>jar</type>
> > >        </dependency>
> > >        <dependency>
> > >            <groupId>wsdl4j</groupId>
> > >            <artifactId>wsdl4j</artifactId>
> > >            <version>1.5.1</version>
> > >             <type>jar</type>
> > >        </dependency>
> > >    </dependencies>
> > > </project>
> > >
> > > what could be wrong with this... my jars reside in Web-INF/lib
> > >
> > > Thanks
> > >
> > > Ankit Jain
> > >
> >
>

Reply via email to