Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-1525

Allow environment variables to be referenced in pom.xml, settings.xml, etc.

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.1
    • Component/s: None
    • Labels:
      None
    • Environment:
      Red Hat Linux, Java 5, Maven 2

      Description

      Maven should allow environment variables to be referenced; similar to Java System properties. Ant allows this to be done using the following syntax:

      <property environment="env"/>
      ${env.CATALINA_BASE}

      where CATALINA_BASE has been defined like:

      export CATALINA_BASE=$HOME/tomcat

      In Maven, an example use for signing jars might be:

      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-jar-plugin</artifactId>
      <executions>
      <execution>
      <goals>
      <goal>sign</goal>
      </goals>
      </execution>
      </executions>
      <configuration>
      <keystore>${env.KEYSTORE_FILE}</keystore>
      <storepass>${env.KEYSTORE_PASS}</storepass>
      <alias>${env.KEYSTORE_ALIAS}</alias>
      <jarPath>${project.build.directory}/${project.build.finalName}.jar</jarPath>
      </configuration>
      </plugin>

      where KEYSTORE_FILE, KEYSTORE_PASS, and KEYSTORE_ALIAS are environment variables.

      It would also be very useful to have environment variables available when defining filter properties files. For instance:

      1. application.properties
        deploy.dir=${env.CATALINA_BASE}/webapps

      Environment variables can be referenced in Java like:

      Map<String, String> environmentVariables = java.lang.System.getenv();

        Attachments

        1. MNG-1525-maven-project.patch
          2 kB
          Edwin Punzalan

          Issue Links

            Activity

              People

              • Assignee:
                jdcasey John Dennis Casey
                Reporter:
                richard.allen Richard Allen
              • Votes:
                2 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: