Search code examples
javamavensystem-properties

properties-maven-plugin does not set System propertey correctly


I am trying to set a system property in my java project with the maven plugin properties-maven-plugin. Here is my maven code:

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>set-system-properties</goal>
                        </goals>
                    </execution>
                        <configuration>
                                <properties>
                                    <property>
                                        <name>system.property.name</name>
                                        <value>${myvalue}</value>
                                    </property>
                                </properties>
                            </configuration>
                </executions>
            </plugin>
        ...

I can see that is executed in the maven run:

[INFO] --- properties-maven-plugin:1.0.0:set-system-properties (default) @ myproject ---
[INFO] Set 1 system property
[INFO] 

But in then it is not present at runtime. For example I can not get it with System.getProperty("system.property.name")

I do not understand why. Funny thing is: It worked at one time and then it didn't, without me changing anything.

I also get this strange Eclipse error at the execution-tag: "Plugin execution not covered by lifecycle configuration: ..." but I think this is an Eclipse problem?


Solution

  • The system property is set for the build. After the build is over, it is gone. If you start the built program later, it does not have that system property.