【发布时间】:2016-06-20 07:12:50
【问题描述】:
我目前正在处理特定的项目结构。
project\WEB-INF\lib中准备在目标文件夹中创建WAR的所有jar文件都应该复制到project\lib中
我们可以使用 maven-antrun 或 maven-resource 插件运行这样的脚本吗,这将在实际 WAR 被创建之前触发?
如果是,那么如何编程呢?文件不应该移动,应该复制。
编辑
使用以下 xml 找到解决方案并且工作正常,openfire 插件需要这种结构
但不幸的是,它仅在第二次执行 mvn package 时发生
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hpe.sis</groupId>
<artifactId>TestCopy</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>TestCopy Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-core -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19.1</version>
</dependency>
</dependencies>
<build>
<finalName>TestCopy</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/TestCopy/lib</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target/TestCopy/WEB-INF/lib</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
-
是的。 (你的问题是yes no answer?)说真的,检查maven.apache.org/plugins/maven-war-plugin我不明白你为什么需要移动jar文件。
-
您的设置存在严重问题。你不应该复制 JAR,你甚至不应该在你的项目中包含 JAR。您可以发布您的 POM 以及您到底想要做什么吗?你能提供更多背景信息吗?
-
我想用
maven-archetype-webapparchetype创建一个openfire插件
标签: maven openfire maven-antrun-plugin maven-resources-plugin