FrankD
FrankD

Reputation: 899

maven build goal need to specify

I have extracted a sample Struts 2 project and it has the maven pom.xml file. I already installed the m2e plugin for eclipse. But when I right click the pom.xml file and select Maven Build it gives me the below error.

No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]

What is the goal I need to specify in the m2e window when I click on Maven build?

Upvotes: 26

Views: 89757

Answers (4)

Thach Van
Thach Van

Reputation: 1539

In the goal field on Run Configurations dialog (Main tab), you can input any of the following Maven's phases:


  1. validate – validate the project is correct and all necessary information is available
  2. compile – compile the source code of the project
  3. test – test the compiled source code using a suitable unit testing framework. These tests should not require the code to be packaged or deployed package – take the compiled code and package it in its distributable format, such as a JAR.
  4. integration-test – process and deploy the package if necessary into an environment where integration tests can be run
  5. verify – run any checks to verify the package is valid and meets quality criteria
  6. install – install the package into the local repository, for use as a dependency in other projects locally
  7. deploy – done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

From: Unknown Lifecycle Phase Error in Maven Build.

Upvotes: 16

bugz
bugz

Reputation: 11

after testing the above solutions I found the correct one.

(1) make sure are enviroment variables are well set (M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-3.3.3

M2=%M2_HOME%\bin)(https://www.tutorialspoint.com/maven/maven_environment_setup.htm)

(2) open the command prompt as admin

(3) change directory to your workspace (cd/workspace/project folder

(4) finally (customize)

mvn archetype:generate -DgroupId=fr.myGroupId -DartifactId=MyApplication -Dpackagename=fr.myGroupId -DarchetypeArtifactId=maven-archetype-quickstart .

Upvotes: 1

Sasi Kathimanda
Sasi Kathimanda

Reputation: 1806

In your Eclipse, Run-->Run Configurations --> on left you will see "Maven Build".on right please mention your goal in the goals tab. for eg:-Dmaven.tomcat.port=8080 tomcat:run

Upvotes: 27

kostja
kostja

Reputation: 61538

You can build a maven project with m2e by right-clicking your project or your .pom, selecting Run as then Maven build... then write package into the goal field and click Run.

The according keyboard shortcut is Alt+Ctrl+X, then m - it will get you to the same dialog.

The result will probably be a .war file in the target subfolder of your project.

Upvotes: 36

Related Questions