Я использую Maven 3.0.3.Мне нужно определить переменную в моем скрипте ("env").У меня есть секция <profiles>
в моем pom, в которой я определяю переменную для элемента <profile>
...
<profile>
<id>qa</id>
<properties>
<env>qa</env>
...
</properties>
</profile>
В моем файле pom.xml как активировать профиль, только если ни один не был указанчерез опцию командной строки "-P" (и, следовательно, установить переменную, если она не была определена)?Я попробовал следующее,
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>env</name>
<value>dev</value>
</property>
</activation>
<properties>
<url>http://localhost:8080/manager</url>
<server>nnadbmon-dev-tomcat</server>
</properties>
</profile>
, но выполнить команду "mvn compile" не удалось, потому что установленный мной плагин принудительного применения требует, чтобы я определил переменную "env".Вот код, который я запускаю для моего подключаемого модуля ...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>enforce-property</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireProperty>
<property>env</property>
<message>Environment missing. This should be either dev, qa, or prod, specified as part of the profile (pass this as a parameter after -P).</message>
<regex>^(dev|qa|production)$</regex>
<regexMessage>Incorrect environment. Expecting one of dev, qa, or prod.</regexMessage>
</requireProperty>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>