Java: ¿Dónde almacena Maven las propiedades del sistema establecidas en pom.xml dentro de un jar compilado?

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.

preguntado el 02 de febrero de 12 a las 11:02

1 Respuestas

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") devuelto 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?

Respondido 02 Feb 12, 18:02

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

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.