Skip to content

Instantly share code, notes, and snippets.

@ericxyan
Last active April 29, 2016 07:00
Show Gist options
  • Save ericxyan/c73254671ddfa68854c525d9f8a59d68 to your computer and use it in GitHub Desktop.
Save ericxyan/c73254671ddfa68854c525d9f8a59d68 to your computer and use it in GitHub Desktop.

Maven

  • POM(Project Object Model):
  • pom.xml:
    • Maven project structure and contents are declared in an pom.xml file.
    • Resides in the base directory of the project
    • mandatory fields: groupId, artifactId, version
      <project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         http://maven.apache.org/xsd/maven-4.0.0.xsd">
         <modelVersion>4.0.0</modelVersion>
         <groupId>com.companyname.project-group</groupId>
         <artifactId>project</artifactId>
         <version>1.0</version>
      </project>
      
  • Projects notation in repository is groupId:artifactId:version
  • Super POM: ALL POMs inherit from a parent
  • effective pom: configuration from super pom plus project configuration
  • check default configurations of super POM: mvn help:effective-pom

What is Build Lifecycle?

A Build Lifecycle is a well defined sequence of phases.
A phase represents a stage in life cycle.
A goal represents a specific task.
Three standard lifecycles: clean, default/build, site
mvn clean dependency:copy-dependencies package
Executing order: phase clean --> goal dependency:copy-dependencies --> phase package

Clean Lifecycle

  • clean:clean goal is bound to the clean phase in the clean lifecycle. It deletes build directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment