Just some brief notes and pointers regarding maven. This is not maven tutorial. This is just intended to help you recollect what you already know and build some more clarity on it.
POM - Project Object Model is expressed in pom.xml file. Object oriented representation of projects. Declarative instead of procedural.
Build lifecycle has following stages: validate, compile, test, package, verify, install and deploy.
Ultimately you want to express the dependency tree and specify actions for specific goals.
You can have a single POM file (in simple project) or collection of directories with their own POM files. Each POM file represents a Project. POM files can inherit from another. POM files inheritance form a tree structure (not graph). But implicit dependencies between projects is a graph.
A project can aggregate multiple component sub-projects called modules in pom.xml
Each POM file associated with packaging type which is any one of following:
- POM (just plain POM file only)
- jar is the default. It implicitly immediately defines implementation for goals in various default lifecycles.
- Other goals are war and ear
- maven-plugin packaging type is used to bundle implementation for custom goal (like compile, install, etc)
- You can define your own packaging type, but usually you will never need to do that. See http://stackoverflow.com/questions/1427722/how-do-i-create-a-new-packaging-type-for-maven
Defining your own goal involves writing maven plugin (Mojo) which is packaged as maven-plugin.
Note
Note that packaging type just defines the implicit semantics for relevant goals in lifecycles. Depending on the goal, the relevant actions from relevant project POM files get executed. That's why this POM model it is Declarative and not Procedural.
For creating destination jar file it uses project artifactId, etc for target file name. You can customize it though using <finalName> property. If you want to generate 2 separate Jar files from single project, you need to use maven-assembly-plugin.
mvn groupId:artifactId:goal -P profile-1,profile-2 mvn compile -P myDebugEnv
Define as <activeProfiles> in POM xml file itself or in
Define <activation> condition in POM xml e.g. when provided jdk version is 1.6 or os is Windows. or when a specific file is missing or present. etc.