Difference between revisions of "Maven"

From BC$ MobileTV Wiki
Jump to: navigation, search
(Tutorials)
 
(63 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
  
== Phases ==
+
== Lifecycle ==
 +
 
 +
<ref>Setting Up Your Project to Use the Build Lifecycle: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#setting-up-your-project-to-use-the-build-lifecycle</ref>
 +
 
 +
=== Phases ===
  
 
Although hardly a comprehensive list, these are the most common default lifecycle phases executed.
 
Although hardly a comprehensive list, these are the most common default lifecycle phases executed.
Line 21: Line 25:
 
<ref>'''Maven in 5 Minutes: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html'''</ref><ref>Tutorial -- Build a JAR file with Maven in 5 minutes: https://cwiki.apache.org/confluence/display/MAVEN/Tutorial%3A+Build+a+JAR+file+with+Maven+in+5+minutes</ref><ref>: https://stackoverflow.com/questions/3402806/what-does-the-name-snapshot-in-jar-mean-whats-wrong-with-snapshot-jars</ref>
 
<ref>'''Maven in 5 Minutes: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html'''</ref><ref>Tutorial -- Build a JAR file with Maven in 5 minutes: https://cwiki.apache.org/confluence/display/MAVEN/Tutorial%3A+Build+a+JAR+file+with+Maven+in+5+minutes</ref><ref>: https://stackoverflow.com/questions/3402806/what-does-the-name-snapshot-in-jar-mean-whats-wrong-with-snapshot-jars</ref>
  
=== Build Commands ===
+
=== Goals  ===
 +
 
 +
* Maven Goals & Phases: https://www.baeldung.com/maven-goals-phases
 +
* IntelliJ IDE - Maven goals: https://www.jetbrains.com/help/idea/work-with-maven-goals.html
 +
 
 +
====  Build Commands ====
  
 
The following are some useful commands (don't forget to remove "mvn" before adding a command to a Run Configuration in your [[IDE]] of choice, the plugin will automatically call Maven).
 
The following are some useful commands (don't forget to remove "mvn" before adding a command to a Run Configuration in your [[IDE]] of choice, the plugin will automatically call Maven).
Line 43: Line 52:
 
  mvn clean dependency:copy-dependencies package
 
  mvn clean dependency:copy-dependencies package
  
 +
<ref>Maven build debug in Eclipse: https://stackoverflow.com/questions/12598261/maven-build-debug-in-eclipse/18616075#18616075</ref>
  
  
 +
==== Troubleshooting ====
  
 +
Search for JARs in your local Maven repository (local cache):
 +
file ~/.m2/repository/org/jsoup/jsoup/1.10.3/jsoup-1.10.3.jar
  
== POM ==
+
Given a specific JAR, search contents to find a specific class (for debugging any "ClassNotFoundException" and similar issues):
 +
jar -tf ~/.m2/repository/org/jsoup/jsoup/1.10.3/jsoup-1.10.3.jar | grep org/jsoup/parser/Parser
 +
 
 +
=== Scopes ===
 +
 
 +
* Maven Dependency Scopes: https://www.baeldung.com/maven-dependency-scopes
 +
* Run main class of Maven project: https://stackoverflow.com/questions/9846046/run-main-class-of-maven-project
 +
* Java with Maven wouldn't build -- Cannot run program ''cmd'' exception "Malformed argument has embedded quote": https://stackoverflow.com/questions/58411279/java-with-maven-wouldnt-build-cannot-run-program-cmd-malformed-argument-has
 +
* Maven POM.xml problem - Unknown error at top line ( <?xml version="1.0" encoding="UTF-8"?> ): https://stackoverflow.com/questions/56455851/maven-pom-xml-problem-unknown-error-at-top-line-xml-version-1-0-encoding
 +
* How do I enable index downloads in Eclipse for Maven dependency search?: https://stackoverflow.com/questions/24252256/how-do-i-enable-index-downloads-in-eclipse-for-maven-dependency-search
 +
* How to run unit test with Maven: https://mkyong.com/maven/how-to-run-unit-test-with-maven/
 +
<ref>'''Maven separate Unit Test and Integration Tests: https://stackoverflow.com/questions/33308037/maven-separate-unit-test-and-integration-tests'''</ref>
 +
<ref>What is the difference between the Maven Surefire and Maven Failsafe plugins?: https://stackoverflow.com/questions/28986005/what-is-the-difference-between-the-maven-surefire-and-maven-failsafe-plugins</ref>
 +
* Publishing failed with multiple errors eclipse: https://stackoverflow.com/questions/5618652/publishing-failed-with-multiple-errors-eclipse
 +
* Eclipse -- Maven search dependencies doesn't work: https://stackoverflow.com/questions/14059685/eclipse-maven-search-dependencies-doesnt-work
 +
 
 +
 
 +
=== Profiles ===
 +
 
 +
Build Profiles are used to set one or more distinct sets of properties and/or build commands (for instance Local Dev .vs. Test Environment .vs. Prod Environment settings).
 +
 
 +
* Introduction to Build Profiles: https://maven.apache.org/guides/introduction/introduction-to-profiles.html
 +
<ref>Guide to Maven Profiles: https://www.baeldung.com/maven-profiles</ref>
 +
<ref>Setting default values for custom Maven 2 properties: https://stackoverflow.com/questions/899274/setting-default-values-for-custom-maven-2-properties</ref>
 +
* Maven, The Complete Reference (E-BOOK) -- Chapter 5, section 32 - Profile Activation by the Absence of a Property: https://books.sonatype.com/mvnref-book/reference/profiles-sect-activation.html#profiles-sect-activation-by-absence
 +
<ref>Active by default Maven profile and other profiles: greyfocus.com/2015/06/activebydefault-maven-other-profiles/</ref>
 +
<ref>How to keep Maven profiles which are activeByDefault active even if another profile gets activated?: https://stackoverflow.com/questions/5309379/how-to-keep-maven-profiles-which-are-activebydefault-active-even-if-another-prof</ref>
 +
 
 +
 
 +
 
 +
=== POM ===
  
 
In Maven, the '''P'''roject '''O'''bject '''M'''odel (''POM'') is the term given to the [[XML]]-based definition of a project (similar to [[DOAP]]), which focuses on providing a listing of Dependencies (libraries, supporting tools, etc), where to download or obtain those Dependencies, and how to use those dependencies together with the code contained in the software project in order to successfully perform a [[Build]]. It also provides a linkage to [[Defect Management]] (aka. Issue Management) & [[Testing]] tools. The following is an empty template for the syntax of the ''POM'' file.
 
In Maven, the '''P'''roject '''O'''bject '''M'''odel (''POM'') is the term given to the [[XML]]-based definition of a project (similar to [[DOAP]]), which focuses on providing a listing of Dependencies (libraries, supporting tools, etc), where to download or obtain those Dependencies, and how to use those dependencies together with the code contained in the software project in order to successfully perform a [[Build]]. It also provides a linkage to [[Defect Management]] (aka. Issue Management) & [[Testing]] tools. The following is an empty template for the syntax of the ''POM'' file.
Line 102: Line 145:
 
</pre>
 
</pre>
  
 +
* Maven docs -- Intro to the POM.xml: https://maven.apache.org/guides/introduction/introduction-to-the-pom.html
 +
* Maven docs -- Introduction to the Standard Maven Directory Layout: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
  
 +
 +
=== Dependency Tree ===
 +
 +
You can view your dependency tree by running the following from command-line:
 +
mvn dependency:tree
 +
 +
For larger apps or heavier more complex Maven configurations, you may want to pipe the output to a file to open in a text editor as it could be hard to read from a console/terminal:
 +
mvn dependency:tree -Dverbose >> C:/APPS/dependencies.txt
 +
 +
 +
==== Find Out-of-Date Plugins ====
 +
 +
You can list Maven plugins that are outdated using the following command:
 +
mvn versions:display-plugin-updates
 +
 +
===== Find Out-of-Date Dependencies =====
 +
 +
You can list libraries that are both out-of-date (it will also differentiate those that "should" be able to be upgraded safely, based on Semantic Versioning) using the following command:
 +
mvn versions:display-dependency-updates
  
  
Line 129: Line 193:
  
 
*  Properties Maven plugin: http://www.mojohaus.org/properties-maven-plugin/index.html (set custom properties, system properties, environment variables, etc... and pass them into other commands or build goals)
 
*  Properties Maven plugin: http://www.mojohaus.org/properties-maven-plugin/index.html (set custom properties, system properties, environment variables, etc... and pass them into other commands or build goals)
 +
<ref>Read FILE properties via ''maven-properties'' plugin: https://www.mojohaus.org/properties-maven-plugin/read-project-properties-mojo.html</ref>
  
 
==== Exec ====
 
==== Exec ====
  
* Exec Maven plugin: http://www.mojohaus.org/exec-maven-plugin/index.html (run command-line commands in a separate and/or parallel process)
+
* Exec Maven plugin: http://www.mojohaus.org/exec-maven-plugin/index.html | [https://www.mojohaus.org/exec-maven-plugin/plugin-info.html DOCS] (run command-line commands in a separate and/or parallel process)
 +
<ref>mvn exec plugin -- Usage: https://www.mojohaus.org/exec-maven-plugin/usage.html (valid </ref>
 +
<ref>mvn exec plugin -- Changing the classpath scope when running Java programs: https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-or-java-change-classpath-scope.html</ref>
 +
 
 +
==== Assembly ====
 +
 
 +
''Assembly Plugin'' for Maven enables developers to combine project output into a single distributable archive that also contains dependencies, modules, site documentation, and other files.
 +
 
 +
* Apache Maven Assembly plugin: https://maven.apache.org/plugins/maven-assembly-plugin/
 +
<ref>Apache Mache Assembly Plugin - usage: https://maven.apache.org/plugins/maven-assembly-plugin/usage.html</ref>
 +
<ref>Apache Mache Assembly Plugin - POM.xml config examples: https://maven.apache.org/plugins/maven-assembly-plugin/examples/index.html</ref>
 +
<ref>''assembly:single'' - assemble an application bundle or distribution from an assembly descriptor.: https://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html#skipAssembly</ref>
  
 
==== Continuous Integration ====
 
==== Continuous Integration ====
Line 141: Line 217:
  
 
==== Static Code Analysis ====
 
==== Static Code Analysis ====
 +
 +
<ref>Maven -- Unable to locate Source XRef to link to: https://stackoverflow.com/questions/12038238/unable-to-locate-source-xref-to-link-to</ref>
 +
<ref>SCA reporting with "maven-jxr-plugin": https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jxr-plugin | [https://maven.apache.org/jxr/maven-jxr-plugin/usage.html DOCS - JXR plugin usage]</ref>
 +
<ref>Better site documentation with Maven (Part V) - static code analysis with PMD: https://softwareriot.wordpress.com/2017/09/20/better-site-documentation-with-maven-part-v-static-code-analysis-with-pmd/</ref>
 +
<ref>OpenHAB's excellent example of a Static Code Analysis Tools is a Maven plugin that executes the Maven plugins for SpotBugs, Checkstyle and PMD and generates a merged .html report: https://github.com/openhab/static-code-analysis/blob/main/docs/maven-plugin.md</ref>
 +
<ref>Maven PMD - Analyzing JSP Code: https://maven.apache.org/plugins/maven-pmd-plugin/examples/jspReport.html</ref>
 +
<ref>Maven PMD - Analyzing JavaScript Code: https://maven.apache.org/plugins/maven-pmd-plugin/examples/javascriptReport.html</ref>
 +
<ref>The Maven build task now supports PMD analysis out of the box: https://devblogs.microsoft.com/devops/the-maven-build-task-now-supports-pmd-analysis-out-of-the-box/</ref>
  
 
===== Checkstyle =====
 
===== Checkstyle =====
Line 162: Line 246:
 
* maven 2 - (jUnit) surefire test plugin: http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html
 
* maven 2 - (jUnit) surefire test plugin: http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html
 
* Maven surefire - How to Use: http://maven.apache.org/plugins/maven-surefire-plugin/howto.html
 
* Maven surefire - How to Use: http://maven.apache.org/plugins/maven-surefire-plugin/howto.html
 +
 +
===== JaCoCo =====
 +
 +
* Reporting Code Coverage Using Maven and JaCoCo Plugin: https://dzone.com/articles/reporting-code-coverage-using-maven-and-jacoco-plu
  
 
==== SoapUI ====
 
==== SoapUI ====
Line 221: Line 309:
  
 
* Run Ruby code using Maven: http://mojo.codehaus.org/rubyscript-maven-plugin/introduction.html
 
* Run Ruby code using Maven: http://mojo.codehaus.org/rubyscript-maven-plugin/introduction.html
 +
 +
 +
 +
 +
  
 
== Resources ==
 
== Resources ==
Line 231: Line 324:
 
* Introduction to the Maven Build Lifecycle: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
 
* Introduction to the Maven Build Lifecycle: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
 
* Maven Integrated View for NetBeans IDE: https://blogs.oracle.com/geertjan/entry/maven_integrated_view_for_netbeans
 
* Maven Integrated View for NetBeans IDE: https://blogs.oracle.com/geertjan/entry/maven_integrated_view_for_netbeans
* '''Maven - Configuring a Proxy: http://maven.apache.org/guides/mini/guide-proxies.html'''<ref>'''How do I use Maven through a proxy?: https://stackoverflow.com/questions/1251192/how-do-i-use-maven-through-a-proxy'''</ref>
+
* '''Maven - Configuring a Proxy: http://maven.apache.org/guides/mini/guide-proxies.html'''<ref>'''How do I use Maven through a proxy?: https://stackoverflow.com/questions/1251192/how-do-i-use-maven-through-a-proxy'''</ref><ref>Maven Error When Building Application Blocked Mirror for Repositories: https://help.mulesoft.com/s/article/Maven-error-when-building-application-Blocked-Mirror-for-repositories</ref><ref>How to disable maven blocking external HTTP repositories?: https://stackoverflow.com/questions/67001968/how-to-disable-maven-blocking-external-http-repositories</ref>
 
* Maven - Password Encryption: http://maven.apache.org/guides/mini/guide-encryption.html
 
* Maven - Password Encryption: http://maven.apache.org/guides/mini/guide-encryption.html
 
* '''Maven - Introduction to the Build Lifecycle: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html''' (lists main built-in commands)
 
* '''Maven - Introduction to the Build Lifecycle: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html''' (lists main built-in commands)
Line 241: Line 334:
 
* A simple card game as an illustration of JDK 9 modules with Maven: https://github.com/codetojoy/WarO_Java_9_Maven
 
* A simple card game as an illustration of JDK 9 modules with Maven: https://github.com/codetojoy/WarO_Java_9_Maven
 
* Require Maven Version: https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html<ref>Robustly enforcing a minimum Maven version for your project: http://blog.peterlynch.ca/2009/12/robustly-enforcing-minimum-maven.html</ref>
 
* Require Maven Version: https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html<ref>Robustly enforcing a minimum Maven version for your project: http://blog.peterlynch.ca/2009/12/robustly-enforcing-minimum-maven.html</ref>
 +
* Maven Surefire plugin FAQs: https://maven.apache.org/surefire/maven-surefire-plugin/faq.html
 +
* Maven docs (OFFICIAL) -- Introduction to Build Profiles: http://maven.apache.org/guides/introduction/introduction-to-profiles.html
 +
<ref>'''Creating Profile Specific Configuration Files With Maven: https://www.petrikainulainen.net/programming/tips-and-tricks/creating-profile-specific-configuration-files-with-maven/'''</ref>
 +
<ref>Build profiles -- (environment-specific) properties filtering example "pom.xml": https://github.com/pkainulainen/maven-examples/blob/master/properties-filtering/pom.xml</ref>
 +
<ref>Maven - How do I activate a profile from command line?: https://stackoverflow.com/questions/30927064/maven-how-do-i-activate-a-profile-from-command-line</ref>
  
  
 
== Tutorials ==
 
== Tutorials ==
  
 +
* How to install Maven on Windows, Linux, Mac: https://www.baeldung.com/install-maven-on-windows-linux-mac
 +
* Maven Install on Mac OS X: https://stackoverflow.com/questions/8826881/maven-install-on-mac-os-x<ref>Where is Maven' settings.xml located on Mac os?: https://stackoverflow.com/questions/3792842/where-is-maven-settings-xml-located-on-mac-os</ref><ref>How to Install Maven on macOS using Homebrew: https://www.youdriveai.com/how-to-install-maven-on-macos-using-homebrew</ref><ref>Install Maven on Mac: https://java2blog.com/install-maven-on-mac/</ref><ref>How to install Maven on Mac OSX: https://mkyong.com/maven/install-maven-on-mac-osx/</ref><ref>How to Install Maven on Mac OS: https://www.journaldev.com/2348/install-maven-mac-os</ref>
 +
* '''Where is Maven local repository?: https://mkyong.com/maven/where-is-maven-local-repository/''' (run the command ''mvn help:evaluate -Dexpression=settings.localRepository'' to find your local Maven repo)
 +
* Specify JDK for Maven to use (to override the OS' ''JAVA_HOME''): https://stackoverflow.com/questions/2503658/specify-jdk-for-maven-to-use (''-Dmaven.compiler.fork=true -Dmaven.compiler.executable="\path\to\javac" compile'')
 +
* Oracle docs -- Building and Running a Java SE Application by Using Maven: https://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Maven_SE/Maven.html#section5s1
 
* TutorialsPoint -- Maven Quick Guide: https://www.tutorialspoint.com/maven/maven_quick_guide.htm
 
* TutorialsPoint -- Maven Quick Guide: https://www.tutorialspoint.com/maven/maven_quick_guide.htm
 +
* Maven for building Java applications - tutorial: https://vogella.com/tutorials/ApacheMaven/article.html
 
* How to Create an Executable JAR with Maven: http://www.baeldung.com/executable-jar-with-maven
 
* How to Create an Executable JAR with Maven: http://www.baeldung.com/executable-jar-with-maven
 
* '''Where is the Maven Local Repository?: http://www.baeldung.com/maven-local-repository'''
 
* '''Where is the Maven Local Repository?: http://www.baeldung.com/maven-local-repository'''
Line 251: Line 355:
 
* How to create user-defined properties in Maven: https://www.mkyong.com/maven/how-to-create-user-defined-properties-in-maven/
 
* How to create user-defined properties in Maven: https://www.mkyong.com/maven/how-to-create-user-defined-properties-in-maven/
 
* '''Writing a Full Featured Maven Pom: https://itnext.io/writing-a-full-featured-maven-pom-f5b874eef312?sk=a208ffef0355c5a0910076c7e10d6252'''
 
* '''Writing a Full Featured Maven Pom: https://itnext.io/writing-a-full-featured-maven-pom-f5b874eef312?sk=a208ffef0355c5a0910076c7e10d6252'''
 +
* Converting Maven POM to IVY: http://vafer.org/blog/20081030002755/<ref>How to convert a Maven pom.xml into an Ivy ivy.xml file : http://stefan222devel.blogspot.com/2010/01/how-to-convert-maven-pomxml-into-ivy.html</ref><ref>Convert Maven POM dependencies to ivy.xml file: http://stackoverflow.com/questions/3715811/maven-pom-dependencies-to-ivy-xml-file</ref>
 +
 
* Checkstyle configuration in maven: https://thecodeexamples.com/maven/checkstyle-configuration-in-maven/
 
* Checkstyle configuration in maven: https://thecodeexamples.com/maven/checkstyle-configuration-in-maven/
 
* How to display Maven plugin goals and parameters: https://www.mkyong.com/maven/how-to-display-maven-plugin-goals-and-parameters/
 
* How to display Maven plugin goals and parameters: https://www.mkyong.com/maven/how-to-display-maven-plugin-goals-and-parameters/
 
* How to build project with Maven: https://www.mkyong.com/maven/how-to-build-project-with-maven/
 
* How to build project with Maven: https://www.mkyong.com/maven/how-to-build-project-with-maven/
 
* '''How to Publish Your Artifacts to Maven Central: http://dzone.com/articles/publish-your-artifacts-to-maven-central'''
 
* '''How to Publish Your Artifacts to Maven Central: http://dzone.com/articles/publish-your-artifacts-to-maven-central'''
* Introduction to the Standard Maven Directory Layout: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
+
* How to download sources for a jar with Maven?:https://stackoverflow.com/a/11361413
* Hello World Maven on the NetBeans RCP: http://netbeans.dzone.com/hello-world-maven-netbeans-rcp
+
 
* How to update maven repository in Eclipse?: http://stackoverflow.com/questions/2555845/how-to-update-maven-repository-in-eclipse<ref>m2eclipse wont download maven artifacts: http://stackoverflow.com/questions/3963439/m2eclipse-wont-download-maven-artifacts</ref><ref>Unable to download jars using M2Eclipse (0.10.0, using Maven 3): http://stackoverflow.com/questions/3019811/unable-to-download-jars-using-m2eclipse-0-10-0-using-maven-3/</ref>
 
* How to update maven repository in Eclipse?: http://stackoverflow.com/questions/2555845/how-to-update-maven-repository-in-eclipse<ref>m2eclipse wont download maven artifacts: http://stackoverflow.com/questions/3963439/m2eclipse-wont-download-maven-artifacts</ref><ref>Unable to download jars using M2Eclipse (0.10.0, using Maven 3): http://stackoverflow.com/questions/3019811/unable-to-download-jars-using-m2eclipse-0-10-0-using-maven-3/</ref>
 +
* How to force maven update?: https://stackoverflow.com/questions/4701532/how-to-force-maven-update (''mvn clean install -U'')
 +
 
* '''How to run a maven created JAR file using just the command line: http://stackoverflow.com/questions/15869784/how-to-run-a-maven-created-jar-file-using-just-the-command-line'''
 
* '''How to run a maven created JAR file using just the command line: http://stackoverflow.com/questions/15869784/how-to-run-a-maven-created-jar-file-using-just-the-command-line'''
 
* Maven –- Create a "fat JAR" file – "One-JAR" plugin example: https://www.mkyong.com/maven/maven-create-a-fat-jar-file-one-jar-example/
 
* Maven –- Create a "fat JAR" file – "One-JAR" plugin example: https://www.mkyong.com/maven/maven-create-a-fat-jar-file-one-jar-example/
Line 264: Line 371:
 
* How do I prevent Maven from downloading artifacts every time?: https://stackoverflow.com/questions/21990854/how-do-i-prevent-maven-from-downloading-artifacts-every-time
 
* How do I prevent Maven from downloading artifacts every time?: https://stackoverflow.com/questions/21990854/how-do-i-prevent-maven-from-downloading-artifacts-every-time
 
* Playing with ActiveMQ using Maven: http://pookey.co.uk/wordpress/archives/74-playing-with-activemq-using-maven
 
* Playing with ActiveMQ using Maven: http://pookey.co.uk/wordpress/archives/74-playing-with-activemq-using-maven
* Creating an Enterprise Application Using Maven: http://netbeans.org/kb/docs/javaee/maven-entapp.html<ref>NetBeans Platform Quick Start Using Maven: http://platform.netbeans.org/tutorials/nbm-maven-quickstart.html?intcmp=925655</ref><ref>Maven 3 support in NetBeans IDE 7.0+: http://netbeans.dzone.com/articles/maven-3-support-in-netbeans-ide</ref>
+
* Maven reactor -- A smart way to a modular project structure: https://springorama.wordpress.com/2018/05/24/maven-reactor-a-smart-way-to-a-modular-project-structure/
* Converting maven POM to IVY: http://vafer.org/blog/20081030002755/<ref>How to convert a Maven pom.xml into an Ivy ivy.xml file : http://stefan222devel.blogspot.com/2010/01/how-to-convert-maven-pomxml-into-ivy.html</ref><ref>Convert Maven POM dependencies to ivy.xml file: http://stackoverflow.com/questions/3715811/maven-pom-dependencies-to-ivy-xml-file</ref>
+
 
* Integrating Maven with IBM Rational Application Developer (RAD) 7.5: http://pamirerdem.blogspot.ca/2010/07/integrating-maven-with-ibm-rational.html
+
* '''How to create a Web Application Project with Maven: http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/'''
 +
* How To Create A Java Project With Maven: http://www.javawebtutor.com/articles/maven/maven_java_project.php<ref>Code Sharing (amongst several team members)? Use Maven: https://pettermahlen.com/2010/05/01/code-sharing-use-maven/</ref>
 +
* Maven archetypes tutorial: https://www.vojtechruzicka.com/maven-archetypes/
 +
* '''How to convert Java web project to Maven based project: http://www.mkyong.com/maven/how-to-convert-java-web-project-to-maven-project/'''<ref>'''Maven & Jenkins with Selenium: Complete Tutorial: https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html'''</ref>
 +
* Creating an Enterprise Application Using Maven: http://netbeans.org/kb/docs/javaee/maven-entapp.html
 +
<ref>NetBeans Platform Quick Start Using Maven: http://platform.netbeans.org/tutorials/nbm-maven-quickstart.html?intcmp=925655</ref><ref>Maven 3 support in NetBeans IDE 7.0+: http://netbeans.dzone.com/articles/maven-3-support-in-netbeans-ide</ref>
 +
<ref>Integrating Maven with IBM Rational Application Developer (RAD) 7.5: http://pamirerdem.blogspot.ca/2010/07/integrating-maven-with-ibm-rational.html</ref>
 +
<ref>Hello World Maven on the NetBeans RCP: http://netbeans.dzone.com/hello-world-maven-netbeans-rcp</ref>
 
* NetBeans Platform CRUD Tutorial Using Maven: http://platform.netbeans.org/tutorials/nbm-maven-crud.html?intcmp=925655<ref>NetBeans Platform Maven Command Line Tutorial: http://platform.netbeans.org/tutorials/nbm-maven-commandline.html?intcmp=925655</ref>
 
* NetBeans Platform CRUD Tutorial Using Maven: http://platform.netbeans.org/tutorials/nbm-maven-crud.html?intcmp=925655<ref>NetBeans Platform Maven Command Line Tutorial: http://platform.netbeans.org/tutorials/nbm-maven-commandline.html?intcmp=925655</ref>
 
* How do I add a project as a dependency of another project in Maven?: http://www.avajava.com/tutorials/lessons/how-do-i-add-a-project-as-a-dependency-of-another-project.html
 
* How do I add a project as a dependency of another project in Maven?: http://www.avajava.com/tutorials/lessons/how-do-i-add-a-project-as-a-dependency-of-another-project.html
* How to set up maven 3 local plugin repository: https://stackoverflow.com/questions/13498186/how-to-set-up-maven-3-local-plugin-repository
+
* How to set up Maven 3 local plugin repository: https://stackoverflow.com/questions/13498186/how-to-set-up-maven-3-local-plugin-repository
 
* Eclipse Maven project to Dynamic Web Project layout: https://stackoverflow.com/questions/7275890/eclipse-maven-project-to-dynamic-web-project-layout#7275955
 
* Eclipse Maven project to Dynamic Web Project layout: https://stackoverflow.com/questions/7275890/eclipse-maven-project-to-dynamic-web-project-layout#7275955
 +
* How to Create a Web Project Using Maven in Eclipse: https://dzone.com/articles/how-to-create-a-web-project-using-maven-in-eclipse-1
 
* NetBeans -- Maven Best Practices: http://wiki.netbeans.org/MavenBestPractices<ref>'''NetBeans Platform Quick Start Using Maven: https://platform.netbeans.org/tutorials/nbm-maven-quickstart.html'''</ref><ref>Creating an Enterprise Application Using Maven</ref><ref>NB - Convert a project to Maven?: https://forums.netbeans.org/topic55932.html</ref><ref>Converting a Netbeans project to a Maven enabled project: https://stackoverflow.com/questions/5495213/converting-a-netbeans-project-to-a-maven-enabled-project</ref><ref>How to Create Web Application using Maven and Netbeans: https://javapointers.com/tutorial/create-web-application-using-maven-and-netbeans/</ref><ref>Add JDBC in Netbeans Maven Project: https://stackoverflow.com/questions/30947905/add-jdbc-in-netbeans-maven-project</ref><ref>NetBeanws -- Testing a Maven Enterprise Application: https://netbeans.org/kb/docs/javaee/maven-entapp-testing.html</ref>
 
* NetBeans -- Maven Best Practices: http://wiki.netbeans.org/MavenBestPractices<ref>'''NetBeans Platform Quick Start Using Maven: https://platform.netbeans.org/tutorials/nbm-maven-quickstart.html'''</ref><ref>Creating an Enterprise Application Using Maven</ref><ref>NB - Convert a project to Maven?: https://forums.netbeans.org/topic55932.html</ref><ref>Converting a Netbeans project to a Maven enabled project: https://stackoverflow.com/questions/5495213/converting-a-netbeans-project-to-a-maven-enabled-project</ref><ref>How to Create Web Application using Maven and Netbeans: https://javapointers.com/tutorial/create-web-application-using-maven-and-netbeans/</ref><ref>Add JDBC in Netbeans Maven Project: https://stackoverflow.com/questions/30947905/add-jdbc-in-netbeans-maven-project</ref><ref>NetBeanws -- Testing a Maven Enterprise Application: https://netbeans.org/kb/docs/javaee/maven-entapp-testing.html</ref>
 
* Missing Maven "settings.xml" file for your Eclipse? What if you need two settings.xml files, one for "Work dev environment" and one for "Personal Workspace"?: https://crunchify.com/missing-maven-settings-xml-file-for-your-eclipse-what-if-you-need-two-settings-xml-file-for-work-personal-workspace/
 
* Missing Maven "settings.xml" file for your Eclipse? What if you need two settings.xml files, one for "Work dev environment" and one for "Personal Workspace"?: https://crunchify.com/missing-maven-settings-xml-file-for-your-eclipse-what-if-you-need-two-settings-xml-file-for-work-personal-workspace/
* '''How to create a Web Application Project with Maven: http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/'''
 
* How To Create A Java Project With Maven: www.javawebtutor.com/articles/maven/maven_java_project.php<ref>Code Sharing (amongst several team members)? Use Maven: https://pettermahlen.com/2010/05/01/code-sharing-use-maven/</ref>
 
* '''How to convert Java web project to Maven based project: http://www.mkyong.com/maven/how-to-convert-java-web-project-to-maven-project/'''<ref>'''Maven & Jenkins with Selenium: Complete Tutorial: https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html'''</ref>
 
 
* Understanding Maven Version Numbers: https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN8855
 
* Understanding Maven Version Numbers: https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN8855
 
* Updating POM Versions: http://maven.apache.org/maven-release/maven-release-plugin/examples/update-versions.html
 
* Updating POM Versions: http://maven.apache.org/maven-release/maven-release-plugin/examples/update-versions.html
 
* Incrementing Maven Project Version with Jenkins/Git: https://stackoverflow.com/questions/9807226/incrementing-maven-project-version-with-jenkins-git
 
* Incrementing Maven Project Version with Jenkins/Git: https://stackoverflow.com/questions/9807226/incrementing-maven-project-version-with-jenkins-git
 
* How do I get Maven to use the correct repositories?: https://stackoverflow.com/questions/2361294/how-do-i-get-maven-to-use-the-correct-repositories (''mvn -Dmaven.repo.local=~/.m2/repository clean install'')
 
* How do I get Maven to use the correct repositories?: https://stackoverflow.com/questions/2361294/how-do-i-get-maven-to-use-the-correct-repositories (''mvn -Dmaven.repo.local=~/.m2/repository clean install'')
 +
* How to set order of repositories in Maven settings.xml: https://stackoverflow.com/questions/5325407/how-to-set-order-of-repositories-in-maven-settings-xml
 +
* Guide for Supporting Multiple Versions of Java (8, 11, 14) in Your Maven Project: https://dzone.com/articles/guide-for-supporting-multiple-versions-of-java-8-1
 
* Using Jenkins Build Version With Maven: https://tedvinke.wordpress.com/2013/04/20/using-jenkins-build-version-with-maven/
 
* Using Jenkins Build Version With Maven: https://tedvinke.wordpress.com/2013/04/20/using-jenkins-build-version-with-maven/
 
* How to build the right smoke test REST service in Java EE with Maven: http://www.codingpedia.org/ama/how-to-build-the-right-smoke-test-rest-service-in-java-ee-with-maven (Servlet/WebService to retrieve GIT version programmatically)
 
* How to build the right smoke test REST service in Java EE with Maven: http://www.codingpedia.org/ama/how-to-build-the-right-smoke-test-rest-service-in-java-ee-with-maven (Servlet/WebService to retrieve GIT version programmatically)
 
* Maven Tips and Tricks -- Encrypting Passwords: https://blog.sonatype.com/2009/10/maven-tips-and-tricks-encrypting-passwords/
 
* Maven Tips and Tricks -- Encrypting Passwords: https://blog.sonatype.com/2009/10/maven-tips-and-tricks-encrypting-passwords/
 
* Using Maven to create Self-Contained, Rich Web Application JARs: http://dzone.com/articles/self-contained-rich-web-application-jars
 
* Using Maven to create Self-Contained, Rich Web Application JARs: http://dzone.com/articles/self-contained-rich-web-application-jars
* Maven does not find JUnit tests to run: https://stackoverflow.com/questions/6178583/maven-does-not-find-junit-tests-to-run (requires one of the following naming conventions for the JUnit Test classes to be followed: ''Test*'', ''*Test'', ''*TestCase'')
+
 
 +
* '''Maven -- Skipping Tests''': https://maven.apache.org/plugins-archives/maven-surefire-plugin-2.12.4/examples/skipping-test.html<ref>'''Maven – How to skip unit test: https://www.mkyong.com/maven/how-to-skip-maven-unit-test/'''</ref><ref>Difference between ''-Dmaven.test.skip=true'' and ''-DskipTests'' in Maven: https://memorynotfound.com/maven-skip-unit-tests/</ref><ref>Maven skip tests (explained): https://stackoverflow.com/questions/24727536/maven-skip-tests</ref>
 +
* (What to do when) Maven does not find JUnit tests to run: https://stackoverflow.com/questions/6178583/maven-does-not-find-junit-tests-to-run (requires one of the following naming conventions for the JUnit Test classes to be followed: ''Test*'', ''*Test'', ''*TestCase'')
 +
* How to run (a specific) Unit Test with Maven: https://www.mkyong.com/maven/how-to-run-unit-test-with-maven/ (''mvn test -Dtest=TestMyApp'' for a jUnit Test case called "TestMyApp.java" which tests the functionality of "MyApp.java")
 +
* Run Junit Suite using Maven Command: https://stackoverflow.com/questions/11762801/run-junit-suite-using-maven-command
 +
* How to run all tests in a particular package with Maven?: https://stackoverflow.com/questions/6819888/how-to-run-all-tests-in-a-particular-package-with-maven
 +
* From Maven, how do I run a class that lives under src/test/java?: https://stackoverflow.com/questions/4060613/from-maven-how-do-i-run-a-class-that-lives-under-src-test-java
 +
* Running JUnit Tests in Parallel with Maven: https://www.baeldung.com/maven-junit-parallel-tests
 +
* '''Parallel builds in Maven 3: https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3'''
 +
* Fork Options and Parallel Test Execution: https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html
 +
 
 +
* '''Creating Profile Specific Configuration Files With Maven: https://www.petrikainulainen.net/programming/tips-and-tricks/creating-profile-specific-configuration-files-with-maven/'''<ref>maven profiles - load config.properties based on environment : http://maven.40175.n5.nabble.com/maven-profiles-load-config-properties-based-on-environment-td5752105.html</ref>
 +
* How do I specify a separate maven goal for running (Cucumber) acceptance tests?: https://stackoverflow.com/questions/18164579/how-do-i-specify-a-separate-maven-goal-for-running-cucumber-acceptance-tests
 +
* How to pass parameters to maven build using pom.xml?: https://stackoverflow.com/questions/24206013/how-to-pass-parameters-to-maven-build-using-pom-xml
 +
* Passing command line arguments from Maven as properties in pom.xml: https://stackoverflow.com/questions/7513319/passing-command-line-arguments-from-maven-as-properties-in-pom-xml
 +
* Reading from config.properties file Maven project: https://stackoverflow.com/questions/35008377/reading-from-config-properties-file-maven-project
 +
* Reading Properties file from POM file in Maven: https://stackoverflow.com/questions/14725197/reading-properties-file-from-pom-file-in-maven/14727072
 +
* Maven -- how to place resource file together with JAR?: https://stackoverflow.com/questions/5637532/maven-how-to-place-resource-file-together-with-jar
 +
* How to reference a resource file correctly for JAR and Debugging?: https://stackoverflow.com/questions/6192661/how-to-reference-a-resource-file-correctly-for-jar-and-debugging
 +
* Maven custom properties precedence: https://davidmarquis.wordpress.com/2011/01/13/maven-custom-properties-precedence/
 +
: https://stackoverflow.com/questions/13708738/how-to-get-a-command-line-property-to-overwrite-a-maven-property?noredirect=1&lq=1
 +
* Maven Resources plugin: https://www.baeldung.com/maven-resources-plugin
 +
<ref>Best practices for copying files with Maven: https://stackoverflow.com/questions/586202/best-practices-for-copying-files-with-maven</ref>
 +
* What is the correct way of forcing maven to use HTTPS for maven central?; https://stackoverflow.com/questions/25393298/what-is-the-correct-way-of-forcing-maven-to-use-https-for-maven-central
 +
* Is it possible to have a JAR missing in Maven Central Repository?: https://stackoverflow.com/questions/14101312/is-it-possible-to-have-a-jar-missing-in-maven-central-repository ("com.bea.xml" ''JSR-137-RI'' reference implementation, XML Stream parser)
 +
* Manually install a Maven dependency from command-line: https://blog.lakmali.com/2011/12/manually-install-maven-dependency.html<ref>Maven2 -- Missing artifact but JARs are in place: https://stackoverflow.com/questions/6111408/maven2-missing-artifact-but-jars-are-in-place</ref>
 +
* How to add Maven as relative dependency from local JAR file: https://blog.lakmali.com/2011/12/how-to-add-maven-dependency-as-relative.html
 +
* Force Maven to execute offline with local repository dependencies in a machine without Internet connection: https://manios.org/2019/08/21/force-maven-offline-execute-goal-dependencies (i.e. manually build up a local repo)
 +
* '''(Tricks for) Faster Maven builds: https://blog.frankel.ch/faster-maven-builds/1/'''
 +
* Faster Maven builds in Docker containers: https://blog.frankel.ch/faster-maven-builds/2/
 +
* Maven Out of Memory Build Failure: https://stackoverflow.com/questions/12498738/maven-out-of-memory-build-failure
 +
* Error when importing Maven-GWT project ("No marketplace entries found to handle gwt-maven-plugin"): https://stackoverflow.com/questions/7916308/error-when-importing-maven-gwt-project-no-marketplace-entries-found-to-handle (similar errors arise with "maven-clean-plugin")
 +
 
 +
* ''maven-replacer-plugin'' and multiple files: https://stackoverflow.com/questions/15157779/maven-replacer-plugin-and-multiple-files
 +
<ref>Maven build script for replacement of text in web.xml (and others): https://blog.giantgeek.com/?p=1377</ref>
 +
<ref>Using Maven Replacer Plugin to replace strings from a properties file: https://crushedbeans.wordpress.com/2013/06/08/using-maver-replacer-plugin-to-replace-strings-from-a-properties-file/</ref>
 +
<ref>Maven replacer -- replacement value containing dollar signs: https://stackoverflow.com/questions/33667378/maven-replacer-replacement-value-containing-dollar-signs</ref>
 +
* Use ${basedir} in Maven.. ALWAYS! : https://keheliya.blogspot.com/2012/07/use-basedir-in-maven-always.html
 +
* Maven – How to create a multi module project: https://mkyong.com/maven/maven-how-to-create-a-multi-module-project/ (JDK 8, prior to JPMS modules in JDK 9+)
 +
* '''Multi-Module Maven Application with Java Modules: https://www.baeldung.com/maven-multi-module-project-java-jpms'''
 +
* What is an "uber jar"?: https://stackoverflow.com/questions/11947037/what-is-an-uber-jar
 +
* How to add aem Uber jar dependency in maven build: https://stackoverflow.com/questions/42731492/how-to-add-aem-uber-jar-dependency-in-maven-build
 +
 
 +
* A Practical Guide to Uploading Artifacts to Maven Central: https://knowm.org/a-practical-guide-to-uploading-artifacts-to-maven-central/
 +
* Publishing artifacts to Maven Central with Bintray & Gradle: http://andresalmiray.com/publishing-artifacts-to-maven-central-with-bintray-gradle/
 +
<ref>Understanding Maven Version Numbers: https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN8855</ref>
 +
<ref>Release vs. Snapshot repositories: http://www.scmgalaxy.com/tutorials/release-vs-snapshot-repositories/</ref>
 +
<ref>How to Use Snapshot of Library in Maven Project: https://dzone.com/articles/how-to-use-snapshot-of-library-in-maven-project</ref>
 +
<ref>Maven Snapshot Repository vs Release Repository: https://stackoverflow.com/questions/275555/maven-snapshot-repository-vs-release-repository</ref>
 +
 
 +
* Java with maven wouldn't build -- Cannot run program “cmd” “Malformed argument has embedded quote”: https://stackoverflow.com/questions/58411279/java-with-maven-wouldnt-build-cannot-run-program-cmd-malformed-argument-has (can potentially be fixed by adding '''-J-Djdk.lang.Process.allowAmbiguousCommands=true''' to ''netbeans_default_options'')
 +
* Fixing weird "''javax.annotation,version=[3.0,4)'' -- Cannot be resolved" error -Issue #117: https://github.com/adobe/aem-project-archetype/issues/117 (Maven transient-dependency hell example on popular library JSoup suddenly dropping "javax.annotation" transient dependencies and expecting them to be "provided" by any projects using/referencing JSoup from now on)
 +
<ref>''javax.annotation,version'' -- Cannot be resolved #229: https://github.com/adobe/aem-project-archetype/issues/229</ref>
 +
<ref>''javax.annotation,version'' -- Cannot be resolved #270 : https://github.com/adobe/aem-project-archetype/pull/270/files/5b7317d73ca9305eb54602fb81be5f2279f2ee33</ref>
 +
<ref>javax.annotation classes and Java 11 JDK: https://stackoverflow.com/questions/56855335/javax-annotation-classes-and-java-11-jdk</ref>
 +
<ref>Can't find @Nullable inside ''javax.annotation.*'': https://stackoverflow.com/questions/19030954/cant-find-nullable-inside-javax-annotation</ref>
 +
<ref>Maven central -- ''javax.annotation'': https://search.maven.org/search?q=javax.annotation</ref>
 +
<ref>Maven central -- ''com.google.code.findbugs:jsr305'': https://search.maven.org/artifact/com.google.code.findbugs/jsr305/3.0.2/jar</ref>
 +
<ref>Maven repository -- ''javax.annotation'': https://mvnrepository.com/search?q=javax.annotation-api</ref>
 +
<ref>OSGi import of ''javax.annotation'' and ''javax.annotation.meta'' is broken in 1.14.2 #1616: https://github.com/jhy/jsoup/issues/1616</ref>
 +
<ref>JSoup -- bug fix to remove ''javax.annotation.meta'' specific version transient dependency: https://github.com/jhy/jsoup/pull/1619/files</ref>
 +
<ref>Where is javax.annotation: https://stackoverflow.com/questions/22589302/where-is-javax-annotation</ref>
 +
 
 +
 
  
 
== External Links ==
 
== External Links ==
Line 326: Line 503:
 
* Android local libraries with Maven: https://android.jlelse.eu/android-local-libraries-with-maven-b7456d4268cf\
 
* Android local libraries with Maven: https://android.jlelse.eu/android-local-libraries-with-maven-b7456d4268cf\
 
* Why I Moved Back from Gradle to Maven: https://blog.philipphauer.de/moving-back-from-gradle-to-maven/
 
* Why I Moved Back from Gradle to Maven: https://blog.philipphauer.de/moving-back-from-gradle-to-maven/
 +
* Maven features I wish Gradle had - inlined plugins: http://andresalmiray.com/maven-features-i-wish-gradle-had-inlined-plugins/
 
* What does the name SNAPSHOT in jar mean? / What's wrong with *snapshot*.jars?: https://stackoverflow.com/questions/3402806/what-does-the-name-snapshot-in-jar-mean-whats-wrong-with-snapshot-jars
 
* What does the name SNAPSHOT in jar mean? / What's wrong with *snapshot*.jars?: https://stackoverflow.com/questions/3402806/what-does-the-name-snapshot-in-jar-mean-whats-wrong-with-snapshot-jars
 
* How to effectively use SNAPSHOT: http://jlorenzen.blogspot.ca/2007/09/how-to-effectively-use-snapshot.html
 
* How to effectively use SNAPSHOT: http://jlorenzen.blogspot.ca/2007/09/how-to-effectively-use-snapshot.html
 
* Maven - Snapshots: https://www.tutorialspoint.com/maven/
 
* Maven - Snapshots: https://www.tutorialspoint.com/maven/
* Local Maven Repository and Libraries: https://android.jlelse.eu/local-maven-repository-and-libraries-updated-story-7585f1563fb2
+
* Local Maven Repository & Libraries: https://android.jlelse.eu/local-maven-repository-and-libraries-updated-story-7585f1563fb2
 +
* Pass '''JAVA_HOME''' as parameter to ''mvn'': https://stackoverflow.com/questions/15345215/pass-java-home-as-parameter-to-mvn
 +
* What's a practicable way for automated configuration, versioning and deployment of Maven-based java applications?: https://stackoverflow.com/questions/14650468/whats-a-practicable-way-for-automated-configuration-versioning-and-deployment/14661186#14661186
 +
* Getting around Maven's parent-child project version dependency issue: https://www.igorkromin.net/index.php/2015/11/08/getting-around-mavens-parent-child-project-version-dependency-issue/
 +
* Multi module builds with Maven 3.5+ and the parent-child pom version management: https://www.igorkromin.net/index.php/2017/06/16/multi-module-builds-with-maven-35-and-the-parent-child-pom-version-management/
 +
* Maven main module & sub-module pom.xml Dependency declaration dependency (dependency put into child module or parent module): https://developpaper.com/maven-main-module-and-sub-module-pom-xml-dependency-declaration-dependency-dependency-put-into-child-module-or-parent-module/
 +
* Usage of Maven ${basedir} in multi-module setup: https://stackoverflow.com/questions/6061537/usage-of-maven-basedir-in-multi-module-setup<ref>Getting parent directory of ${basedir} from maven: https://stackoverflow.com/questions/19511785/getting-parent-directory-of-basedir-from-maven</ref>
 +
* '''JavaFX Application with Maven in Eclipse: https://stackoverflow.com/questions/34388367/javafx-application-with-maven-in-eclipse''' (standalone/launchable Desktop JavaFX app built using Maven)
 +
* Jenkins Build Error -- Build step 'Invoke top-level Maven targets' marked build as failure: https://stackoverflow.com/questions/45048958/jenkins-build-error-build-step-invoke-top-level-maven-targets-marked-build-as
 +
* No archetypes currently available. The archetype list will refresh when the indexes finish updating: https://stackoverflow.com/questions/10612599/no-archetypes-currently-available-the-archetype-list-will-refresh-when-the-inde
 +
* Import Maven Remote Archetype Catalogs in Eclipse: https://howtodoinjava.com/eclipse/how-to-import-maven-remote-archetype-catalogs-in-eclipse/
 +
* “Add Local Catalog” workaround for Maven Archetypes behind a proxy: https://web.archive.org/web/20170208173809/http://adobeaemclub.com/configuring-aem-maven-archetype-for-eclipse-plugin/
 +
* What to do when you get “no archetypes currently available”: https://stackoverflow.com/questions/10612599/no-archetypes-currently-available-the-archetype-list-will-refresh-when-the-inde
 +
* Maven Archetype generate proxy issue, searching for remote catalog: https://stackoverflow.com/questions/41504411/maven-archetype-generate-proxy-issue-searching-for-remote-catalog
 +
* How does the Archetype Plugin know about archetypes?: http://maven.apache.org/archetype/maven-archetype-plugin/specification/archetype-catalog.html
 +
* How to solve “Plugin execution not covered by lifecycle configuration” for Spring Data Maven Builds: https://stackoverflow.com/questions/6352208/how-to-solve-plugin-execution-not-covered-by-lifecycle-configuration-for-sprin
 +
* Maven project in eclipse - deployment assembly fails build: https://stackoverflow.com/questions/6799135/maven-project-in-eclipse-deployment-assembly-fails-build
 +
* Maven 3.7 to Include Default Wrapper: https://www.infoq.com/news/2020/04/maven-wrapper/ (inspired by Spring Boot and Gradle, Maven will now include a Maven Wrapper "mvnw" & "mvnw.cmd" to automatically download a specific version of Maven prior to builds)<ref>What is the purpose of ''mvnw'' and ''mvnw.cmd'' files?: https://stackoverflow.com/questions/38723833/what-is-the-purpose-of-mvnw-and-mvnw-cmd-files</ref>
 +
* maven -- Failed to install metadata project Could not parse metadata maven-metadata-local.xml: only whitespace content allowed before start tag: https://stackoverflow.com/questions/26024582/maven-failed-to-install-metadata-project-could-not-parse-metadata-maven-metada
 +
* Maven features I wish Gradle had - override task properties: http://andresalmiray.com/maven-features-i-wish-gradle-had-override-task-properties/
 +
* What's New in Maven 4: https://maarten.mulders.it/2020/11/whats-new-in-maven-4/
 +
* Maven and IntelliJ IDEA: https://blog.jetbrains.com/idea/2021/07/using-maven-in-intellij-idea/
  
  
Line 338: Line 537:
 
== See Also ==
 
== See Also ==
  
[[Ant]] | [[Java]] | [[CI]] | [[Testing]] | [[SCM]]
+
[[Ant]] | [[Java]] | [[CI]] | [[Testing]] | [[SCM]] | [[Semantic Versioning]]
  
 
[[Category:Build Tool]]
 
[[Category:Build Tool]]

Latest revision as of 21:14, 21 June 2022

Apache Software Foundation (ASF) logo
Apache Maven project

Maven is a dependency management system and build tool for rapid Java-based application development with rich features to streamline development and SCM. Maven is a Yiddish word which means "accumulator of knowledge". The Maven Project started out as an attempt to simplify build processes in a project with multiple Ant build scripts. It was proposed that a standard way to build projects, clearly define what a project consists of, easily publish project information and share JARs across several different projects would greatly simplify and lend efficiency and speed to the Java development process.


Lifecycle

[1]

Phases

Although hardly a comprehensive list, these are the most common default lifecycle phases executed.

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

There are two other Maven lifecycles of note beyond the default list above. They are

  • clean - cleans up artifacts created by prior builds
  • site - generates site documentation for this project

[2][3][4]

Goals

Build Commands

The following are some useful commands (don't forget to remove "mvn" before adding a command to a Run Configuration in your IDE of choice, the plugin will automatically call Maven).

Standard full clean & install (with complete maven repository building of dependencies via POM dependency list):

mvn clean install -PautoInstallPackage

Clean the target directory, build and explode out a WAR file, run it in an embedded Jetty server (should be configured properly in pom.xml).

mvn clean war:exploded jetty:run -e

Run unit tests:

mvn test

Package a runnable JAR, WAR or EAR:

mvn package

Build a new snapshot and release:

mvn -U deploy

An interesting thing to note is that phases and goals may be executed in sequence:

mvn clean dependency:copy-dependencies package

[5]


Troubleshooting

Search for JARs in your local Maven repository (local cache):

file ~/.m2/repository/org/jsoup/jsoup/1.10.3/jsoup-1.10.3.jar

Given a specific JAR, search contents to find a specific class (for debugging any "ClassNotFoundException" and similar issues):

jar -tf ~/.m2/repository/org/jsoup/jsoup/1.10.3/jsoup-1.10.3.jar | grep org/jsoup/parser/Parser

Scopes

[6] [7]


Profiles

Build Profiles are used to set one or more distinct sets of properties and/or build commands (for instance Local Dev .vs. Test Environment .vs. Prod Environment settings).

[8] [9]

[10] [11]


POM

In Maven, the Project Object Model (POM) is the term given to the XML-based definition of a project (similar to DOAP), which focuses on providing a listing of Dependencies (libraries, supporting tools, etc), where to download or obtain those Dependencies, and how to use those dependencies together with the code contained in the software project in order to successfully perform a Build. It also provides a linkage to Defect Management (aka. Issue Management) & Testing tools. The following is an empty template for the syntax of the POM file.

 <project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <!-- The Basics -->
  <groupId>...</groupId>
  <artifactId>...</artifactId>
  <version>...</version>
  <packaging>...</packaging>
   <dependencies>
     <dependency>
       <groupId>...</groupId>
       <artifactId>...</artifactId>
       <version>...</version>
     </dependency>
   </dependencies>
   <parent>...</parent>
   <dependencyManagement>...</dependencyManagement>
   <modules>...</modules>
   <properties>...</properties>

  <!-- Build Settings -->
   <build>...</build>
   <reporting>...</reporting>

  <!-- Additional Project Information -->
   <name>...</name>
   <description>...</description>
   <url>...</url>
   <inceptionYear>...</inceptionYear>
   <licenses>...</licenses>
   <organization>...</organization>
   <developers>...</developers>
   <contributors>...</contributors>

   <!-- Environment Settings -->
   <issueManagement>...</issueManagement>
   <ciManagement>...</ciManagement>
   <mailingLists>...</mailingLists>
   <scm>...</scm>
   <prerequisites>...</prerequisites>
   <repositories>...</repositories>
   <pluginRepositories>...</pluginRepositories>
   <distributionManagement>...</distributionManagement>
   <profiles>...</profiles>
 </project>


Dependency Tree

You can view your dependency tree by running the following from command-line:

mvn dependency:tree

For larger apps or heavier more complex Maven configurations, you may want to pipe the output to a file to open in a text editor as it could be hard to read from a console/terminal:

mvn dependency:tree -Dverbose >> C:/APPS/dependencies.txt


Find Out-of-Date Plugins

You can list Maven plugins that are outdated using the following command:

mvn versions:display-plugin-updates
Find Out-of-Date Dependencies

You can list libraries that are both out-of-date (it will also differentiate those that "should" be able to be upgraded safely, based on Semantic Versioning) using the following command:

mvn versions:display-dependency-updates



Tools

Plugins

Releases

Versions

SCM

Properties

[12]

Exec

[13] [14]

Assembly

Assembly Plugin for Maven enables developers to combine project output into a single distributable archive that also contains dependencies, modules, site documentation, and other files.

[15] [16] [17]

Continuous Integration

Continuous Integration

Static Code Analysis

[18] [19] [20] [21] [22] [23] [24]

Checkstyle
PMD
findbugs
spotbugs

jUnit

JaCoCo

SoapUI

Tomcat

Config processor

Castor

Exec (command-line)

CloudTools


Language Extensions

While just about any program can be run remotely in a cloud environment via the CloudTools plugin, or by calling a local program from the command-line via the Exec plugin, there are still instances when you want to work more closely with a given programming language's specific tools such as compilers, testing suites, IDEs, etc. You can accomplish this by using one of the many Language-specific Maven extensions.

PHP

Python

Flex

C#

C/C++

RubyScript




Resources

[37] [38] [39]


Tutorials

[51][52] [53] [54]

https://stackoverflow.com/questions/13708738/how-to-get-a-command-line-property-to-overwrite-a-maven-property?noredirect=1&lq=1

[67]

[69] [70] [71]

[72] [73] [74] [75]

[76] [77] [78] [79] [80] [81] [82] [83] [84] [85]


External Links


References

  1. Setting Up Your Project to Use the Build Lifecycle: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#setting-up-your-project-to-use-the-build-lifecycle
  2. Maven in 5 Minutes: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
  3. Tutorial -- Build a JAR file with Maven in 5 minutes: https://cwiki.apache.org/confluence/display/MAVEN/Tutorial%3A+Build+a+JAR+file+with+Maven+in+5+minutes
  4. : https://stackoverflow.com/questions/3402806/what-does-the-name-snapshot-in-jar-mean-whats-wrong-with-snapshot-jars
  5. Maven build debug in Eclipse: https://stackoverflow.com/questions/12598261/maven-build-debug-in-eclipse/18616075#18616075
  6. Maven separate Unit Test and Integration Tests: https://stackoverflow.com/questions/33308037/maven-separate-unit-test-and-integration-tests
  7. What is the difference between the Maven Surefire and Maven Failsafe plugins?: https://stackoverflow.com/questions/28986005/what-is-the-difference-between-the-maven-surefire-and-maven-failsafe-plugins
  8. Guide to Maven Profiles: https://www.baeldung.com/maven-profiles
  9. Setting default values for custom Maven 2 properties: https://stackoverflow.com/questions/899274/setting-default-values-for-custom-maven-2-properties
  10. Active by default Maven profile and other profiles: greyfocus.com/2015/06/activebydefault-maven-other-profiles/
  11. How to keep Maven profiles which are activeByDefault active even if another profile gets activated?: https://stackoverflow.com/questions/5309379/how-to-keep-maven-profiles-which-are-activebydefault-active-even-if-another-prof
  12. Read FILE properties via maven-properties plugin: https://www.mojohaus.org/properties-maven-plugin/read-project-properties-mojo.html
  13. mvn exec plugin -- Usage: https://www.mojohaus.org/exec-maven-plugin/usage.html (valid
  14. mvn exec plugin -- Changing the classpath scope when running Java programs: https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-or-java-change-classpath-scope.html
  15. Apache Mache Assembly Plugin - usage: https://maven.apache.org/plugins/maven-assembly-plugin/usage.html
  16. Apache Mache Assembly Plugin - POM.xml config examples: https://maven.apache.org/plugins/maven-assembly-plugin/examples/index.html
  17. assembly:single - assemble an application bundle or distribution from an assembly descriptor.: https://maven.apache.org/plugins/maven-assembly-plugin/single-mojo.html#skipAssembly
  18. Maven -- Unable to locate Source XRef to link to: https://stackoverflow.com/questions/12038238/unable-to-locate-source-xref-to-link-to
  19. SCA reporting with "maven-jxr-plugin": https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jxr-plugin | DOCS - JXR plugin usage
  20. Better site documentation with Maven (Part V) - static code analysis with PMD: https://softwareriot.wordpress.com/2017/09/20/better-site-documentation-with-maven-part-v-static-code-analysis-with-pmd/
  21. OpenHAB's excellent example of a Static Code Analysis Tools is a Maven plugin that executes the Maven plugins for SpotBugs, Checkstyle and PMD and generates a merged .html report: https://github.com/openhab/static-code-analysis/blob/main/docs/maven-plugin.md
  22. Maven PMD - Analyzing JSP Code: https://maven.apache.org/plugins/maven-pmd-plugin/examples/jspReport.html
  23. Maven PMD - Analyzing JavaScript Code: https://maven.apache.org/plugins/maven-pmd-plugin/examples/javascriptReport.html
  24. The Maven build task now supports PMD analysis out of the box: https://devblogs.microsoft.com/devops/the-maven-build-task-now-supports-pmd-analysis-out-of-the-box/
  25. Maven – PMD example: https://www.mkyong.com/maven/maven-pmd-example/
  26. Analyzing JavaScript Code: https://maven.apache.org/plugins/maven-pmd-plugin/examples/javascriptReport.html
  27. Introduction to FindBugs: https://www.baeldung.com/intro-to-findbugs
  28. FindBugs Maven Plugin tutorial: https://www.petrikainulainen.net/programming/maven/findbugs-maven-plugin-tutorial/
  29. Native C/C++ Maven Plugin (usage):http://mojo.codehaus.org/maven-native/native-maven-plugin/usage.html
  30. How do I use Maven through a proxy?: https://stackoverflow.com/questions/1251192/how-do-i-use-maven-through-a-proxy
  31. Maven Error When Building Application Blocked Mirror for Repositories: https://help.mulesoft.com/s/article/Maven-error-when-building-application-Blocked-Mirror-for-repositories
  32. How to disable maven blocking external HTTP repositories?: https://stackoverflow.com/questions/67001968/how-to-disable-maven-blocking-external-http-repositories
  33. Maven -- Versions plugin - Changing the project version: http://www.mojohaus.org/versions-maven-plugin/examples/set.html
  34. Maven -- Versions plugin - Advancing dependency versions: http://www.mojohaus.org/versions-maven-plugin/examples/advancing-dependency-versions.html
  35. Maven -- Versions plugin - Replacing -SNAPSHOT versions with their corresponding releases: http://www.mojohaus.org/versions-maven-plugin/examples/use-releases.html
  36. Robustly enforcing a minimum Maven version for your project: http://blog.peterlynch.ca/2009/12/robustly-enforcing-minimum-maven.html
  37. Creating Profile Specific Configuration Files With Maven: https://www.petrikainulainen.net/programming/tips-and-tricks/creating-profile-specific-configuration-files-with-maven/
  38. Build profiles -- (environment-specific) properties filtering example "pom.xml": https://github.com/pkainulainen/maven-examples/blob/master/properties-filtering/pom.xml
  39. Maven - How do I activate a profile from command line?: https://stackoverflow.com/questions/30927064/maven-how-do-i-activate-a-profile-from-command-line
  40. Where is Maven' settings.xml located on Mac os?: https://stackoverflow.com/questions/3792842/where-is-maven-settings-xml-located-on-mac-os
  41. How to Install Maven on macOS using Homebrew: https://www.youdriveai.com/how-to-install-maven-on-macos-using-homebrew
  42. Install Maven on Mac: https://java2blog.com/install-maven-on-mac/
  43. How to install Maven on Mac OSX: https://mkyong.com/maven/install-maven-on-mac-osx/
  44. How to Install Maven on Mac OS: https://www.journaldev.com/2348/install-maven-mac-os
  45. How to convert a Maven pom.xml into an Ivy ivy.xml file : http://stefan222devel.blogspot.com/2010/01/how-to-convert-maven-pomxml-into-ivy.html
  46. Convert Maven POM dependencies to ivy.xml file: http://stackoverflow.com/questions/3715811/maven-pom-dependencies-to-ivy-xml-file
  47. m2eclipse wont download maven artifacts: http://stackoverflow.com/questions/3963439/m2eclipse-wont-download-maven-artifacts
  48. Unable to download jars using M2Eclipse (0.10.0, using Maven 3): http://stackoverflow.com/questions/3019811/unable-to-download-jars-using-m2eclipse-0-10-0-using-maven-3/
  49. Code Sharing (amongst several team members)? Use Maven: https://pettermahlen.com/2010/05/01/code-sharing-use-maven/
  50. Maven & Jenkins with Selenium: Complete Tutorial: https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html
  51. NetBeans Platform Quick Start Using Maven: http://platform.netbeans.org/tutorials/nbm-maven-quickstart.html?intcmp=925655
  52. Maven 3 support in NetBeans IDE 7.0+: http://netbeans.dzone.com/articles/maven-3-support-in-netbeans-ide
  53. Integrating Maven with IBM Rational Application Developer (RAD) 7.5: http://pamirerdem.blogspot.ca/2010/07/integrating-maven-with-ibm-rational.html
  54. Hello World Maven on the NetBeans RCP: http://netbeans.dzone.com/hello-world-maven-netbeans-rcp
  55. NetBeans Platform Maven Command Line Tutorial: http://platform.netbeans.org/tutorials/nbm-maven-commandline.html?intcmp=925655
  56. NetBeans Platform Quick Start Using Maven: https://platform.netbeans.org/tutorials/nbm-maven-quickstart.html
  57. Creating an Enterprise Application Using Maven
  58. NB - Convert a project to Maven?: https://forums.netbeans.org/topic55932.html
  59. Converting a Netbeans project to a Maven enabled project: https://stackoverflow.com/questions/5495213/converting-a-netbeans-project-to-a-maven-enabled-project
  60. How to Create Web Application using Maven and Netbeans: https://javapointers.com/tutorial/create-web-application-using-maven-and-netbeans/
  61. Add JDBC in Netbeans Maven Project: https://stackoverflow.com/questions/30947905/add-jdbc-in-netbeans-maven-project
  62. NetBeanws -- Testing a Maven Enterprise Application: https://netbeans.org/kb/docs/javaee/maven-entapp-testing.html
  63. Maven – How to skip unit test: https://www.mkyong.com/maven/how-to-skip-maven-unit-test/
  64. Difference between -Dmaven.test.skip=true and -DskipTests in Maven: https://memorynotfound.com/maven-skip-unit-tests/
  65. Maven skip tests (explained): https://stackoverflow.com/questions/24727536/maven-skip-tests
  66. maven profiles - load config.properties based on environment : http://maven.40175.n5.nabble.com/maven-profiles-load-config-properties-based-on-environment-td5752105.html
  67. Best practices for copying files with Maven: https://stackoverflow.com/questions/586202/best-practices-for-copying-files-with-maven
  68. Maven2 -- Missing artifact but JARs are in place: https://stackoverflow.com/questions/6111408/maven2-missing-artifact-but-jars-are-in-place
  69. Maven build script for replacement of text in web.xml (and others): https://blog.giantgeek.com/?p=1377
  70. Using Maven Replacer Plugin to replace strings from a properties file: https://crushedbeans.wordpress.com/2013/06/08/using-maver-replacer-plugin-to-replace-strings-from-a-properties-file/
  71. Maven replacer -- replacement value containing dollar signs: https://stackoverflow.com/questions/33667378/maven-replacer-replacement-value-containing-dollar-signs
  72. Understanding Maven Version Numbers: https://docs.oracle.com/middleware/1212/core/MAVEN/maven_version.htm#MAVEN8855
  73. Release vs. Snapshot repositories: http://www.scmgalaxy.com/tutorials/release-vs-snapshot-repositories/
  74. How to Use Snapshot of Library in Maven Project: https://dzone.com/articles/how-to-use-snapshot-of-library-in-maven-project
  75. Maven Snapshot Repository vs Release Repository: https://stackoverflow.com/questions/275555/maven-snapshot-repository-vs-release-repository
  76. javax.annotation,version -- Cannot be resolved #229: https://github.com/adobe/aem-project-archetype/issues/229
  77. javax.annotation,version -- Cannot be resolved #270 : https://github.com/adobe/aem-project-archetype/pull/270/files/5b7317d73ca9305eb54602fb81be5f2279f2ee33
  78. javax.annotation classes and Java 11 JDK: https://stackoverflow.com/questions/56855335/javax-annotation-classes-and-java-11-jdk
  79. Can't find @Nullable inside javax.annotation.*: https://stackoverflow.com/questions/19030954/cant-find-nullable-inside-javax-annotation
  80. Maven central -- javax.annotation: https://search.maven.org/search?q=javax.annotation
  81. Maven central -- com.google.code.findbugs:jsr305: https://search.maven.org/artifact/com.google.code.findbugs/jsr305/3.0.2/jar
  82. Maven repository -- javax.annotation: https://mvnrepository.com/search?q=javax.annotation-api
  83. OSGi import of javax.annotation and javax.annotation.meta is broken in 1.14.2 #1616: https://github.com/jhy/jsoup/issues/1616
  84. JSoup -- bug fix to remove javax.annotation.meta specific version transient dependency: https://github.com/jhy/jsoup/pull/1619/files
  85. Where is javax.annotation: https://stackoverflow.com/questions/22589302/where-is-javax-annotation
  86. m2e lifecycle-mapping not found: https://stackoverflow.com/questions/7409823/m2e-lifecycle-mapping-not-found/7423909
  87. Getting parent directory of ${basedir} from maven: https://stackoverflow.com/questions/19511785/getting-parent-directory-of-basedir-from-maven
  88. What is the purpose of mvnw and mvnw.cmd files?: https://stackoverflow.com/questions/38723833/what-is-the-purpose-of-mvnw-and-mvnw-cmd-files

See Also

Ant | Java | CI | Testing | SCM | Semantic Versioning