我尝试使用maven-resources-plugin通过copy-resources目标进行一些过滤,但遇到了以下错误:
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:copy-resources (default-cli) on project bar: The parameters 'resources', 'outputDirectory' for goal org.apache.maven.plugins:maven-resources-plugin:2.5:copy-resources are missing or invalid为了隔离问题,我创建了一个非常简单的pom.xml,几乎逐字地从http://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html复制,运行它,并得到相同的错误。
我用下面的命令调用它
mvn resources:copy-resources有什么想法吗?这是测试pom.xml。
<?xml version="1.0" encoding="UTF-8"?>
<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>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/extra-resources</outputDirectory>
<resources>
<resource>
<directory>src/non-packaged-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
发布于 2012-06-09 06:10:37
您遇到的主要问题是您使用以下命令直接调用插件目标
mvn resources:copy-resources这并不一定要创建输出目录。相反,调用正确的Maven生命周期阶段。
mvn process-resources要获得生命周期阶段的完整列表,只需不带任何内容运行mvn命令即可。
一般来说,调用生命周期阶段几乎总是比直接调用目标更好,因为它保证满足任何先决条件(例如,不能在要测试的类之前编译测试类)。
发布于 2012-06-07 12:28:37
检查@bmargulies答案是否适合您。你可以参考these examples。
在任何情况下,您都不需要使用<pluginManagement>来实现此目的。多模块场景下使用<pluginManagement>,便于继承plugin配置。
您需要将configuration移出execution元素。下面的代码片段可以正常工作。
<?xml version="1.0" encoding="UTF-8"?>
<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>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<outputDirectory>${basedir}/target/extra-resources</outputDirectory>
<resources>
<resource>
<directory>src/non-packaged-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>发布于 2015-05-12 23:25:37
只需删除执行及其配置即可。通常,您可能希望在<build> > <resources>中定义资源,而不是直接在<build> > <testResources> (参见http://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html)中定义资源,而不是在插件配置中使用默认的生命周期process-(test-)resources,它由copy-(test-)resources.自动挂接。是的,这在他们的页面上是一个糟糕的例子!
https://stackoverflow.com/questions/10923944
复制相似问题