0

Please tell me how to run the maven LifeCycle commands through Terminal?

enter image description here

If you write mvn clean or mvn compile, then the commands belonging to the maven plugin are run. The result of their execution does not correspond to the commands of the lifecycle.

slindenau
  • 1,091
  • 2
  • 11
  • 18
Mary
  • 35
  • 5
  • Please only ask *one* question per question! I'm removing the second one, otherwise I'd have to vote to close this as "not focused enough". – Marcus Müller Jun 23 '22 at 08:53
  • What do you mean that the result does not correspond? When you click on these buttons in Intellij IDEA it runs that specific `mvn` command in the **context** of your **current project** (with all other settings and enabled options in IDEA). You can even view this command in the output window in IDEA by looking at the first line. – slindenau Jun 23 '22 at 09:08
  • @slindenau The "compile" lifecycle command runs successfully. But running the "mvn compile" command through the terminal ends with the error "Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.2:wsimport". Moreover, this goal is fulfilled with push-button execution, classes of the necessary service are generated. – Mary Jun 23 '22 at 09:35
  • With the terminal you mean the 'Terminal' tab in IDEA, or are you starting a terminal in your OS? In both cases you are now running the `mvn` process manually, without the context that IDEA normally sets. So you will have to make sure that you set all the relevant settings yourself. For starters i think it's good if you add the error message you're getting. You can also inspect what IDEA starts for you by looking at the first line in the 'Run' tab on executing a maven goal. – slindenau Jun 23 '22 at 10:11
  • @slindenau 'Terminal' tab in IDEA. Example. The execution time varies. 1) Terminal. mvn clean compile install -Pdev [INFO] Total time: 02:58 min [INFO] Finished at: 2022-06-23T21:34:11+05:00 – Mary Jun 24 '22 at 04:36
  • @slindenau 2) LifeCycle. "C:\Program Files\Java\jdk1.8.0_112\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\...\IdeaProjects\...\... "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.5\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.5\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.5\plugins\maven\lib\maven-event-listener.jar" (see the continuation below) – Mary Jun 24 '22 at 04:37
  • "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.5\lib\idea_rt.jar=64621:C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2019.3.5\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar" org.codehaus.classworlds.Launcher -Didea.version2019.3.5 install -P dev [INFO] Total time: 26:56 min [INFO] Finished at: 2022-06-23T22:02:15+05:00 – Mary Jun 24 '22 at 04:37
  • There is a very big difference in execution time: 10 times. – Mary Jun 24 '22 at 04:39
  • If you give the command `mvn package` you will start the maven life cycle https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#lifecycle-reference from validate, up-to package (included). That means that every plugin which is bound to the appropriate life cycle phases will be executed. It is possible having several plugins bound to a single life cycle phase... If you like to run on command line just use `mvn package` or alike... Also I strongly recommend to upgrade your IntelliJ version... – khmarbaise Jun 24 '22 at 06:31
  • What version of maven are you using from the terminal? IDEA uses the built in maven3 from your provided log. What does `mvn --version` output from the Terminal? And what is your working directory where you execute the command from the Terminal, is that the same root folder as your IdeaProject (where the pom.xml is located)? – slindenau Jun 24 '22 at 10:09
  • And more logging from the `Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.2:wsimport` error would also help. It should give a reason in the output log why this failed. Alternatively you can add the `-X` flag to the `mvn` command to enable debug logging. – slindenau Jun 24 '22 at 10:16
  • This: `then the commands belonging to the maven plugin are run` is unfortunately wrong. The commands like `mvn package` means to execute the life cycle https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#lifecycle-reference – khmarbaise Jun 24 '22 at 12:36

0 Answers0