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 8267811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:40:11+00:00 2026-06-08T05:40:11+00:00

Is it possible to set a default property in maven3. I can fetch the

  • 0

Is it possible to set a default property in maven3. I can fetch the CATALINA_HOME from bash by following

 <properties>
     <cargo.tomcat.home>${env.CATALINA_HOME}</cargo.tomcat.home>   
 </properties>

But if the variable is not set and I run the evaluate expression command I get null object

! mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=cargo.tomcat.home

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-help-plugin:2.1.1:evaluate (default-cli) @ cargo-selenium-springmvc-webapp ---
[INFO] No artifact parameter specified, using 'com.keybroker.spike:cargo-selenium-springmvc-webapp:war:1.0-SNAPSHOT' as project.
[INFO] 
null object or invalid expression
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.721s
[INFO] Finished at: Tue Jul 17 16:51:48 CEST 2012
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------

I would be interested in setting a default $CATALINA_HOME. I don’t mind using another plugin but vanilla maven3 would be best. So what i am looking for

if $CATALINA_HOME is set by bash then use it
otherwise if the is a -DcatalinaHome argument passed to maven, then use that 
if all else fails, default to XYZ path for $CATALINA_HOME
  • 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-06-08T05:40:13+00:00Added an answer on June 8, 2026 at 5:40 am

    Yes, this is possible. I have tested this on Windows 7 and Maven 3.0.4. FOO is my example environment variable.

    First, add the following profile to the POM

    <profiles>
      <profile>
        <id>env.FOO</id>
        <activation>
          <property>
            <name>!env.FOO</name>
          </property>
        </activation>
        <properties>
          <env.FOO>default_FOO</env.FOO>
        </properties>
      </profile>
    </profiles>
    

    As you already know, the placeholder ${env.FOO} is used elsewhere in the POM which will be replaced with a real value. The three ways to supply a value are:

    1) By setting an environment variable

    set FOO=env_FOO       (Windows)
    export FOO=env_FOO    (Bash)
    

    2) Supplying a command line parameter (this will override the environment variable)

    mvn -Denv.FOO=cmdline_FOO    (note the env. prefix)
    

    which will override the environment value.

    3) Not setting FOO by any of the previous methods, the value in the POM will be activated clause, by the !env.FOO and be set to default_FOO

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

Sidebar

Related Questions

Is it possible to set a default value without the body of a property?
Is it possible to write similar construction? I want to set, somehow, default value
Is it possible to set a default selection on an NSPopupButton? I have one
Possible Duplicate: How do you give a C# Auto-Property a default value? Hi all:
Possible Duplicate: How do you give a C# Auto-Property a default value? Is there
Possible Duplicate: How do you give a C# Auto-Property a default value? I have
When you set the draggable property of an MKAnnotationView, the default behavior seems to
How can I setup a default value to a property defined as follow: public
Is it possible to override the display property with its default value? For example
Is it possible to set a project default for VB.NET winforms projects so that

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.