Skip to content

Instantly share code, notes, and snippets.

@dzlab
Last active April 14, 2016 14:46
Show Gist options
  • Save dzlab/f67941a2acced194b3bc to your computer and use it in GitHub Desktop.
Save dzlab/f67941a2acced194b3bc to your computer and use it in GitHub Desktop.
A collection of maven commands
# maven ignoring license
mvn install -Dlicense.skip=true -DskipTests
# maven fat jar
mvn assembly:assembly -DdescriptorId=jar-with-dependencies -DskipTests
# maven generate webapp project
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp
# maven generate empty project
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart
mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
# maven run tests of a given class
mvn test -Dtest=classname
Maven plugins:
== Tomcat
```xml
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
```
mvn clean install tomcat7:run
== Executable jar with dependencies:
```xml
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>[app.package.ClassName]</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment