i want have 2 scripts run maven, 1 of depends on environment variable. i'm trying this:
<build> <plugins> <plugin> <groupid>org.codehaus.groovy.maven</groupid> <artifactid>gmaven-plugin</artifactid> <version>1.0</version> <executions> <execution> <phase>validate</phase> <goals> <goal>execute</goal> </goals> <configuration> <source> println "my script" </source> </configuration> </execution> </executions> </plugin> </build> ... <profile> <activation> <property> <name>env.my_env_var</name> <value>runstuff</value> </property> </activation> <build> <plugins> <plugin> <groupid>org.codehaus.groovy.maven</groupid> <artifactid>gmaven-plugin</artifactid> <version>1.0</version> <executions> <execution> <phase>validate</phase> <goals> <goal>execute</goal> </goals> <configuration> <source> println "my conditional script" </source> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile>
when run "mvn validate" test this, "my script". when set env variable , run again, "my conditional script" not "my script". seems if condition satisfied , second 1 runs, first 1 not.
i want run first 1 unconditionally and second 1 if env variable set. thought of checking env variable in script seems problematic too, according this question.
i'm new maven it's not unlikely there's simple solution i'm not seeing it.
i found answer. each execution must have unique id. if don't specify id, 'default' both. once gave conditional 1 non-default id, both run.
<build> <plugins> <plugin> ... <executions> <execution> <id>unconditional-script</id> ... </execution> </executions> </plugin> </build> ... <profile> ... <build> <plugins> <plugin> ... <executions> <execution> <id>conditional-script</id> ... </execution> </executions> </plugin> </plugins> </build> </profile>
Comments
Post a Comment