00 Maven Tips & Tricks - lukes8/wiki-notes GitHub Wiki
https://www.baeldung.com/spring-maven-bom
https://github.com/eugenp/tutorials/tree/master/maven-modules/spring-bom
The maven goal that only makes JAR package from compiled java sources
mvn jar:jar
The maven goal that makes only WAR package from compiled java sources
mvn war:war
The maven phase that makes all first phases ending with package ie. compile, test, jar
mvn package
The maven goal that makes only installation of the package to the maven local .repository (and then accessible as dependency for other projects or modules)
mvn install:install
Process resources, package into JAR file and finally install it to the maven local .repository
mvn resources:resources jar:jar install:install
Tip: very useful if you have just some updated resources and want to build your BIG app simply and faster ie. except of compile and test goals
Process resources, package into WAR file and finally install it to the maven local .repository
mvn resources:resources war:war install:install
Note: the resources can be usually JAR libraries of 3th party, resources on the classpath (yml, config, properties etc.).
Skip javadoc generation during build
mvn clean install -Dmaven.javadoc.skip=true
Packages all needed files (inc. copying webapp resources) into WAR file and finally install it to the maven local .repository
mvn war:war install:install
Tip: very useful if you have updated only some javascripts or other frontend stuffs and want to build your BIG app simply and faster ie. except of compile and test goals
Clean the release property and backup files eg. pom.xml.releaseBackup, release.properties
mvn release:clean
Preparation phase for release when it checks staging area (if exists no modified files) Checks last version from maven-metadata.xml on jFrog to ensure that we are now on correct version (consistency check) Test all test classes eg. h2 tests in case for spring boot Create release version from snapshot ie. modify version in project pom.xml from 1.1.42-SNAPSHOT to 1.1.42 Create tag as release version ie. 1.1.42 Create another development version (snapshot) ie. modify version in project pom.xml from 1.1.42 to 1.1.43-SNAPSHOT
mvn release:prepare
Checkout from SCM URL as remote repository on tagged release version ie. 1.1.42 Deploy/Push the jars or ears to jFrog specified on local settings.xml
mvn release:perform
Tip: tag is basically something like branch but only mark or naming for specified commit so then you can checkout on this tag much more easier way than on commit specified by its number
Checkout from SCM URL as remote repository on tagged release version ie. 1.1.42 Deploy/Push the jars or ears to jFrog specified on passed settings.xml, we might need to access under different user due to privilegies (jFrog has some permissions to approach for specified users)
mvn release:perform -s /path/explicit-settings.xml
Maven cmd used to point to a specific settings file in order to override the default settings.xml
mvn clean install -s YourOwnSettings.xml
Compile means that you need the JAR for compiling and running the app. For a web application, as an example, the JAR will be placed in the WEB-INF/lib directory.
Provided means that you need the JAR for compiling, but at run time there is already a JAR provided by the environment so you don't need it t be packaged with your app. For a web app, this means that the JAR file will not be placed into the WEB-INF/lib directory.
For a web app, if the app server already provides the JAR (or its functionality), then use "provided" otherwise use "compile". ref
mvn dependency:tree | findstr /in log4j
Let's say we have common-package.jar used in our project pom as dependency In the pom.xml of common-package.jar is used version of some eg. jdbc.version v1.1 But we want to use older version of jdbc eg. v1.0. We can make it via parent pom.xml of our project app in properties section With this we will use the different version of jdbc in nested jar.
POM.xml of project app, just example for image
<properties>
...
<jdbc.version>v1.0<jdbc.version> //but in default is used v1.1
</properties>
dependencies section
<dependency>
...
<artifactId>common-package<artifactId>
</dependency>
Sometimes you cannot get some artifakt/package from remote repository eg. jFrog. You can use this manual approach
<dependency>
<groupId>com.some-project</groupId>
<artifactId>some-artifact</artifactId>
<scope>system</scope>
<systemPath>${project.basedir}/your_configs/your_jars/your_package.jar</systemPath>
</dependency>