Apache Maven 
Volodymyr Ostapiv 
Aug 2014
Agenda 
▪ What is Maven, Project lifecycle 
▪ Getting, installing, configuring Maven 
▪ POM, GAV, Archetype 
▪ pom.xml contents 
– dependencies 
– properties 
– exclusions 
– profiles 
▪ Some useful plugins 
▪ Creating executable JAR
What is Maven 
▪Maven is a build automation tool used 
primarily for Java projects. 
▪ Maven addresses two aspects of building 
software: 
1. it describes how software is built 
2. it describes its dependencies
Maven LifeCycle 
•Default lifecycle 
–generate-sources/generate-resources 
–compile 
–test 
–package 
–integration-test (pre and post) 
–install 
–Deploy 
•Separate “clean” lifecycle
History 
– Maven 1 (2003) 
– Maven 2 (2005) 
▪ Not backwards Compatible 
– Maven 3 (2010) 
▪ Same as Maven 2 but more stable and with some 
additional features
Get it!
Configure 
Windows 
Settings: %MAVEN_HOME%confsettings.xml 
Repository Location: UserProfile.m2 
Linux 
Settings: /usr/local/maven/conf/settings.xml 
Repository Location: ~/.m2/ 
Use your own temporary settings for maven: 
mvn --settings=[PATH_TO_SETTINGS_FILE] 
Adding a Local repository location: 
mvn -Dmaven.repo.local=/path/to/local/repo
Path Conventions
Create simple project 
mvn archetype:generate 
-DgroupId=[myGroup] 
-DartifactId=[myArtifact] 
-DarchetypeArtifactId=maven-archetype- 
archetype 
OR 
mvn archetype:generate
Arche-who? O_o 
Archetype is a Maven project templating toolkit. 
An archetype is defined as an original pattern or model 
from which all other things of the same kind are made.
Maven + IDE 
Generate project files for the most popular IDEs 
mvn idea:idea mvn eclipse:eclipse
Maven Project Object Model (POM) 
▪ Describes a project 
– Name and Version 
– Artifact Type 
– Source Code Locations 
– Dependencies 
– Plugins 
– Profiles (Alternate build config.) 
▪ Uses XML by default
Project Name (GAV) 
▪ Maven uniquely identifies a project using: 
– groupID: project grouping identifier (no spaces 
or colons) 
▪ Usually loosely based on Java package 
– artfiactId: name of project (no spaces or 
colons) 
– version: Version of project 
▪ Format {Major}.{Minor}.{Maintanence} 
▪ Add ‘-SNAPSHOT ‘ to identify in development
Project Name (GAV) 
<?xml version="1.0" encoding="UTF-8"?> 
<project> 
<modelVersion>4.0.0</modelVersion> 
<groupId>org.lds.training</groupId> 
<artifactId>maven-training</artifactId> 
<version>1.0</version> 
<name>Windows 8</name> 
<description>The best OS ever!</description> 
<packaging>jar</packaging> 
<properties> 
<java.version>1.6</java.version> 
<properties> 
</project>
Dependencies 
<dependencies> 
<dependency> 
<groupId>org.slf4j</groupId> 
<artifactId>slf4j-simple</artifactId> 
<version>1.7.5</version> 
<scope>compile</scope> 
</dependency> 
</dependencies>
Dependency scope 
• compile (default) 
• provided (by JDK or a container at runtime) 
• runtime (not required for compilation) 
• test (used only during tests) 
• system (provided locally) 
• import (only available in Maven 2.0.9 or later)
Properties 
<properties> 
<jdk.version>1.6</jdk.version> 
<spring.version>3.1.2.RELEASE</spring.version> 
<spring.batch.version>2.1.8.RELEASE</spring.batch.version> 
</properties> 
<dependency> 
<groupId>org.springframework.batch</groupId> 
<artifactId>spring-batch-infrastructure</artifactId> 
<version>${spring.batch.version}</version> 
</dependency> 
mvn install -Dmyproperty=my property from command line
Exclusions 
<exclusions> 
<exclusion> 
<groupId>org.softserve.sse</groupId> 
<artifactId>softserve-sse</artifactId> 
</exclusion> 
</exclusions>
Profiles 
<profile> 
<id>default</id> 
<activation> 
<activeByDefault>true</activeByDefault> 
</activation> 
</profile> 
(mvn install -Pprofilename)
Profile activation 
Operating System based: 
<activation> 
<os> 
<family>unix</family> 
</os> 
</activation> 
<activation> 
<os> 
<name>Windows XP</name> 
<family>Windows</family> 
<arch>x86</arch> 
<version>5.1.2600</version> 
</os> 
</activation> 
JDK based: 
<activation> 
<jdk>1.4</jdk> 
</activation> 
<activation> 
<jdk>[1.3,1.6)</jdk> 
</activation>
Profile activation 
System property based: 
<activation> 
<property> 
<name>environment</name> 
<value>test</value> 
</property> 
</activation> 
File system state based: 
<activation> 
<file> 
<missing> 
target/maven/somefile 
</missing> 
</file> 
</activation>
Plugins 
Here real magic starts
maven-surefire-plugin 
surefire:test
Surefire: configuration 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-surefire-plugin</artifactId> 
<version>2.16</version> 
<configuration> 
All stuff goes here 
</configuration> 
</plugin>
Surefire: execution 
<skip>false</skip> 
<includes> 
<include>**/*Test.java</include> 
</includes> 
<excludes> 
<exclude>**/TestToSkip.java</exclude> 
</excludes> 
<!-- parallel execution --> 
<parallel>methods</parallel> 
<threadCount>10</threadCount> 
<useUnlimitedThreads>false</useUnlimitedThreads> 
<forkCount>4</forkCount> 
<reuseForks>true</reuseForks>
jetty-maven-plugin 
mvn jetty:run
tomcat-maven-plugin 
mvn tomcat:run
maven-antrun-plugin 
mvn antrun:run
maven-antrun-plugin 
<plugin> 
<artifactId>maven-antrun-plugin</artifactId> 
<version>1.7</version> 
<executions> 
<execution> 
<phase>generate-sources</phase> 
<configuration> 
<tasks> 
<!-- Place any ant task here (<target> </target> in a build.xml) --> 
</tasks> 
</configuration> 
<goals> 
<goal>run</goal> 
</goals> 
</execution> 
</executions> 
</plugin>
maven-antrun-plugin 
<tasks> 
<exec dir="${project.basedir}" 
executable="${project.basedir}/src/main/sh/doit.sh" failonerror="true"> 
<arg line="arg1 arg2 arg3 arg4" /> 
</exec> 
</tasks> 
<tasks> 
<copy todir="/builds/app/${project.version}"> 
<fileset dir="${project.build.directory}/rpm"/> 
</copy> 
<delete file="src/main/resources/db_conf.properties" /> 
</tasks> 
<tasks> 
<chmod file="src/main/resources/run.sh " perm="755" /> 
</tasks>
maven-compiler-plugin 
mvn compiler:compile 
mvn compiler:testCompile
maven-dependency-plugin 
mvn dependency:analyze 
mvn dependency:tree
selenium-maven-plugin 
selenium:start-server 
selenium:stop-server 
selenium:selenese 
selenium:xvfb
Creating executable JAR 
▪maven-jar-plugin 
(uses classpath 
dependencies) 
▪maven-assembly-plugin 
(all-in-one file) 
▪maven-shade-plugin 
(all-in-one file)
maven-jar-plugin 
mvn jar:jar
maven-jar-plugin 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-jar-plugin</artifactId> 
<version>2.4</version> 
<configuration> 
<archive> 
<manifest> 
<mainClass>org.akceptor.Main</mainClass> 
</manifest> 
</archive> 
</configuration> 
</plugin>
onejar-maven-plugin 
mvn onejar:one-jar
maven-assembly-plugin 
mvn assembly:single
maven-shade-plugin 
mvn shade:shade
Configurations and executions 
<executions> 
<execution> 
<id>execution1</id> 
<phase>test</phase> 
<configuration> 
<timeout>10</timeout> 
<options> 
<option>one</option> 
<option>two</option> 
</options> 
</configuration> 
<goals> 
<goal>doit</goal> 
</goals> 
</execution> 
</executions>
That’s all

