Maven and Gradle are build automation tool that help us to to build our project.
Gradle faster than Maven?What is the difference between Maven and Gradle?
Cannot find matching toolchain definitions for the following toolchain types jdk
In this case to resolve the build issue we need to create a toolchains.xml file in .m2 directory. And add the following lines into that file.
<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>11</version>
<vendor>oracle</vendor>
</provides>
<configuration>
<jdkHome>C:\Program Files\Java\jdk-11.0.15</jdkHome>
</configuration>
</toolchain>
</toolchains>
After updating toolchains.xml file, go back to your project and execute the command to build the project.
Skip Running Tests from Maven Build
There are multiple ways to skip the execution of the tests from a Maven project. So that at the time of build it doesn't compile the unit tests. Following are the steps using that you can skip the unit test compilation.
1. The first way is; while compiling or building the project using mvn install command. There are two commands that you can use on the command line to skip the tests running.
a. -DskipTests
b. -Dmaven.test.skip=true
2. Another way is to add the skipTests configuration in POM.xml file within the maven-surefire-plugin plugin. Below is the plugin code snippet for POM file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
Reference
Failed to read artifact descriptor | Maven
Problem
Failed to read artifact descriptor for com.adobe.acs:acs-aem-commons-bundle:jar:3.17.2: could not find artifact com.adobe.acs:acs-aem-commons:pom:3.17.2 in central (https://repo.maven.apache.org/maven2)
Resolution
In case you are seeing this error while building the code using Maven then please try to run the maven command with -Padobe-public or setting ssl=true. Below are the sample command lines.
mvn -PautoInstallPackage -Padobe-public clean install
mvn clean install -P autoInstallPackage -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced
To bypass this default restriction, you can do the following:
- add the -U flag to the maven install command, or
- configure your Maven clients’ settings.xml file with the following value <updatePolicy>always</updatePolicy>. Below is the sample settings.xml file.
<settings xmlns="https://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> <profiles> <!-- ====================================================== --> <!-- A D O B E P U B L I C P R O F I L E --> <!-- ====================================================== --> <profile> <id>adobe-public</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <releaseRepository-Id>adobe-public-releases</releaseRepository-Id> <releaseRepository-Name>Adobe Public Releases</releaseRepository-Name> <releaseRepository-URL>https://repo.adobe.com/nexus/content/groups/public</releaseRepository-URL> </properties> <repositories> <repository> <id>adobe-public-releases</id> <name>Adobe Public Repository</name> <url>https://repo.adobe.com/nexus/content/groups/public</url> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>adobe-public-releases</id> <name>Adobe Public Repository</name> <url>https://repo.adobe.com/nexus/content/groups/public</url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>adobe-public</activeProfile> </activeProfiles> </settings>
Maven project configuration for module is not available
Maven resources compiler: Maven project configuration required for module '<project name>' isn't available. Compilation of Maven projects is supported only if external build is started from an IDE.
Solution
No goals have been specified for this build
When we started a maven project without setting the run goal then the Maven build will get failed and generate the below 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]".
In this case, we have to set the maven goal e.g. clean install to successfully build and run the project or application.
Resolution
If you are running using IDE then please set the command line as mentioned below and restart the build. To set the command line with IntelliJ, please go to Run >> Edit Configurations >> Select your project >> Select Parameters tab from left >> put clean install in command line field.
Now rerun the maven build.
Error while running the Maven project.
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.882 s [INFO] Finished at: 2021-06-09T07:28:32+05:30 [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 Process finished with exit code 1
Failed to collect dependencies mule-core-ee:jar:3.8.4
Resolution:
To resolve this in Mule 3 Anypoint studio, create a new fresh maven project and build it. If this newly created project successfully build then your other project where you are facing this issue will work. Match the project POM.xml file with new project pom and see the dependencies.Example POM.xml file.
maven commands/phases
mvn validate
mvn compile
mvn package
mvn install
mvn deploy
mvn test
mvn verify
mvn integration-test
mvn clean
mvn site
References:
useful maven command and their usage
usage: mvn [options] [<goal(s)>] [<phase(s)>]
Options:
-am,--also-make If project list is specified, also build projects required by the list
-amd,--also-make-dependents If project list is specified, also build projects that depend on projects on the list
-B,--batch-mode Run in non-interactive (batch) mode
-b,--builder <arg> The id of the build strategy to use.
-C,--strict-checksums Fail the build if checksums don't match
-c,--lax-checksums Warn if checksums don't match
-cpu,--check-plugin-updates Ineffective, only kept for backward compatibility
-D,--define <arg> Define a system property
-e,--errors Produce execution error messages
-emp,--encrypt-master-password <arg> Encrypt master security password
-ep,--encrypt-password <arg> Encrypt server password
-f,--file <arg> Force the use of an alternate POM file (or directory with pom.xml).
-fae,--fail-at-end Only fail the build afterwards; allow all non-impacted builds to continue
-ff,--fail-fast Stop at first failure in reactorized builds
-fn,--fail-never NEVER fail the build, regardless of project result
-gs,--global-settings <arg> Alternate path for the global settings file
-gt,--global-toolchains <arg> Alternate path for the global toolchains file
-h,--help Display help information
-l,--log-file <arg> Log file where all build output will go.
-llr,--legacy-local-repository Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be
activated by using -Dmaven.legacyLocalRepo=true
-N,--non-recursive Do not recurse into sub-projects
-npr,--no-plugin-registry Ineffective, only kept for backward compatibility
-npu,--no-plugin-updates Ineffective, only kept for backward compatibility
-nsu,--no-snapshot-updates Suppress SNAPSHOT updates
-o,--offline Work offline
-P,--activate-profiles <arg> Comma-delimited list of profiles to activate
-pl,--projects <arg> Comma-delimited list of specified reactor projects to build instead of all projects. A project can be
specified by [groupId]:artifactId or by its relative path.
-q,--quiet Quiet output - only show errors
-rf,--resume-from <arg> Resume reactor from specified project
-s,--settings <arg> Alternate path for the user settings file
-T,--threads <arg> Thread count, for instance 2.0C where C is core multiplied
-t,--toolchains <arg> Alternate path for the user toolchains file
-U,--update-snapshots Forces a check for missing releases and updated snapshots on remote repositories
-up,--update-plugins Ineffective, only kept for backward compatibility
-V,--show-version Display version information WITHOUT stopping build
-v,--version Display version information
-X,--debug Produce execution debug output