properties-maven-plugin not working for goal write-project-properties

岁酱吖の 提交于 2020-06-27 16:18:44

问题


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] 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]

Here is my project structure

MyApplication
|src/main/java
|src/main/resources
|src/test/java
|src/test/resources
|lib          ////(no files here yet)
|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>

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.


回答1:


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>


来源:https://stackoverflow.com/questions/49931179/properties-maven-plugin-not-working-for-goal-write-project-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!