문제

Can any Maven plugins copy one or more dependencies (although not all of them) of a .war project into its warSourceDirectory (src/main/webapp)?

I'm working on a Java web-app that will display an applet. I'd like the war project to pick the latest version of some jars (the applet's dependencies) and stick them in /src/main/webapp/, to save me having to copy them around the place.

I've thought about shading and uber-jar-ing the applet itself, but I'd like to split the jars up to save users having to download one massive jar when only one of the bits in it has changed.

도움이 되었습니까?

해결책

Use for this dependency:copy from Maven Dependency Plugin.

Read also example page: Copying specific artifacts

Sample configuration

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
    <execution>
        <id>copy</id>
        <phase>compile</phase>
        <goals>
            <goal>copy</goal>
        </goals>
        <configuration>
            <artifactItems>
                <artifactItem>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>3.8.1</version>
                    <type>jar</type>
                    <overWrite>false</overWrite>
                    <destFileName>optional-new-name.jar</destFileName>
                </artifactItem>
            </artifactItems>
            <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/</outputDirectory>
            <overWriteReleases>false</overWriteReleases>
            <overWriteSnapshots>true</overWriteSnapshots>
        </configuration>
    </execution>
</executions>

Copying files into src/main/webapp is bad idea. Copy file directly into target folder.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top