Showing posts with label Maven. Show all posts
Showing posts with label Maven. Show all posts

Convert Java project to Maven project

Installing m2eclipse
(Just so you know, STS comes with this plugin already, whew!)
Select Java project, right click, maven->Enable Dependency Management.

Or you could New->Maven->Maven POM File

To create a new Maven project

New->Maven->Maven Project
You could choose which archetype you want to generate, there a lot of them!!!!

You could also run maven command in Eclipse, by using Run as, Maven Build, you could specify your goal.

Maven Archetype Plugin

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

mvn archetype:create-from-project

Maven Lifecycle References

http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference

Maven in 5 minutes

http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

Create maven-driven project in one command:

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

All plugins in Maven 2.0 look much like a dependency - and in some ways they are. This plugin will be automatically downloaded and used - including a specific version if you request it (the default is to use the latest available).

Take a look at STS's "Effective POM" view, you can understand what plugin, phase, and goal.

You must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal

mvn test-compile
mvn:compiler:testCompile
mvn org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile

Maven Setting Up

1. download the zip, unzip it into some folder, let's say C:\Applications\apache-maven-3.0.3
2. setting up variables
M2_HOME=C:\Applications\apache-maven-3.0.3
put %M2_HOME% into PATH
M2_REPO=C:\Users\Paul\.m2\repository
3. mvn -v   should work now.
4. to make sure a project maven compatible, use mvn eclipse:eclipse
5. in Eclipse, you need setup M2_REPO variable
select Window > Preferences. Select the Java > Build Path > Classpath Variables page.