Until now, I'm using the command mvn clean compile hibernate3:hbm2java
to launch my program. Is there any way to combine those three goals within a single one, e.g. mvn run
or mvn myapp:run
?
In Maven the "verbs" are goals packaged in Maven plugins which are tied to a phases in a build lifecycle. A Maven lifecycle consists of a sequence of named phases: prepare-resources, compile, package, and install among other. There is phase that captures compilation and a phase that captures packaging.
There are three built-in lifecycles: default: the main lifecycle, as it's responsible for project deployment. clean: to clean the project and remove all files generated by the previous build.
There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's web site.
From the main menu, select Run | Edit Configurations to open the run/debug configuration for your project. In the list that opens, select Run Maven Goal. In the Select Maven Goal dialog, specify a project and a goal that you want to execute before launching the project.
Another solution that differs completely from my other answer would be to use the exec-maven-plugin
with the goal exec:exec
.
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>mvn</executable>
<arguments>
<argument>clean</argument>
<argument>compile</argument>
<argument>hibernate3:hbm2java</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
And then you just run it like this:
mvn exec:exec
By doing it this way you are not changing any of the other plugins and it is not bound to any phases either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With