You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Laurent Martelli <ma...@gmail.com> on 2010/07/27 19:31:16 UTC
How to put classes in a directory of your choice in a jar
Hi,
I was asking myself a few days ago how could I package java classes in a
directory of my choice in a jar package. Yes, I know, this is a strange
idea.
But anyway, since I found a solution, I would like to share it with you.
The idea is to use a directory in target/ where you put the classes and the
resources where you want:
<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>
[...]
<build>
<!-- classes will be in classes/-->
<outputDirectory>target/package/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
<configuration>
<outputDirectory>target/package</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<classesDirectory>target/package</classesDirectory>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<!-- resources will go in bla/-->
<directory>src/main/resources</directory>
<targetPath>bla</targetPath>
</resource>
</resources>
</build>
</project>
Cheers,
Laurent
Re: How to put classes in a directory of your choice in a jar
Posted by amitmosesalbert <am...@hotmail.com>.
Laurent, This was very useful. Can you help me out in placing classes to a
directory same as parent under target/classes
Say i have
src/main/java/com/company/app/a.java to be placed under
target/classes/com/company/app/a.class
I can work out for anything under app but what if i have the below
src/main/java/newfolder/company/java/b.java
When i try to include the former source path it throws an error duplicate
tag <build>.
Can you please help me out.
I am not build and release engineer and new to maven.
--
View this message in context: http://maven.40175.n5.nabble.com/How-to-put-classes-in-a-directory-of-your-choice-in-a-jar-tp2256100p2842745.html
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