And*_*nie 17 maven maven-resources-plugin
我正在尝试使用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
Run Code Online (Sandbox Code Playgroud)
为了隔离这个问题,我创建了一个非常简单的pom.xml,几乎从http://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html中逐字复制,运行它,并得到了同样的错误.
我正在调用它
mvn resources:copy-resources
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?这是测试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>
Run Code Online (Sandbox Code Playgroud)
Man*_*ser 30
您遇到的主要问题是您直接使用调用插件目标
mvn resources:copy-resources
Run Code Online (Sandbox Code Playgroud)
这不一定会创建输出目录.而是调用正确的Maven生命周期阶段.
mvn process-resources
Run Code Online (Sandbox Code Playgroud)
有关生命周期阶段的完整列表,只需运行mvn命令即可.
通常,最好直接调用生命周期阶段而不是目标,因为它保证满足任何前提条件(例如,在要测试的类之前无法编译测试类).
Rag*_*ram 10
检查@bmargulies答案是否适合您.您可以参考这些示例.
无论如何,您无需使用<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27438 次 |
| 最近记录: |