Maven configuration for Multi Module Project - spring

I am creating a multi-module project with Spring Boot, the project will have 3 modules: moduleA, moduleB and moduleC.
I am following this tutorial https://spring.io/guides/gs/multi-module/#scratch
in the root directory I've created the 3 directories: moduleA, moduleB and moduleC
I've run mvn -N io.takari:maven:wrapper
after I've run sudo ./mvnw and here the result:
MacBook-Pro-de-calzada:multi-module-project-example nunito$ sudo ./mvnw
/Users/nunito/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.066 s
[INFO] Finished at: 2017-04-24T20:03:37+02:00
[INFO] Final Memory: 7M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. 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-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
MacBook-Pro-de-calzada:multi-module-project-example nunito$
and executing ./mvnw clean install
/Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.062 s
[INFO] Finished at: 2017-04-24T22:38:20+02:00
[INFO] Final Memory: 8M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
MacBook-Pro-de-calzada:multi-module-project-example nunito$

You need to have a pom.xml file in order to run ./mvnw clean install.
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example).
Have a look at Maven Configuration for Multi Module Project and Maven Configuration for Library in the tutorial. There you will find the necessary pom.xml files.

There are two things :
For running any maven project , the very basic and first requirement is you must have a pom.xml . Absence of this file will throw you the error :
[ERROR] The goal you specified requires a project to execute but there
is no POM in this directory
(/Users/calzada/Development/J2EE/workspace-sts-3.8.4.RELEASE/multi-module-project-example).
Please verify you invoked Maven from the correct directory. -> [Help
1]
In the tutorial https://spring.io/guides/gs/multi-module/#scratch it is mentioned that you should have the pom.xml file , please refer this section ▶Maven Configuration for Multi Module Project

Related

Error when running docker and maven from shell script

I can run the following line from the command line with correct results:
docker run --rm -v $PWD/java-app:/app -v /root/.m2/:/root/.m2/ -w /app maven:3-alpine mvn -B -DskipTests clean package
Based on the previous command, I created the following script:
echo "******************"
echo "***Building jar***"
echo "******************"
docker run --rm -v $PWD/java-app:/app -v /root/.m2/:/root/.m2/ -w /app maven:3-alpine "$#"
To run that script, I use the following line:
./jenkins/build/mvn.sh mvn -B -DskipTests package
And I obtain the following output:
******************
***Building jar***
******************
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.071 s
[INFO] Finished at: 2021-04-21T19:03:56Z
[INFO] Final Memory: 13M/381M
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "package
[ERROR] ". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. 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-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException
Any clues?
The reason was I was creating the script with a Windows editor. That introduced a bad character in the file.

Maven installing plugin

[INFO] `Scanning for projects`...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] `Building MVNDEMO 0.0.1-SNAPSHOT`
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] `BUILD FAILURE`
[INFO] ------------------------------------------------------------------------
[INFO] `Total time: 0.099 s
[INFO] Finished at: 2019-04-25T12:29:22+05:30
[INFO] Final Memory: 5M/123M`
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "testcases". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. 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-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
You called something like mvn testcases, which is not a valid Maven phase.
If you want to build, use mvn clean install.

Gitlab CI. mvn verify. Failed to execute goal

I tried build locally:
mvn -B verify
All works fine.
.gitlab-ci.yml :
image: maven:latest
verify-job:
script:
- mvn -B verify
After checked several modules maven. I get error:
[INFO] Tree 1.0-0 ......................................... FAILURE [ 7.587 s]
... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:35 min
[INFO] Finished at: 2018-12-25T13:51:57Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project Tree: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :Tree
ERROR: Job failed: exit code 1
no module uses dependency org.apache.maven.plugins:maven-surefire-plugin
I checked another answers on SO with the same error, no one is related with CI GitLab integration.
I can guess it's related to ktlint, but why local builds are successful?
I find a solution:
just add to pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
Here you can go for the solution, your pipeline need to be define jdk package add:
Just make sure about the java version as per your project needs:
Java_Build:
stage: build
image:
name: docker:20.10
services:
- docker:dind
before_script:
- apk update
- apk add openjdk8
- apk add maven
script:
- mvn -B verify

Maven gives a error when trying to execute the "mvn build" command

When I run my maven project through "run as "==> "Maven build" in my eclipse IDE,the error what is shown in the under img happened.
![enter image description here][1]
My JDK version is:1.7.0_76
Maven version is:3.3.1
echo %JAVA_hOME%=D:\work\Java\jdk1.7.0_76
echo %M2_HOME%=D:\work\apache-maven-3.3.3
In my eclipse IDE My maven setting like the under img:![enter image description here][2]![enter image description here][3]
My project's build path is ![enter image description here][4]
This is because this project is an old project compiled with JDK1.6,so,I choose the installed jdk1.6. But when run as maven build,the error like picture 1 happened!
Help me ,pls!
The error is 【[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.084 s
[INFO] Finished at: 2015-07-11T01:15:18+08:00
[INFO] Final Memory: 5M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. 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-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
】
If you select Run As → Maven build an Eclipse Run Configuration is used (see menu Run → Run Configurations...). In case of a Maven Build at least one appropriate goal (e.g. one of Maven's built-in lifecycles) has to be specified in its Goals: field.

Maven surefire - test failures on clean install

I have a Spring MVC project that I am currently working on. Everything looks fine and I am not missing any of the jar files. On "mvn clean install" I am getting the error below.
So far I've tried all the other suggestion that I found on similar topics like: "mvn dependency::tree" so I can check if I am missing any repository but no result.
For some guys it looks like "mvn clean install -U" was the solution but not in my case, getting the same error.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:17 min
[INFO] Finished at: 2014-12-09T11:46:34+00:00
[INFO] Final Memory: 23M/226M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
12.4:test (default-test) on project am: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\ADMIN\Documents\Code Base\Removable Disk\am
\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
C:\Users\ADMIN\Documents\Code Base\Removable Disk\am>
One or more test(s) are failing. You have two options
Fix those test cases and try.
or
Run mvn clean install -Dmaven.test.skip. This command will skips the test phase.

Resources