Saturday, September 12, 2015
Maven in short
1. Dependency management - can download the transitive dependencies (dependencies of a dependency and this can be infinitely transitive)
2. The main phases in maven lifecycle are:
a. Clean - will clean the target directory
3. A plugin is bound to a lifecycle phase - for example, compiler plugin is bound to compile phase.
4. We can either execute the mvn <phase-name> or mvn <plugin-name>:<goal-name> for example, mvn compile and mvn compiler:compile do the same thing but when we execute mvn compile any other plugin we have bound to compile phase willl be executed too (together with compiler plugin's compile goal).
5. Maven POM is hierarchical - a project's POM is always inheriting from the base maven's super POM (that comes as part of maven). To see this, execute: mvn help:effective-pom and this will show the plugins that are already part of the super POM we are inheriting from.
6. Within the project too, we can build a hierarchy of POM files. We use the <modules> element to define the sub-modules (which have their own POM files) in the parent module/directory.
In parent pom.xml:
<module>server</module> -- this will build server/pom.xml
7. All plugins are listed at - http://maven.apache.org/plugins/index.html
8. Maven central repo is - http://search.maven.org/
9. Some important plugins:
b. Jar - mvn package (this is phase and jar plugin in bound to package phase) or run explicitly as mvn jar:jar.
ii. -Djar.forceCreation=true - jar created every time.
d. Install - packages and puts the archive in local maven repo so other modules/projects can refer to it.
e. Deploy - deploys to remote maven repo (the remote repo configuration is provided in pom.xml in <distributionManagement> element). This repo could be in cloud (running artifactory server for eg.)
f. Surefire - only one goal (test).
g. War - to package web application
10. Archetype - to create a project based on an archetype (or template for a project). We can create our own complex setup archetype and make it available as a template for new projects in an organization.
a. Mvn archetype:create-from-project - used to create a new archetype based on existing project. All source files which were there in the original project will be present in the new projects created from that archetype.
b. Mvn archetype:generate - to create a new project
11. Some commands:
a. mvn archetype:generate (format is <plugin>:<goal>) - used to generate skeleton for new project.
b. mvn idea:idea or eclipse:eclipse -- to generate project in IDE specific way (run it after archetype:generate)
c. Mvn help:describe -Dcmd=compiler:compile -Ddetail - to see what properties are available for compiler plugin (properties like maven.compiler.verbose)
d. Mvn compiler:compile -Dmaven.compiler.verbose=true -- to debug what is going during compilation
e. Mvn -help
f. Mvn -v
g. Mvn <plugin-name>:help (eg. Mvn compiler:help)
h. Mvn -q compile (quite mode - tidys the o/p)
i. Mvn -X -- gives verbose/debug o/p
The Sign of Four by Arthur Conan Doyle My rating: 5 of 5 stars It is the second Sherlock Holmes book after "A Study in Scarlet&quo...
I hit this issue recently which occurred on only one windows 7 host. The error was caused by this hard to guess reason ( http://support.mic...
Following are the steps to create NPIV port on an adapter (only tested with Brocade HBAs) on a host with VMware vSphere ESX/ESXi hypervisor...
At times, you may have wanted to perform some action periodically in your web application. Quartz is an enterprise grade scheduler which can...