More Related Content

PPTX
Apache Maven for AT/QC
PDF
Build system
DOCX
Pom
PDF
Releasing Projects Using Maven
PDF
Maven 3… so what?
PDF
How to create a skeleton of a Java console application
PDF
Deep Dive Hands-on in Java EE 6 - Oredev 2010
PPT
Java build tool_comparison
Apache Maven for AT/QC
Build system
Pom
Releasing Projects Using Maven
Maven 3… so what?
How to create a skeleton of a Java console application
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Java build tool_comparison

What's hot (20)

PPT
Maven in Mule
PDF
Java EE 6 = Less Code + More Power
PDF
Enterprise Maven Repository BOF
PDF
Java, Eclipse, Maven & JSF tutorial
KEY
Introduction To Maven2
KEY
Tycho - good, bad or ugly ?
KEY
How to be effective with JBoss Developer Studio
PDF
Vue routing tutorial getting started with vue router
PPT
Maven
PPT
PDF
[Spring Camp 2013] Java Configuration 없인 못살아!
PDF
Hands On with Maven
PDF
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
PPTX
Maven
PDF
Note - Apache Maven Intro
PPTX
Building and managing java projects with maven part-III
PPT
Training in Android with Maven
PPTX
Cis 274 intro
PDF
Maven 3 Overview
PDF
OSGi framework overview
Maven in Mule
Java EE 6 = Less Code + More Power
Enterprise Maven Repository BOF
Java, Eclipse, Maven & JSF tutorial
Introduction To Maven2
Tycho - good, bad or ugly ?
How to be effective with JBoss Developer Studio
Vue routing tutorial getting started with vue router
Maven
[Spring Camp 2013] Java Configuration 없인 못살아!
Hands On with Maven
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Maven
Note - Apache Maven Intro
Building and managing java projects with maven part-III
Training in Android with Maven
Cis 274 intro
Maven 3 Overview
OSGi framework overview
Ad

