On Dec 17, 2008, at 9:14 AM, Todd Thiessen wrote:

This prints hello and goodbye as part of the clean phase.
...
Doesn't this fit your needs?

No, it doesn't fit my needs because it always prints both "hello" and "goodbye". I want to print either "hello" or "goodbye".

For example, in the scenario I mentioned earlier, I want to launch a desktop application with one particular command-line configuration. With your solution, I'd be launching the app multiple times. That's certainly not what I want.

I've attached a rewrite of your code that uses profiles to select which configuration is run. For instance:

mvn -Phello clean
mvn -Pgoodbye clean

Or I can do both at once:

mvn -Phello,goodbye clean

Is there a way to accomplish this without profiles?

Trevor

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.vocaro</groupId>
    <artifactId>antrun</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <profiles>
        <profile>
            <id>hello</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>print-hello</id>
                                <phase>clean</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>echo</executable>
                                    <arguments>
                                        <argument>hello</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>goodbye</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>print-goodbye</id>
                                <phase>clean</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>echo</executable>
                                    <arguments>
                                        <argument>goodbye</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    
</project>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to