maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russell Gold <r...@gold-family.us>
Subject Re: Maven profiles question
Date Wed, 16 Oct 2013 00:55:32 GMT
Do you mean that you always want to run this program whenever you build it? Or you only want
to run it when you activate the profile? Unless you do something unusual, "install" will always
cause the jar to be created and installed in your local repository.

You might try adding to your pom something like:

<profiles>
    <profile>
        <id>run</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.2.1</version>
                    <executions>
                        <execution>
                            <phase>install</phase>
                            <goals>
                                <goal>java</goal>
                            </goals>
                            <configuration>
                                <mainClass>MyProgramName</mainClass>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

You can then build and run the program with:

	mvn install -Prun


BTW, (ahem) my video course on maven, linked below, has received some good reviews, if you're
looking for more information. And I do cover profiles and the execution element.

- Russ

On Oct 15, 2013, at 7:50 PM, Jvsrvcs <jvsrvcs@gmail.com> wrote:

> I really do not understand any of the documentation related to the
> <execution> plugin.
> 
> If I do something like:
>  $mvn -P deploy
> 
> I need to:
> 1. build the project (meaning I just want target/myproj.jar to exist
> 2. Run a java program like:   $java -jar target/myproj.jar <some_options>
> 
> so I want to create a profile that will do both.  I realize that simply $mvn
> install will build the target/myproj.jar but how would I add that to a maven
> profile so that it does both the mvn install and runs $java -jar
> target/myproj.jar <opts>
> 
> ?
> 
> Any help would be appreciated, all of the documentation and examples I have
> tried are not leading me to a solution.
> 
> 
> 
> --
> View this message in context: http://maven.40175.n5.nabble.com/Maven-profiles-question-tp5773102.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

-----------------
Author, Getting Started with Apache Maven <http://www.packtpub.com/getting-started-with-apache-maven/video>

Come read my webnovel, Take a Lemon <http://www.takealemon.com>, 
and listen to the Misfile radio play <http://www.fuzzyfacetheater.com/misfile/>!








Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message