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 <[email protected]> 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: [email protected]
> For additional commands, e-mail: [email protected]
>
-----------------
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/>!