Saturday, 7 April 2018

maven

1. lifecycle
  • clean
  • default
  • site
  • packaging of project: if no <packaging> value found, jar is used.

2. phase
  • clean (3)
  • default (21)
  • site (4)
  • 'mvn install' will execute all phases preceding 'install'

3. phase and plugin:goal
  • phase rely on plugin:goal to carryout the task
  • default binding between phase and goal exist:  test | surefire:test
  • 'mvn test' will execute default plugin/goal, i.e. 'mvn surefire:test'
  • plugin/goal can be executed outside of phase, e.g. 'mvn clean dependency:copy-dependencies package'
  • when execute maven you can specify 'phase' or 'goal'
  • if you specify 'phase', it will run all phases up till the specified phase, and it will run all goals attached to each phase
  • if you specify a 'goal', it will run all phases up till the phase for the goal, then it will run that goal
  • mvn-plugins-package-goal

4. mvn profile
  • use profile to customize build for different env
  • use 'mvn -P' option in command line to activate profile
  • profile can also be activated based on OS variable or jdk version

5. mvn command
  • mvn clean //remove target dir
  • mvn test //execute unit test
  • mvn install //install artifact to local repository
  • mvn install -DskipTests //skip test

6. maven surefire and failsafe plugin
  • surefire plugin is used in 'test' phase, it's designed to run unit tests and if any of the tests fail then it will fail the build immediately
  • surefire plugin has one goal: 'test'
  • failsafe plugin is used in 'integration-tests' and 'verify' phase, it's designed to run integration tests, and do not fail the build if there are test failures
  • failsafe plugin has two goals: 'integration-test' runs the integration tests of an application; 'verify' verifies that the integration tests of an application passed

7. parallel/fork
  • run junit in parallel two options

reference

No comments:

Post a Comment