Similar to Apache Maven basics (20)

PPTX
Maven Basics - Explained
PPSX
Maven Presentation - SureFire vs FailSafe
PDF
Introduction to maven, its configuration, lifecycle and relationship to JS world
PPT
Introduction tomaven
PDF
PDF
PDF
Apache maven, a software project management tool
PPTX
Maven in mulesoft
PPTX
PPTX
Introduction to maven
PPTX
Maven project build in automation testing in eclipse
PPT
Maven Introduction
PDF
Build Automation using Maven
PPT
MAVEN
PDF
Fundamental of apache maven
PDF
Apache maven
PPTX
Maven
ODP
Maven in Java EE project
Maven Basics - Explained
Maven Presentation - SureFire vs FailSafe
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction tomaven
Apache maven, a software project management tool
Maven in mulesoft
Introduction to maven
Maven project build in automation testing in eclipse
Maven Introduction
Build Automation using Maven
MAVEN
Fundamental of apache maven
Apache maven
Maven
Maven in Java EE project
Ad

Recently uploaded (20)

PDF
Laparoscopic Imaging Systems at World Laparoscopy Hospital
PPTX
pharmaceutics-1unit-1-221214121936-550b56aa.pptx
PDF
African Communication Research: A review
PPTX
principlesofmanagementsem1slides-131211060335-phpapp01 (1).ppt
PPTX
operating_systems_presentations_delhi_nc
PPTX
Approach to a child with acute kidney injury
PPTX
Math 2 Quarter 2 Week 1 Matatag Curriculum
PPTX
4. Diagnosis and treatment planning in RPD.pptx
PPT
hemostasis and its significance, physiology
PPTX
growth and developement.pptxweeeeerrgttyyy
PDF
CHALLENGES FACED BY TEACHERS WHEN TEACHING LEARNERS WITH DEVELOPMENTAL DISABI...
PDF
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
PDF
Unleashing the Potential of the Cultural and creative industries
PPTX
MMW-CHAPTER-1-final.pptx major Elementary Education
PPTX
Copy of ARAL Program Primer_071725(1).pptx
PPT
hsl powerpoint resource goyloveh feb 07.ppt
PPTX
ENGlishGrade8_Quarter2_WEEK1_LESSON1.pptx
PDF
faiz-khans about Radiotherapy Physics-02.pdf
PDF
Chevening Scholarship Application and Interview Preparation Guide
PDF
FAMILY PLANNING (preventative and social medicine pdf)
Laparoscopic Imaging Systems at World Laparoscopy Hospital
pharmaceutics-1unit-1-221214121936-550b56aa.pptx
African Communication Research: A review
principlesofmanagementsem1slides-131211060335-phpapp01 (1).ppt
operating_systems_presentations_delhi_nc
Approach to a child with acute kidney injury
Math 2 Quarter 2 Week 1 Matatag Curriculum
4. Diagnosis and treatment planning in RPD.pptx
hemostasis and its significance, physiology
growth and developement.pptxweeeeerrgttyyy
CHALLENGES FACED BY TEACHERS WHEN TEACHING LEARNERS WITH DEVELOPMENTAL DISABI...
Horaris_Grups_25-26_Definitiu_15_07_25.pdf
Unleashing the Potential of the Cultural and creative industries
MMW-CHAPTER-1-final.pptx major Elementary Education
Copy of ARAL Program Primer_071725(1).pptx
hsl powerpoint resource goyloveh feb 07.ppt
ENGlishGrade8_Quarter2_WEEK1_LESSON1.pptx
faiz-khans about Radiotherapy Physics-02.pdf
Chevening Scholarship Application and Interview Preparation Guide
FAMILY PLANNING (preventative and social medicine pdf)

