Wednesday, May 29, 2019

Basic Usage of Maven in Eclipse
What is Maven?

Maven project lifecycles
Maven repositories
Start a new Maven project in Eclipse

What is Maven?


Project management tool which encompasses project object module (pom.xml), project lifecycle, dependency management, and plugin execution logic
- Maven, the Complete Reference
Maven as build tool
§ Dependency management which includes dependency inheritance
§ Accessing remote repositories
§ Build logic reuse with plugins
§ Produces deployable artifacts




Maven project lifecycles


Maven has three default lifecycles: clean, default, site
§ clean – project cleaning
   § default – project deployment
          § site – creates project’s site documentation
All lifecycles have numerous phases
          § Each phase of a lifecycle is defined by one or more plugins and goals
               q Building custom Maven plugins is possible, beyond scope of this training
          § User defines phase to which Maven runs; Maven executes all phases to that point.




Maven repositories

Local repository:  ${user.dir}/.m2/repository
§ Configured in and collocated with ${user.dir}/.m2/settings.xml
§ Can also be set in Super pom and individual project pom’s
Remote repository:  Currently set by default to https://repo.maven.apache.org/maven2
§ Can be configured in ${user.dir}/.m2/settings.xml
q Will set repository location for all locally-built Maven projects.
q Most ideal place to set remote repository.  
To ensure that your newly installed Java jar is a available as a Maven dependency, build your local index . . .


Start a new Maven project in Eclipse

1. Create new project:  File > New (> Other…) > Maven Project
2. Choose a archetype or not
  § Archetypes are prototypes from which to begin Maven projects
             q Possible to build custom archetypes, beyond the scope of the project
3. Choose a group Id, artifact Id, version number, description
File structure
§ /src/main/java
§ /src/main/resources
§ /src/test/java
§ /src/test/resources
§ Maven repository
§ Target folder
§ pom.xml








No comments:

Post a Comment