Activate a profile based on environment

前端 未结 1 876
轻奢々
轻奢々 2020-12-22 04:15

Here\'s my scenario:

  • Maven 2.0.9 is our build system
  • We install code to multiple environments
  • All of our environment-specific properties are
1条回答
  •  别那么骄傲
    2020-12-22 04:58

    This isn't possible using just Maven. (See also How to activate profile by means of maven property?) The reason is that profiles are the first thing evaluated before anything else to determine the effective POM.

    My suggestion is to write some preprocessor that parses your environment specific property files and converts them to the required system properties before launching Maven. This script can be included in your ~/.mavenrc so that it runs automatically before Maven is launched. Here is an example script that that assumes the properties file is in a fixed location:

    properties=`cat /etc/build-env.properties`
    while read line; do
       MAVEN_OPTS="$MAVEN_OPTS -D$line"
    done <<< "$properties"
    

    If the properties file is not fixed, you'll just need to add something to the script to discover the location (assuming it is discoverable).

    0 讨论(0)
提交回复
热议问题