Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute multiple goals in one maven command, but with different arguments for each goal

Tags:

java

maven

I am trying to run 2 maven goals in one maven command like:

mvn release:prepare release:perform -Darguments='-Dmaven.test.skip=true'

but, I would like the first goal to skip tests and the second one not to skip tests.

It has to be in one line command.

Is there a way to do it other than executing them in 2 separate commands?

like image 558
Eric Avatar asked Apr 01 '15 04:04

Eric


People also ask

How do I run multiple Maven commands?

Use these commands in batch file to run ur script. Keep your batch file where you pom. xml file is housed set ProjectPath=C:\TetonWorkSpace\PeriodicApplicationCheck cd %ProjectPath% mvn clean test -Dxmlfile=Smoke. xml pause To Create a Task in Task scheduler: 1.

How do I set goals in Maven?

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. Click OK.

How do I run an argument in a Maven project?

You could run: mvn exec:exec -Dexec. args="arg1". This will pass the argument arg1 to your program. By using the -f parameter, you can also run it from other directories.

Which Maven goal can be used to create a Maven project from the command line?

To build a Maven project via the command line, you use the mvn command from the command line. The command must be executed in the directory which contains the relevant pom file. You pass the build life cycle, phase or goal as parameter to this command.

How do I run a specific goal in Maven project?

To run a specific goal, without executing its entire phase (and the preceding phases) we can use the command: mvn <PLUGIN>:<GOAL> For example, to run integration-test goal from Failsafe plugin, we need to run: mvn failsafe:integration-test 6. Building a Maven Project

What are the Maven commands?

Maven contains a wide set of commands which you can execute. Maven commands are a mix of build life cycles, build phases and build goals, and can thus be a bit confusing. Therefore I will describe the common Maven commands in this tutorial, as well as explain which build life cycles, build phases and build goals they are executing.

What are the goals of Maven phases?

Maven Goal Each phase is a sequence of goals, and each goal is responsible for a specific task. When we run a phase – all goals bound to this phase are executed in order. Here are some of the phases and default goals bound to them: We can list all goals bound to a specific phase and their plugins using the command:

How do I pass an argument to Maven?

Passing an Argument to Maven Now, let's run Maven from our terminal as we usually do, with the package command, for example. But in this case, let's also add the notation -D followed by a property name:


1 Answers

You can use the following:

mvn -Dmaven.test.skip=true release:prepare release:perform

Within release-plugin the arguments are passed via -Darguments='....' to the sub process which is started by release:perform. The other arguments are passed to the process which is started by release:prepare.

like image 163
khmarbaise Avatar answered Nov 15 '22 01:11

khmarbaise