Folks;

What I want to do is fairly simple.  We have a number of destructive unit
tests in our environment that should NEVER be run against production, and I
want to enforce that by attaching a plugin to the validate or initialize
phase that will fail the build if "PROD" is in the current list of active
profiles AND if maven.test.skip is either false or undefined.

            <plugin>
                <groupId>org.codehaus.mojo.groovy</groupId>
                <artifactId>groovy-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prevent-tests-against-prod</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <source>
                                if ((${project.activeprofile} == "PROD")
                                && (${maven.test.skip} != "true"))
                                {
                                   fail("Running unit tests against
production is NEVER OK!");
                                }
                            </source>
                        </configuration>
                    </execution>
... (additional executions follow>

So, is there a way to make this happen? I realize I can use mvn
help:active-profiles but having to parse the output of that command is messy
and I'm guessing there's a better way.

Thanks,
-Chris

-- 
Chris Patti --- Y!: feoh -- AIM: chrisfeohpatti --- E-Mail: [EMAIL PROTECTED]
"Technological progress is like an ax in the hands of a pathological
criminal." -Albert Einstein

Reply via email to