Hello World from OSS Silicon Valley


HowToUse/Maven/3.2

_ Install&Setup

_ Command Line

Prerequisite
Step.1
Download Maven from http://maven.apache.org/download.cgi and unzip it.

(In case download file is tar ball)

$ tar xzvf <download file>
Step.2
Set path. (In case you are using Windows)
ItemDescriptionExample
MAVEN_HOMEMaven Home path"C:\apache-maven-3.2.2"
PathMaven executable path"%MAVEN_HOME%\bin"
The setting of "MAVEN_HOME" is not mandatory. Just I prefer to set "HOME" variable to manage multiple versions' path.
Step.3
Confirm if the maven works
$ mvn --version
Install_fig1.png

_ Eclipse Plugin

(If you installed Eclipse for Java EE, Maven plugin, m2e is installed by default. Here, I use Eclipse 4.3 (Kepler) for explanation.)

Step.1
Launch eclipse.
Step.2
Choose "Help" -> "About Eclipse" and check if the plugin for Maven (m2e) has already been installed. If the icon for m2e is shown up, you have plugin.
Install_fig3.png
Step.3
Choose "Help" -> "Install New Software" and click "add" button.
Install_fig2.png
Step.4
Enter the name and location of plugin.
ParameterValueExample
NameName for plugin"m2e"
LocationThe location of plugin"http://download.eclipse.org/technology/m2e/releases "
Install_fig4.png
Step.5
Check the install item and click "next" button.
Install_fig5.png
Install_fig6.png

_ HowToUse

_ Simple Case

Step.1
Create a new project.
$ mvn archetype:create \
  -DgroupId=<Group ID> \
  -DartifactId=<Artifact ID>
ArgumentDescriptionExample
archetypeArcheType"create"
group IDJava Package name"org.apache"
artifact IDProject name for Maven"project1"
SimpleCase_fig1.png
Step.2
Launch eclipse and choose "File" -> "Import". Select "Existing Maven Project" and click "Next" button.
SimpleCase_fig4.png
Step.3
Click "Browze" button.
SimpleCase_fig5.png
Step.4
Select Maven project folder we have created.
SimpleCase_fig6.png
Step.5
pom.xml in the folder will be recognized. Click "finish" button.
SimpleCase_fig7.png
SimpleCase_fig8.png
Step.6
Double click the pom.xml and edit it as needed. If you append "dependency" block, maven download correspondent library from maven repository and link the source code in the project.
SimpleCase_fig9.png

(Example: Selenium plugin)

<dependency>
	<groupId>org.seleniumhq.selenium</groupId>
	<artifactId>selenium-java</artifactId>
	<version>LATEST</version>
</dependency>

(MySQL Connector)

<dependency>
	<groupId>mysql</groupId>
	<artifactId>mysql-connector-java</artifactId>
	<version>5.1.28</version>
</dependency>

(Log4J)

<dependency>
	<groupId>log4j</groupId>
	<artifactId>log4j</artifactId>
	<version>1.2.15</version>
</dependency>
Step.7
Create test code.
Step.8
Compile project
$ mvn compile
SimpleCase_fig2.png
Step.9
Execute Test Code (Command line)
$ mvn test
SimpleCase_fig3.png

(Eclipse) Choose "Run" -> "Run As" -> "maven test"

_ JavaEE project

(TBD)

_ Author

S.Yatsuzuka

Last-modified: 2015-08-17 (Mon) 02:41:34 (3167d)