I am using maven for my development purposes. I have a requirement that I want to include some of the third party jar in my project jar and exclude others specified in pom.xml file. Below is my pom.xml file.
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ckdm</groupId>
<artifactId>Exporter</artifactId>
<version>atlas2.1</version>
<packaging>jar</packaging>
<name>Exporter</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<aspectj.version>1.6.10</aspectj.version>
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.ckdm</groupId>
<artifactId>CubeCreator</artifactId>
<version>atlas2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.guavus</groupId>
<artifactId>ConcurrentFlows</artifactId>
<version>atlas2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ps</groupId>
<artifactId>thriftGenerated</artifactId>
<version>atlas2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>apache</groupId>
<artifactId>libthrift</artifactId>
<version>0.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.203.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>1.7.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
</project>
I read somewhere that specifying scope as provided doesn’t include the jar’s in the project jar. Where am I getting wrong, it is not able to include any of the jars?
as per your above comments, I assume you have one jar which has your main class in it.
Add
MANIFEST.MFfile in you project. Its contents should be like below:YourMainJar.jaris the file in which you have your main class, third party jars needs to be on the same location where yourYourMainJar.jaris placed.When you double click your
YourMainJar.jar, it will automatically run and also pick your third party jars from the same location.Note: You need to include this
MANIFEST.MFwhen you are packing your project as jar.