Maven: life cycle for running a program?

I can use Maven to compile and test the program

mvn compile
mvn test

Is there a life cycle command to just run the program or create a script that will run the program?

+4
source share
2 answers

If you ask this question, it means that you are not clear that the Maven life cycle is valid.

There is no lifecycle command, only the assembly life cycle, which consists of different phases.

So, to make it clear: there is an assembly life cycle consisting of phases that consist of the goals of the plugin.

When you call Maven with

mvn compile

. Maven . , . , , . compile , , , maven-compiler-plugin, compile.

, : , .

POM, . @manouti, exec-maven-plugin.

+4

, exec-maven-plugin, exec:java goal. , :

<plugin>
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>exec-maven-plugin</artifactId>
     <version>1.4</version>
     <executions>
         <execution>
            <id>run-java</id>
            <phase>package</phase>
            <goals>
                <goal>java</goal>
            </goals>
         </execution>
      </executions>
      <configuration>
           <mainClass>main.Class</mainClass>
      </configuration>
</plugin>
+3

Source: https://habr.com/ru/post/1616113/


All Articles