Here is my pom.xml
<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>
<url>http://maven.apache.org</url>
<name>SomeProject</name>
<groupId>com.test.te</groupId>
<artifactId>testjar</artifactId>
<version>1.1.6</version>
<packaging>jar</packaging>
<dependencies>
....
....
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.conf</include>
<include>**/*.java</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<id>drive</id>
<goals><goal>jar</goal></goals>
<phase>install</phase>
<configuration>
<finalName>driver</finalName>
<includes>
<include>com/test/te/p1/*.java<include>
<include>com/test/te/p1/*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Here is how I am executing this
mvn clean install
Here is the build output's last few lines.
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: /home/mycp/workspace/SomeProject/target/testjar-1.1.6.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing /home/mycp/workspace/SomeProject/target/testjar-1.1.6.jar to /home/mycp/.m2/repository/com/test/te/testjar/1.1.6/testjar-1.1.6.jar
[INFO] [jar:jar {execution: driver}]
[INFO] Building jar: /home/mycp/workspace/TestProject/target/driver.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11 seconds
[INFO] Finished at: Wed Oct 28 17:27:10 IST 2015
[INFO] Final Memory: 129M/888M
[INFO] ------------------------------------------------------------------------
- Why the 2nd jar (driver.jar) is not versioned (driver-1.1.6.jar) ?
- Why the 2nd jar not installed in local repo?
How to do this?
My requirement is create two jars testjar-${project.version}.jar driver-${project.version}.jar and install those two in two different artifact
/home/mycp/.m2/repossitory/com/test/te/testjar/${project-version}/testjar-${project.version}.jar
/home/mycp/.m2/repossitory/com/test/te/driver/${project-version}/driver-${project.version}.jar