Maven - Project

Card Puncher Data Processing

About

A project in the Maven sense contains all little pieces that come into play to give code life. Ie:

  • configuration files,
  • the developers involved and the roles they play,
  • the defect tracking system,
  • the organization and licenses,
  • the URL of where the project lives,

Management

Id

The (primary key|coordinate) of a specific project in time is represented by:

Create

  • create a directory
  • On the command line of you shell, execute the following Maven goal:
mvn archetype:generate \
  -DarchetypeArtifactId=maven-archetype-quickstart \
  -DgroupId=com.gerardnico.app \
  -DartifactId=my-app \
  -DinteractiveMode=false

where:

It will create a standard project structure.

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] [archetype:generate {execution: default-cli}]
[INFO] Generating project in Batch mode
Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.
0/maven-archetype-quickstart-1.0.jar
4K downloaded  (maven-archetype-quickstart-1.0.jar)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.
0/maven-archetype-quickstart-1.0.pom
703b downloaded  (maven-archetype-quickstart-1.0.pom)
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-qui
ckstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.mycompany.app
[INFO] Parameter: packageName, Value: com.mycompany.app
[INFO] Parameter: package, Value: com.mycompany.app
[INFO] Parameter: artifactId, Value: my-app
[INFO] Parameter: basedir, Value: C:\temp\myproject
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:\temp\myproject\my-app
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Sat Apr 13 16:38:38 CEST 2013
[INFO] Final Memory: 25M/349M
[INFO] ------------------------------------------------------------------------

Build

mvn package

where:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app
[INFO]    task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\temp\myproject\my-app\src\main\resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\temp\myproject\my-app\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: C:\temp\myproject\my-app\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.mycompany.app.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.031 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] [jar:jar {execution: default-jar}]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Sat Apr 13 16:43:33 CEST 2013
[INFO] Final Memory: 12M/213M
[INFO] ------------------------------------------------------------------------

Test

my-app>java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
Hello World!

Documentation / Reference





Discover More
Card Puncher Data Processing
Maven

is a build tool. It is declarative build tool whereas ant is a procedural build tool. You can then change the build process by changing the process not the declaration. Most of the project declaration...
Card Puncher Data Processing
Maven - Artifact - (Component|Module|Library)

in Maven. An Artifact is the data storage unit of a repository. It's at the same time: the distribution unit to distribute and the dependency unit to use (Ie artifacts can be transferred to...
Card Puncher Data Processing
Maven - Configuration Files (Pom, Settings, Profiles, )

Maven configuration occurs at differents levels: Project - The pom.xml file is the core of a project's configuration in Maven. User - this is configuration specific to a particular user: (%USER_HOME%/.m2/settings.xml)...
Card Puncher Data Processing
Maven - GroupId

GroupId is the first coordinate of an artifact that indicates the unique identifier of the organization or group that created the project. It's the Maven jargon for the package name. org.apache.maven.plugins...
Idea Maven Module
Maven - Module

module management in Maven. A multi-module project is defined by a parent POM referencing one or more sub-modules. The mechanism in Maven that handles multi-module projects is referred to as the reactor....
Card Puncher Data Processing
Maven - pom.xml - Project Object Model

pom.xml is an XML representation of a Maven project known also as the project descriptor. It is ultimately a project declaration. Where as a build.xml tells ant precisely what to do when it is run (procedural),...
Card Puncher Data Processing
What are Java Coordinates?

The following attributes identifies uniquely an artifact (har,war,zip,...): groupid - the organisation artifactId - the software name version - the version classifier (source, doc, ...) packaging...



Share this page:
Follow us:
Task Runner