Maven: add resource from jar to WEB-INF during bui

2020-03-31 03:37发布

问题:

I want to add resource from dependency jar, which resides in myjar.jar:META_INF/public-resource/myresource.sk to my webapp/WEB-INF/myfolder during mvn package goal. Does anybody can give advice, how to do this?

回答1:

If myjar is in mvn repository, like it should be, something like

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>package</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                       <artifactItems>
                         <artifactItem>
                            <groupId>mygroupid</groupId>
                            <artifactId>myjar</artifactId>
                            <outputDirectory>src/main/webapp/WEB-INF/myfolder</outputDirectory>
                            <includes>META_INF/public-resource/myresource.sk</includes>
                          </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
 </build>


标签: maven-3