Domanda

I am using maven-jar-plugin to generate a sources jar.

I have the following folder structure:

folder/foo/baz/A.java
folder/bar/baz/B.java

I want the sources jar to contain the following:

baz/A.java
baz/B.java

I am using the following configuration:

<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.4</version>
        <executions>
            <execution>
                <phase>generate-resources</phase>
                <goals>
                    <goal>jar</goal>
                </goals>
                <configuration>
                    <classesDirectory>folder</classesDirectory>
                    <includes>
                        <include>foo/**</include>
                        <include>bar/**</include>
                    </includes>
                    <finalName>sources</finalName>
                </configuration>
            </execution>
        </executions>
</plugin>

But this creates the jar like this:

folder/foo/baz/A.java
folder/bar/baz/B.java

How can i modify the code to get my desired structure in the jar?

È stato utile?

Soluzione

I could not solve this with the maven-jar-plugin, i had to use maven-resources-plugin, too:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.3</version>
    <executions>
        <execution>
            <phase>generate-resources</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/sources/</outputDirectory>
                <resources>
                    <resource>
                        <directory>folder/foo/</directory>
                    </resource>
                    <resource>
                        <directory>folder/bar/</directory>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <phase>generate-resources</phase>
            <goals>
                <goal>jar</goal>
            </goals>
            <configuration>
                <classesDirectory>${project.build.directory}/sources</classesDirectory>
                <includes>
                    <include>**/*</include>
                </includes>
                <finalName>sources</finalName>
            </configuration>
        </execution>
    </executions>
</plugin>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top