我正试图将一些jar文件从web-inf/lib文件夹复制到src/main/webapp/applet文件中,这些文件都是必需的归档小程序,以便jar文件出现在输出war文件中。
我希望这个复制操作需要在maven构建期间执行。我已经尝试了两种选择,一种是
maven war插件如下。
<webResources>
<resource>
<directory>src/main/webapp/WEB-INF/lib</directory>
<filtering>true</filtering>
<includes>
<include>**/*.jar</include>
</includes>
<targetPath>${basedir}/src/main/webapp/applet</targetPath>
</resource>
</webResources>
下面是构建的痕迹。
[INFO] --- maven-war-plugin:2.6:war (default-war) @ myapp ---
[INFO] Packaging webapp
[INFO] Assembling webapp [myapp] in [C:jboss_projectsmyappsrcmainwebapp]
[INFO] Processing war project
[INFO] Copying webapp webResources [C:jboss_projectsmyappsrc/main/webapp/WEB-INF/lib] to [C:jboss_projectsmyappsrcmainwebapp]
[INFO] Webapp assembled in [999 msecs]
[INFO] Building war: C:jboss_projectsmyapptargetmyapp.war
下一个尝试是使用下面的maven资源插件。
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/main/webapp/applet</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>src/main/webapp/WEB-INF/lib</directory>
<filtering>true</filtering>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
注意:在两次试用中,我都发现了在webapp中创建的小程序文件夹在更新项目时,但在生成过程中,该文件夹不是修改/创建。
任何建议都将不胜感激。请不要将其标记为重复。我查看的每个引用都有助于如何从源文件复制到web-inf/lib文件夹。不是这个。
wemu的建议奏效了。这就是它被配置为从本地repo获取依赖jar的方式。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin.version}</version>
<executions>
<execution>
<id>applet-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.xxx.yyy</groupId>
<artifactId>yyy</artifactId>
<version>1.0</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${basedir}/src/main/webapp/applet</outputDirectory>
<destFileName>yyy.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
检查下面的ant任务是否适合您?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>move-applet-jar-files</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="Copying jar files for applets">
<echo message="your jar file to be copied" />
<copy file="${source.dir}/abc.jar" tofile="${target.dir}/abc.jar" />
</target>
</configuration>
</execution>
</executions>
</plugin>