0

We've specified a bunch of system properties in our maven compiler plugin definition within pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <encoding>${project.build.sourceEncoding}</encoding>

                <systemProperties>
                    <systemProperty>
                        <key>aKey</key>
                        <value>aValue</value>
                    </systemProperty>
                </systemProperties>
             <!-- ....etcetera.... -->

These are automatically loaded when the jar is executed

How does Maven create this auto-load behaviour for system properties? I'd like to understand the practical implementation of this behaviour.

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
KomodoDave
  • 7,239
  • 10
  • 60
  • 92

1 Answers1

0

This is not behaviour I would expect (unless I am misunderstanding you). Compile-time system properties should not be persisted at runtime.

I created a basic maven project that just prints out the system properties and it did not contain the system property specified in plugin configuration.

System.getProperties().getProperty("aKey") returned null at runtime even with compiler plugin configured the same as yours.

Any other plugins running that might have an effect? How are you accessing the system properties?

Wilhelm Kleu
  • 10,821
  • 4
  • 36
  • 48
  • We're fairly sure it does persist because we have a project with a property specified as per my example and the code sees it as set to `true` upon execution of the jar. Searching the project - indeed grepping it - reveals no additional instances of the keyword. The environment we deploy to does not have it defined in any loaded project files. – KomodoDave Feb 02 '12 at 14:27