properties-maven-plugin 不适用于目标 write-project-properties [英] properties-maven-plugin not working for goal write-project-properties

查看:79
本文介绍了properties-maven-plugin 不适用于目标 write-project-properties的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将属性值从 mvn 命令行导出到稍后我的 java 代码需要的文件.但我总是收到错误:

I need to export property values from mvn command line to a file which is needed for my java code later. But i always get the error:

[ERROR] 无法执行目标org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties项目 MyApplication 上的(默认 cli):参数outputFile"为目标org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties丢失或无效 -> [帮助 1] [错误]

[ERROR] Failed to execute goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties (default-cli) on project MyApplication: The parameters 'outputFile' for goal org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties are missing or invalid -> [Help 1] [ERROR]

这是我的项目结构

MyApplication
|src/main/java
|src/main/resources
|src/test/java
|src/test/resources
|lib          ////(no files here yet)
|pom.xml

我的 pom.xml 是:

And my pom.xml is:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0-alpha-2</version>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>write-project-properties</goal>
            </goals>
            <configuration><outputFile>${basedir}/lib/build.properties</outputFile>
            </configuration>
        </execution>
    </executions>
</plugin>

注意:我尝试在 lib 文件夹中手动创建空文件 build.properties ,甚至出现相同的错误.也尝试过插件版本 1.0.0.

Note: I tried by manually creating empty file build.properties in lib folder and even same error. Tried with plugin version 1.0.0 too.

推荐答案

OK,经过数小时的尝试不同的组合,(moved above/out of )in pom.xml,我现在看到创建的 lib/build.properties 文件.但是有人可以解释一下吗?

OK, after hours of trying different combinations, (moved <configuration> above/out of <executions>)in pom.xml, i see now lib/build.properties file created. But can someone explain this please?

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                 <version>1.0-alpha-2</version>
                <configuration>
                    <outputFile>${basedir}/lib/build.properties</outputFile>
                </configuration>
                <executions>
                    <execution>
                        <id>write-project-properties</id>
                        <goals>
                            <goal>write-project-properties</goal>
                        </goals>
                        <phase>test</phase>
                    </execution>
                </executions>
            </plugin>

这篇关于properties-maven-plugin 不适用于目标 write-project-properties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