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

Reply via email to