maven is life-cycle based project build, deploy and management tools.After you download and install maven from Apache site, you use mvn plus option commands to manage your projects. In fact, following code is executed in linux system.
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "${M2_HOME}"/boot/plexus-classworlds-*.jar \
"-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
"-Dmaven.home=${M2_HOME}" \
${CLASSWORLDS_LAUNCHER} "$@"
In maven, plexus project from codehaus is depended library. maven makes use of plexus's class-loader and XML parser tools.According to m2.conf, plexus class-world launches org.apache.maven.cli.MavenCli to do the whole work.
main is org.apache.maven.cli.MavenCli from plexus.core
set maven.home default ${user.home}/m2
[plexus.core]
optionally ${maven.home}/lib/ext/*.jar
load ${maven.home}/lib/*.jar
MavenCli is an important class as it is the entry point for maven world. This class takes advantage of Apache common command line package and parse the argument from $@ into CommandLine object.
public class MavenCli {
public static int main( String [] args, ClassWorld classWorld ){
CLIManager cliManager = new CLIManager();
CommandLine commandLine;
commandLine = cliManager.parse( args );
}
}
After that, setting related to build are build up and MavenExecutionRequest and Maven instance are created. MavenExecutionRequest object is common java bean or JOPO which holds the information about the project like pom file name, ArtifactRepository, Goals and etc. class Maven is the man who carries out the build work further.
maven = createMavenInstance( settings.isInteractiveMode() );
maven.execute( request );
Maven class is glanced as below and some features are worthy of being highlighted.
- Register EventDispatcher and Monitor;
- Parse pom XML file using org.codehaus.plexus.util.xml.Xpp3Dom;
- Use data from pom XML file to fill into Project and Model,Repository, Extension, Plugin objects;
- Loop each project and call DefaultLifecycleExecutor to run each project.
List projects = getProjects( request, globalProfileManager );
rm = new ReactorManager( projects );
MavenSession session = createSession( request, rm );
session.setUsingPOMsFromFilesystem( foundProjects );
lifecycleExecutor.execute( session, rm, dispatcher );