WestFarmer
WestFarmer

Reputation: 765

why setting environment variable in maven jetty plug-in not work?

I want to run my java web application with maven jetty plugin in eclipse, my application need a os environment variable COMDIR to run, I saw here, jetty 9.3.x already support set environment variable in pom configuration, but my configuration doesn't work, did I miss something?

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.4.11.v20180605</version>
    <dependencies>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.2.3</version>
        </dependency>
    </dependencies>
    <configuration>
        <!-- <war>${project.build.directory}/cwe-0.0.1-SNAPSHOT.war</war> -->
        <webAppSourceDirectory>${project.basedir}/WebContent</webAppSourceDirectory>
        <webAppConfig>
            <jettyEnvXml>${project.basedir}/profiles/1-dev/WebContent/WEB-INF/etc/jetty.env.xml</jettyEnvXml>
            <contextPath>/FDI</contextPath>
            <allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
            <descriptor>${project.basedir}/WebContent/WEB-INF/web.xml</descriptor>
        </webAppConfig>
        <dumpOnStart>true</dumpOnStart>
        <env>
            <COMDIR>/home/ggfan/1-install/comdir</COMDIR>
        </env>
        <systemProperties>
            <systemProperty>
                <name>APP_RUNTIME</name>
                <value>${project.basedir}/runtime</value>
            </systemProperty>
            <systemProperty>
                <name>COMDIR</name>
                <value>/home/ggfan/1-install/comdir</value>
            </systemProperty>
        </systemProperties>
    </configuration>
</plugin>

Upvotes: 1

Views: 567

Answers (1)

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49472

It does work, but only for forked JVMs.

In other words, only the jetty:run-forked goal will work with <env> settings.

Upvotes: 4

Related Questions