$ mvn archetype:generate \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DarchetypeVersion=1.5 \ -DgroupId=mtitek.maven.samples \ -DartifactId=mtitek-maven-samples \ -Dpackage=mtitek.maven.samples \ -Dversion=1.0.0-SNAPSHOT \ -DinteractiveMode=falseNotes:
$ mvn archetype:generate
[INFO] Scanning for projects... [INFO] [INFO] ------------------< org.apache.maven:standalone-pom >------------------- [INFO] Building Maven Stub Project (No POM) 1 [INFO] --------------------------------[ pom ]--------------------------------- [INFO] [INFO] >>> archetype:3.4.0:generate (default-cli) > generate-sources @ standalone-pom >>> [INFO] [INFO] <<< archetype:3.4.0:generate (default-cli) < generate-sources @ standalone-pom <<< [INFO] [INFO] [INFO] --- archetype:3.4.0:generate (default-cli) @ standalone-pom --- [INFO] Generating project in Interactive mode [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) Choose archetype: 1: remote -> am.ik.archetype:elm-spring-boot-blank-archetype (Blank multi project for Spring Boot + Elm) 2: remote -> am.ik.archetype:graalvm-blank-archetype (Blank project for GraalVM) ... 3562: remote -> za.co.absa.hyperdrive:component-archetype_2.11 (-) 3563: remote -> za.co.absa.hyperdrive:component-archetype_2.12 (-) Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 2253:
<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> <groupId>mtitek.maven.samples</groupId> <artifactId>mtitek-maven-samples</artifactId> <version>1.0.0-SNAPSHOT</version> <!-- <packaging>jar</packaging> --> <!-- if packaging is not specified, the default value is jar --> </project>Maven commands are always executed on the effective version of the "pom.xml" file.
|+ ${user.home} |+ .m2 |+ repository |+ org |+ apache |+ maven |+ plugins
|+ ${user.home} |+ .m2 |+ repository |+ org |+ apache |+ maven |+ plugins |+ maven-help-plugin
|+ ${user.home} |+ .m2 |+ repository |+ org |+ apache |+ maven |+ plugins |+ maven-help-plugin |+ 2.1.1
<project> <properties> <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format> <!-- default value --> </properties> </project>The date format must follow the syntax defined by SimpleDateFormat.
<build> <sourceDirectory>$HOME/dev/mtitek-maven-samples/src/main/java</sourceDirectory> <testSourceDirectory>$HOME/dev/mtitek-maven-samples/src/test/java</testSourceDirectory> <outputDirectory>$HOME/dev/mtitek-maven-samples/target/classes</outputDirectory> <testOutputDirectory>$HOME/dev/mtitek-maven-samples/target/test-classes</testOutputDirectory> <resources> <resource> <directory>$HOME/dev/mtitek-maven-samples/src/main/resources</directory> </resource> </resources> <testResources> <testResource> <directory>$HOME/dev/mtitek-maven-samples/src/test/resources</directory> </testResource> </testResources> <directory>$HOME/dev/mtitek-maven-samples/target</directory> <!-- ... -->
<?xml version="1.0" encoding="UTF-8" ?> <plugin> <name>Maven Help Plugin</name> <description>...</description> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-help-plugin</artifactId> <version>2.1.1</version> <goalPrefix>help</goalPrefix> <!-- ... --> <mojos> <mojo> <goal>describe</goal> <!-- ... --> <parameters> <parameter> <name>artifactId</name> <type>java.lang.String</type> <required>false</required> <!-- ... --> </parameter> <!-- ... --> </parameters> <configuration> <artifactId implementation="java.lang.String">${artifactId}</artifactId> <!-- ... --> </configuration> <!-- ... --> </mojo> <!-- ... --> </mojos> <dependencies> <!-- ... --> </dependencies> </plugin>
<?xml version="1.0" encoding="UTF-8" ?> <metadata> <plugins> <plugin> <name>Maven Help Plugin</name> <artifactId>maven-help-plugin</artifactId> <prefix>help</prefix> </plugin> <!-- ... --> </plugins> </metadata>To execute a plugin goal, you use the plugin prefix followed by the goal name.
$ mvn help:helpYou can also use the plugin coordinates ("groupId":"artifactId":"version") to execute a goal:
$ mvn org.apache.maven.plugins:maven-help-plugin:help $ mvn org.apache.maven.plugins:maven-help-plugin:3.3.0:helpIf a project defines multiple executions (with different configurations) for a goal in the pom.xml file, you can specify an execution by appending its identifier (id) after the goal name, separated by the character '@':
$ mvn plugin-prefix:plugin-goal@goal-execution-idTo pass values to goal parameters, use the syntax "-Dparam_name=param_value":
$ mvn help:help -Ddetail=true $ mvn org.apache.maven.plugins:maven-help-plugin:3.3.0:help -Ddetail=trueAll writable parameters of the plugin can be initialized in the project's pom.xml file in the "<configuration>" section of the plugin:
... <configuration> <detail>true</detail> </configuration> ...Parameters that can be initialized either via the command line or in the pom.xml file's "<properties>" section are those that define a "property" attribute (User property).
$ mvn help:help -Ddetail=true
... Available parameters: detail (Default: false) If true, display all settable properties for each goal. User property: detail ...It can also be initialized in the project's pom.xml file in the "<properties>" section:
... <properties> <detail>true</detail> </properties> ...
[INFO] ------------------------------------------------------------------------ [INFO] Building mtitek-maven-samples 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-cli) @ mtitek-maven-samples --- [INFO] [INFO] --- maven-jar-plugin:2.3.2:jar (default-cli) @ mtitek-maven-samples --- [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------You can see that the build process executed:
[INFO] ------------------------------------------------------------------------ [INFO] Building mtitek-maven-samples 1.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ mtitek-maven-samples --- [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mtitek-maven-samples --- [INFO] [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ mtitek-maven-samples --- [INFO] [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ mtitek-maven-samples --- [INFO] [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ mtitek-maven-samples --- [INFO] [INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ mtitek-maven-samples --- [INFO] [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ mtitek-maven-samples --- [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
phase goal ---------------------- ------------------------------------- clean clean:clean
phase goal ---------------------- ------------------------------------- site site:site site-deploy site:deploy
phase goal ---------------------- ------------------------------------- process-resources resources:resources compile compiler:compile process-test-resources resources:testResources test-compile compiler:testCompile test surefire:test package jar:jar / war:war / ejb:ejb / rar:rar install install:install deploy deploy:deploy
phase goal ---------------------- ------------------------------------- generate-resources ear:generate-application-xml process-resources resources:resources package ear:ear install install:install deploy deploy:deploy
phase goal ---------------------- ------------------------------------- package site:attach-descriptor install install:install deploy deploy:deploy
phase goal ---------------------- ------------------------------------- generate-resources plugin:descriptor process-resources resources:resources compile compiler:compile process-test-resources resources:testResources test-compile compiler:testCompile test surefire:test package jar:jar + plugin:addPluginArtifactMetadata install install:install deploy deploy:deploy
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> <executions> <execution> <id>default-jar</id> <configuration> <finalName>${project.artifactId}-default-${project.version}</finalName> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <execution> <id>echo-package-name</id> <phase>package</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <echo>project coordinates: ${project.groupId}:${project.artifactId}:${project.packaging}:${project.version} </echo> </target> </configuration> </execution> </executions> </plugin> </plugins> </build>