Apache Maven basics

  • 1. Apache Maven Volodymyr Ostapiv Aug 2014
  • 2. Agenda ▪ What is Maven, Project lifecycle ▪ Getting, installing, configuring Maven ▪ POM, GAV, Archetype ▪ pom.xml contents – dependencies – properties – exclusions – profiles ▪ Some useful plugins ▪ Creating executable JAR
  • 3. What is Maven ▪Maven is a build automation tool used primarily for Java projects. ▪ Maven addresses two aspects of building software: 1. it describes how software is built 2. it describes its dependencies
  • 4. Maven LifeCycle •Default lifecycle –generate-sources/generate-resources –compile –test –package –integration-test (pre and post) –install –Deploy •Separate “clean” lifecycle
  • 5. History – Maven 1 (2003) – Maven 2 (2005) ▪ Not backwards Compatible – Maven 3 (2010) ▪ Same as Maven 2 but more stable and with some additional features
  • 7. Configure Windows Settings: %MAVEN_HOME%confsettings.xml Repository Location: UserProfile.m2 Linux Settings: /usr/local/maven/conf/settings.xml Repository Location: ~/.m2/ Use your own temporary settings for maven: mvn --settings=[PATH_TO_SETTINGS_FILE] Adding a Local repository location: mvn -Dmaven.repo.local=/path/to/local/repo
  • 9. Create simple project mvn archetype:generate -DgroupId=[myGroup] -DartifactId=[myArtifact] -DarchetypeArtifactId=maven-archetype- archetype OR mvn archetype:generate
  • 10. Arche-who? O_o Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made.
  • 11. Maven + IDE Generate project files for the most popular IDEs mvn idea:idea mvn eclipse:eclipse
  • 12. Maven Project Object Model (POM) ▪ Describes a project – Name and Version – Artifact Type – Source Code Locations – Dependencies – Plugins – Profiles (Alternate build config.) ▪ Uses XML by default
  • 13. Project Name (GAV) ▪ Maven uniquely identifies a project using: – groupID: project grouping identifier (no spaces or colons) ▪ Usually loosely based on Java package – artfiactId: name of project (no spaces or colons) – version: Version of project ▪ Format {Major}.{Minor}.{Maintanence} ▪ Add ‘-SNAPSHOT ‘ to identify in development
  • 14. Project Name (GAV) <?xml version="1.0" encoding="UTF-8"?> <project> <modelVersion>4.0.0</modelVersion> <groupId>org.lds.training</groupId> <artifactId>maven-training</artifactId> <version>1.0</version> <name>Windows 8</name> <description>The best OS ever!</description> <packaging>jar</packaging> <properties> <java.version>1.6</java.version> <properties> </project>
  • 15. Dependencies <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.5</version> <scope>compile</scope> </dependency> </dependencies>
  • 16. Dependency scope • compile (default) • provided (by JDK or a container at runtime) • runtime (not required for compilation) • test (used only during tests) • system (provided locally) • import (only available in Maven 2.0.9 or later)
  • 17. Properties <properties> <jdk.version>1.6</jdk.version> <spring.version>3.1.2.RELEASE</spring.version> <spring.batch.version>2.1.8.RELEASE</spring.batch.version> </properties> <dependency> <groupId>org.springframework.batch</groupId> <artifactId>spring-batch-infrastructure</artifactId> <version>${spring.batch.version}</version> </dependency> mvn install -Dmyproperty=my property from command line
  • 18. Exclusions <exclusions> <exclusion> <groupId>org.softserve.sse</groupId> <artifactId>softserve-sse</artifactId> </exclusion> </exclusions>
  • 19. Profiles <profile> <id>default</id> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> (mvn install -Pprofilename)
  • 20. Profile activation Operating System based: <activation> <os> <family>unix</family> </os> </activation> <activation> <os> <name>Windows XP</name> <family>Windows</family> <arch>x86</arch> <version>5.1.2600</version> </os> </activation> JDK based: <activation> <jdk>1.4</jdk> </activation> <activation> <jdk>[1.3,1.6)</jdk> </activation>
  • 21. Profile activation System property based: <activation> <property> <name>environment</name> <value>test</value> </property> </activation> File system state based: <activation> <file> <missing> target/maven/somefile </missing> </file> </activation>
  • 22. Plugins Here real magic starts
  • 24. Surefire: configuration <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.16</version> <configuration> All stuff goes here </configuration> </plugin>
  • 25. Surefire: execution <skip>false</skip> <includes> <include>**/*Test.java</include> </includes> <excludes> <exclude>**/TestToSkip.java</exclude> </excludes> <!-- parallel execution --> <parallel>methods</parallel> <threadCount>10</threadCount> <useUnlimitedThreads>false</useUnlimitedThreads> <forkCount>4</forkCount> <reuseForks>true</reuseForks>
  • 29. maven-antrun-plugin <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>generate-sources</phase> <configuration> <tasks> <!-- Place any ant task here (<target> </target> in a build.xml) --> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
  • 30. maven-antrun-plugin <tasks> <exec dir="${project.basedir}" executable="${project.basedir}/src/main/sh/doit.sh" failonerror="true"> <arg line="arg1 arg2 arg3 arg4" /> </exec> </tasks> <tasks> <copy todir="/builds/app/${project.version}"> <fileset dir="${project.build.directory}/rpm"/> </copy> <delete file="src/main/resources/db_conf.properties" /> </tasks> <tasks> <chmod file="src/main/resources/run.sh " perm="755" /> </tasks>
  • 31. maven-compiler-plugin mvn compiler:compile mvn compiler:testCompile
  • 34. Creating executable JAR ▪maven-jar-plugin (uses classpath dependencies) ▪maven-assembly-plugin (all-in-one file) ▪maven-shade-plugin (all-in-one file)
  • 36. maven-jar-plugin <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <mainClass>org.akceptor.Main</mainClass> </manifest> </archive> </configuration> </plugin>
  • 40. Configurations and executions <executions> <execution> <id>execution1</id> <phase>test</phase> <configuration> <timeout>10</timeout> <options> <option>one</option> <option>two</option> </options> </configuration> <goals> <goal>doit</goal> </goals> </execution> </executions>

