在 webapp 文件夹中复制 jar 文件 maven 项目
Copying jar files maven project in webapp folder
我正在尝试将几个 jar 文件从 web-inf/lib 文件夹复制到 src/main/webapp/applet 文件夹,这些都是所需
小程序存档,以便 jar 文件出现在输出 war 文件中。
我希望这个复制操作需要在 maven 期间执行 build.Already 我尝试了两种选择,一种是
maven-war-plugin 在下面。
<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_projects\myapp\src\main\webapp]
[INFO] Processing war project
[INFO] Copying webapp webResources [C:\jboss_projects\myapp\src/main/webapp/WEB-INF/lib] to [C:\jboss_projects\myapp\src\main\webapp]
[INFO] Webapp assembled in [999 msecs]
[INFO] Building war: C:\jboss_projects\myapp\target\myapp.war
下一次尝试使用下面的 maven-resources-plugin。
<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>
Note: in both trials I found the applet folder created inside webapp
while updating project but during build that folder is not
modified/created.
任何建议都会很多 appreciated.Please 不要将此标记为重复我查看的每个参考资料都有助于如何从源复制到 web-inf/lib 文件夹。
不是这个。
检查以下蚂蚁任务是否适合您?
<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>
wemu 建议 worked.This 是如何配置从本地 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>
我正在尝试将几个 jar 文件从 web-inf/lib 文件夹复制到 src/main/webapp/applet 文件夹,这些都是所需 小程序存档,以便 jar 文件出现在输出 war 文件中。
我希望这个复制操作需要在 maven 期间执行 build.Already 我尝试了两种选择,一种是
maven-war-plugin 在下面。
<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_projects\myapp\src\main\webapp]
[INFO] Processing war project
[INFO] Copying webapp webResources [C:\jboss_projects\myapp\src/main/webapp/WEB-INF/lib] to [C:\jboss_projects\myapp\src\main\webapp]
[INFO] Webapp assembled in [999 msecs]
[INFO] Building war: C:\jboss_projects\myapp\target\myapp.war
下一次尝试使用下面的 maven-resources-plugin。
<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>
Note: in both trials I found the applet folder created inside webapp while updating project but during build that folder is not modified/created.
任何建议都会很多 appreciated.Please 不要将此标记为重复我查看的每个参考资料都有助于如何从源复制到 web-inf/lib 文件夹。 不是这个。
检查以下蚂蚁任务是否适合您?
<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>
wemu 建议 worked.This 是如何配置从本地 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>