This step will install and use Maven to build a simple Java project to ensure that the tool is configured appropriately. The first time it runs, it will cache many Jars from Central into a folder ${user.home}/.m2/repository
; for subsequent runs, it will be much faster.
zip
(Windows) or Maven tgz
(for macOS/Linux).MAVEN_HOME
.MAVEN_HOME/bin
to the PATH
or specify the full path to the Maven executable; run mvn –version
, and a version message should be printed out. Maven requires a JDK (not just a JRE), which should be installed by following the instructions from the Java site.mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.1
(all on one line) to create a new Maven project.groupId
, enter com.packtpub.e4
.artifactId
, enter com.packtpub.e4.tycho
.1.0-SNAPSHOT
and com.packtpub.e4
respectively.Define value for property 'groupId': com.packtpub.e4 Define value for property 'artifactId': com.packtpub.e4.tycho Define value for property 'version': 1.0-SNAPSHOT Define value for property 'package': com.packtpub.e4 Confirm properties configuration: groupId: com.packtpub.e4 artifactId: com.packtpub.e4.tycho version: 1.0-SNAPSHOT package: com.packtpub.e4 Y: : Y
com.packtpub.e4.tycho
directory created and run mvn package
to run the tests and create the package:[INFO] Scanning for projects... [INFO] [INFO] Building com.packtpub.e4.tycho 1.0-SNAPSHOT[INFO] T E S T S Running com.packtpub.e4.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] Building jar: com.packtpub.e4.tycho-1.0-SNAPSHOT.jar [INFO] [INFO] BUILD SUCCESS [INFO] [INFO] Total time: 1.977s [INFO] Final Memory: 15M/136M
The Maven launcher knows how to connect to the Central repository and download additional plug-ins. When it initially launches, it will download a set of plug-ins, which in turn have dependencies on other Jars that will be resolved automatically prior to the project building.
Fortunately, these are cached in the local Maven repository (which defaults to ${user.home}/.m2/repository
), so this is done only once. The repository can be cleaned or removed; the next time Maven runs, it will download any required plug-ins again.
When mvn archetype:generate
is executed, a sample Java project is created. This creates a pom.xml
file with the groupId
, artifactId
and version
given and sets it up for a Java project.
When mvn package
is executed, the operation depends on the packaging type of the project. This will default to jar
if not specified, and the default package
operation for jar
is to run the compile
, then run test
, and finally create the Jar file of the package.
The Maven quickstart
archetype is a useful way of creating a pom.xml
file with known good values, and a way of verifying connectivity to the outside before moving ahead with the Eclipse-specific Tycho builds. If there's a problem with these steps, check out the troubleshooting guides at http://maven.apache.org/users/ for assistance.
18.222.35.21