Sprig Maven
- Maven is a project management tool
- ANT is also a build tool which is similar to Maven and it is a default build tool in Intellij IDEA,Netbeans,Eclips
- Replace the build tool to maven.
- Maven has a common folder structure.Hence any developer can easily identify the project.
- Maven can create documentation by checking the source code of the project.Hence source code should be correctly formatted.
- Source code read by doc comments
- Maven is a collection of dependency management tool and document development tool
- All the dependencies are download into the home directory as common repository not for each project.
- Plugins are created by set of goals.
- Maven is created by set of pulgins.
- Create a Project : mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.mycompany.app -DartifactId=my-app 
- Execute a goal : mvn : - EX : mvn compiler : compile
 
- Maven life Cycle
- Clean(clear all created artifacts and rebuild the project)
- Default(create project)
- Site(Use to create websites)
 
- can compile one or more life cycles together.("mvn clean defualt site")
- Life cycles have one or more phases.
- Clean
- pre-clean
- post-clean
- clean
 
- Default
- validate (check folder structure)
- compile (compile the code)
- test (compile test cases)
- package (build artifacts)
- verify (check integration tests)
- install (install project as a dependency in a local repository)
- deploy (send the project to the remote repository from local rep)
 
- Site
- pre-site
- post-site
- site
- site deploy
 
- Phase is created by set of goals from different set of plugins.
- Archetype is a project template in maven.
- Examples for archetypes : 
- maven-archetype-quickstart
- maven-archetype-webapp
 
- Project structure
- POM (Project Object Model)
- ‘pom.xml’ contains the Project Object Model for the project
- POM contains every important piece of information about the project.
 com.mycompany.app my-app jar 1.0-SNAPSHOT Maven Quick Start Archetype 
- Generate IDE specific project descriptor
 mvn idea:idea mvn eclipse:eclipse
 
 
- type
 Packaging type of the project (jar, war, ear)
- version
 Version of the project. “SNAPSHOT”: A beta version in changing phase Downloaded when a maven phase is executed in a timely manner
- optional
 Marks as optional when the project itself is a dependency./li>
- scope
 Classpath of the task (compiling, runtime or test execution) Different scopes are as following.
 - “compile”
 Default scope. Dependencies are available in all classpaths. Propagated to dependent projects
- “test”
 Only available for test compilation and execution. These are not transitive
- “provided”
 Expect the JDK or the container to provide at runtime.
- “runtime”
 Not needed for compilation but for runtime and test execution.
- “system”
 Similar to provided but need to specify the JAR file.
 
 
 
 
- “compile”
- systemPath
 Used when dependency scope is system. Example: ${java.home}/lib
- Used to set the manifest for the JAR file.
- Can contain a project with multiple modules.
- Dependency modules are always build before dependent modules.
- Have to mention the parent information in the sub module
- All project resources are maintained in separate resource directories
inside main.
 src -> main -> resources
 src -> test -> resources
- Most of the times, property files which contain application configuration are stored in these locations.
- Can also be explicitly mentioned also in the resources section of the POM.


 
Comments
Post a Comment