pagurix
pagurix

Reputation: 1926

How to move (or copy) a war's jar to another war's folder?

I have maven prj with 2 modules: a JAR and a WAR that depends on the JAR.

after the MAVEN INSTALL I have into a WAR the classic WEB-INF/lib folder that contains all the jar dependencies(including the first module's JAR).

I need the first module's JAR is moved to another folder, for example WEB-INF/resources. as I can?

I was able to move the jar but only within the TARGET, the WAR remains the same. I used the following plugin:

...
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.9</version>
            <executions>
                <execution>
                    <id>copy-installed</id>
                    <phase>install</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>groupId</groupId>
                                <artifactId>artifactId</artifactId>
                                <version>1.0</version>
                                <type>jar</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>${project.build.directory}/.../WEB-INF/services</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                        <outputDirectory>${project.build.directory}/.../WEB-INF/services</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>    

Upvotes: 0

Views: 261

Answers (2)

Multisync
Multisync

Reputation: 8797

Maybe this will help:

<project.warSourceDirectory>${basedir}/src/main/webapp</project.warSourceDirectory>
...

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.9</version>
    <executions>
        <execution>
            <id>copy-installed</id>
            <phase>install</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>groupId</groupId>
                        <artifactId>artifactId</artifactId>
                        <version>1.0</version>
                        <type>jar</type>
                        <overWrite>false</overWrite>
                        <outputDirectory>${project.warSourceDirectory}/WEB-INF/services</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

Upvotes: 0

pagurix
pagurix

Reputation: 1926

For now, I surrendered.

I could not move this JAR from WEB-INF/lib to WEB-INF/services of the EAR. The workaround I used is to say MODULE1 to copy its JAR in the WEB-INF/services of MODULE2. Consequently, the JAR will be present in the WEB-INF/services of the sources folders, in the WEB-INF/services of the TARGET folders and in the end in the WEB-INF/services of the EAR.

i used:

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <outputDirectory>..MOSULE1/src/main/webbapp/WEB-INF/services</outputDirectory>
            </configuration>
        </plugin>
    </plugins>

into MODULE1 pom.

I had to give up to make module1 independent module2 ;(

i hope i will found a clean solution..

Upvotes: 0

Related Questions