Maven
Top Commands
mvn archetype:generate -DgroupId=org.cloudhadoop -DartifactId=myproject
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=com.cloudhadoop -DartifactId=mywebapp
mvn clean
mvn compile
mvn clean install -Dmaven.test.skip=true or mvn clean install -DskipTests=true or with a package goal ```markup mvn package –DskipTests or mvn package -Dmaven.test.skip
mvn -X mvn dependency:tree mvn dependency:resolve mvn dependency:resolve -Dartifact=groupId:artifactId:version
mvn help:effective-pom
Super POM - Simplest POM - Effective POM
Effective POM is a mixture of Super POM and Simplest POM. It's better to say that the Effective POM is actual POM that your project uses.
Maven dependencies and transitive dependencies
Dependencies are just dependencies that you literally use, including in your Simplest POM.
Transitive dependencies are hidden from you. Because you use them using explicit dependencies.
mvn dependency:resolve
// link
Goal that resolves the project dependencies from the repository. When using this goal while running on Java 9 the module names will be visible as well.
mvn dependency:tree
// link
Displays the dependency tree for this project. Multiple formats are supported: text (by default), but also DOT, GraphML, and TGF.
mvn dependency:analyze
// link
Analyzes the dependencies of this project and determines which are: used and declared; used and undeclared; unused and declared.
How to exclude transitive dependency?
FE: Dependency org.apache.velocity
includes transitive dependency oro.
To exclude you have to write <exclusions> tags in your Simplest POM:
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <exclusions> <exclusion> <groupId>oro</groupId> <artifactId>oro</artifactId> </exclusion> </exclusions> </dependency> </dependencies>
Plugins
Official Apache documentation.
Maven Build Lifecycles
Official Apache documentation.
Maven Packaging Types / JAR - WAR - EAR - ...
IndelliJ Idea Hot Keys for Maven
Show Dependencies... // ⌥⇧⌘U //