Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 310747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:51:42+00:00 2026-05-12T07:51:42+00:00

Is it possible to set environmental variables in a build profile as opposed to

  • 0

Is it possible to set environmental variables in a build profile as opposed to setting them in the command line?

For instance, I want to enable the debugger when I’m using my test environment (-Denv=test).

I want maven to do this:

export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"

This way, I can quickly attach a debugger without having to type the same repeated line over and over.

I don’t believe the helps me in this case:

<plugin>
...
<!--    Automatically enable the debugger when running Jetty    -->
                    <argLine>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n</argLine>
                </configuration>
...
</plugin>

Walter

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:51:43+00:00Added an answer on May 12, 2026 at 7:51 am

    In recent versions of Maven you can activate the debugger by running mvnDebug rather than mvn, the mvnDebug bat/sh file sets MVN__DEBUG_OPTS and passes them to the java.exe. The values passed are:

    set MAVEN_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
    

    If that isn’t sufficient, this may work (note I’ve not yet tested this, I’ll update once I have). Maven reads properties prefixed with “env.” from the environment, you may be able to set environment variables by prefixing with the same. i.e.:

    <profile>
      <id>dev</id>
      <properties>
        <env.MAVEN_OPTS>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000<env.MAVEN_OPTS>
      </properties>
    </profile>
    

    Update: The surefire plugin allows you to specify system properties to be used during test execution. The configuration is as follows:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.4.2</version>
      <configuration>
        <systemProperties>
          <property>
            <name>propertyName</name>
            <value>propertyValue</value>
          </property>
        </systemProperties>
      </configuration>
    </plugin>
    

    If none of those work for you, it is possible to write a small plugin configured in your profile that binds to the initialize phase and sets your variables. The plugin would have configuration like this:

    <plugin>
      <groupId>name.seller.rich</groupId>
      <artifactId>maven-environment-plugin</artifactId>
      <version>0.0.1</version>
      <executions>
        <execution>
          <id>set-properties</id>
          <phase>initialize</phase>
          <goals>
            <goal>set-properties</goal>
          </goals>
        </execution>
      </executions>                              
      <configuration>
        <properties>
          <env.MAVEN_OPTS>-Xdebug -Xnoagent -Djava.compiler=NONE 
              -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000<env.MAVEN_OPTS>
        </properties>
      </configuration>
    </plugin>
    

    during execution the plugin would set each passed property using System.setProperty(). If the first two aren’t suitable or don’t work this should address your issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are class variables a good way to set the context for a class instance
I want to set up a parameterized build in Hudson that only takes one
I am setting some permanent environment variables via a batch file. Is it possible
Possible Duplicate: How do I set environment variables from Java? I'm trying to set
In Java SE it is possible set the cause of an exception using initCause
Is possible to set an image as an iPhone application unique icon in code
Is it possible to set multiple properties at a time for an object in
Is it possible to set authorization on a specific field in MVC 3? My
Is it possible to set a timeout when loading an xml directly from a
Is it possible to set code behind a resource dictionary in WPF. For example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.