Editor's Notes

  • #19: <dependency> <groupId>net.lightbody.bmp</groupId> <artifactId>browsermob-proxy</artifactId> <version>2.0-beta-8</version> <scope>test</scope> <exclusions> <exclusion> <groupId>org.softserve.sse</groupId> <artifactId>softserve-sse</artifactId> </exclusion> </exclusions> </dependency>
  • #20: <profiles> <profile> <id>default</id> <activation> <activeByDefault>true</activeByDefault> </activation> <build> <finalName>${name}</finalName> <plugins> <plugin>…</plugin> <plugins> </build> </profile> </profiles>
  • #21: <activation> <os> <family>windows</family> </os> </activation>
  • #23: Maven is – at its heart – a plugin execution framework. All work is done by plugins. Looking for a specific goal to execute. There are the build and the reporting plugins: Build plugins will be executed during the build and they should be configured in the <build/> element from the POM. Reporting plugins will be executed during the site generation and they should be configured in the <reporting/> element from the POM.
  • #24: http://maven.apache.org/surefire/maven-surefire-plugin/ Maven Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in 2 different file formats: Plain text files (*.txt) XML files (*.xml) By default, these files are generated at ${basedir}/target/surefire-reports. For an HTML format of the report, please see the Maven Surefire Report Plugin.
  • #25: mvn –DskipTests mvn -Dmaven.test.skip=true
  • #26: Parallel execution * parallel: methods, classes, both, suites, suitesAndClasses, suitesAndMethods, classesAndMethods, all ** threadCount: <threadCountMethods>10</threadCountMethods> <threadCountClasses>10</threadCountClasses> <threadCountSuites>10</threadCountSuites>
  • #27: http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html
  • #28: http://tomcat.apache.org/maven-plugin.html
  • #29: https://maven.apache.org/plugins/maven-antrun-plugin/
  • #30: https://maven.apache.org/plugins/maven-antrun-plugin/
  • #31: https://maven.apache.org/plugins/maven-antrun-plugin/
  • #32: <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> <configuration> <source>1.6</source> <target>1.6</target> <compilerArgument>-proc:none</compilerArgument> </configuration> <executions> <execution> <id>run-annotation-processors-only</id> <phase>generate-sources</phase> <configuration> <compilerArgument>-proc:only</compilerArgument> <!-- If your app has multiple packages, use this include filter to execute the processor only on the package containing your entities --> <!-- <includes> <include>**/model/*.java</include> </includes> --> </configuration> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin>
  • #33: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>analyze</id> <phase>verify</phase> <goals> <goal>analyze-only</goal> </goals> <configuration> <failOnWarning>true</failOnWarning> </configuration> </execution> </executions> </plugin>
  • #34: http://mojo.codehaus.org/selenium-maven-plugin/ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>selenium-maven-plugin</artifactId> <version>2.3</version> <executions> <execution> <phase>pre-integration-test</phase> <goals> <goal>start-server</goal> </goals> <configuration> <background>true</background> </configuration> </execution> </executions> </plugin>
  • #37: For Spring apps use onejar-maven-plugin <plugin> <groupId>com.jolira</groupId> <artifactId>onejar-maven-plugin</artifactId> <version>1.4.4</version> <executions> <execution> <configuration> <mainClass>com.package.core.Main</mainClass> <!-- Optional, default is false --> <attachToBuild>true</attachToBuild> <!-- Optional, default is "one jar" --> <classifier>onejar</classifier> </configuration> <goals> <goal>one-jar</goal> </goals> </execution> </executions> </plugin>
  • #38: For Spring apps use onejar-maven-plugin <plugin> <groupId>com.jolira</groupId> <artifactId>onejar-maven-plugin</artifactId> <version>1.4.4</version> <executions> <execution> <configuration> <mainClass>com.package.core.Main</mainClass> <!-- Optional, default is false --> <attachToBuild>true</attachToBuild> <!-- Optional, default is "one jar" --> <classifier>onejar</classifier> </configuration> <goals> <goal>one-jar</goal> </goals> </execution> </executions> </plugin> http://onejar-maven-plugin.googlecode.com/svn/mavensite/usage.html
  • #39: <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>org.akceptor.Main</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>
  • #40: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.7.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> </execution> </executions> <configuration> <finalName>${project.artifactId}</finalName> <outputDirectory> ${project.build.directory}/${project.artifactId}/bin </outputDirectory> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>org.akceptor.Main</mainClass> </transformer> </transformers> </configuration> </plugin> http://maven.apache.org/plugins/maven-shade-plugin/
  • #41: http://maven.apache.org/guides/mini/guide-configuring-plugins.html