wiki:PLATFORM_DEPLOYMENT_BUILD_MAVEN
Last modified 11 years ago Last modified on 02/10/09 15:07:05

Platform Deployment Build with Maven

If you don't have Maven installed on your machine yet, use PLATFORM_INFRASTRUCTURE_OVERVIEW

Commands

The syntax for running Maven commands is mvn [profile] [command] [parameters]. They have to be executed in the console in sophie2-platform (in the repository) directory or in the module you want to command (again in its directory). The basic of them are:

  • validate: validate the project is correct and all necessary information is available
  • compile: compile the source code of the project
  • test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
  • package: take the compiled code and package it in its distributable format, such as a JAR.
  • integration-test: process and deploy the package if necessary into an environment where integration tests can be run
  • verify: run any checks to verify the package is valid and meets quality criteria
  • install: install the package into the local repository, for use as a dependency in other projects locally
  • deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
  • clean: cleans up artifacts created by prior builds
  • site: generates site documentation for this project

If you want to skip the tests in the project while building and don't need their results(or the resulted test reports), add '-Dmaven.test.skip=true' in the end of the command you execute.

Maven 2 introduces the concept of a build profile. Profiles are specified using a subset of the elements available in the POM itself (plus one extra section), and are triggered in any of a variety of ways. They modify the POM at build time, and are meant to be used in complementary sets to give equivalent-but-different parameters for a set of target environments. We have two profile sections defined in our project and they are:

  • hudson profile - used for hudson build server (sophie2.org:8080) to generate various reports and their needed maven goals(on this time only the cobertura report is generated using this profile)
  • jspcompile - used for compiling the jsp, used by Sophie 2 server. The command is 'mvn -Djspcompile [maven-goal]' -Dmaven.test.skip=true. See S2S_TESTING_SERVER_R0 for more information.

Note: Maybe you will have memory problems executing some of the commands for example mvn site. One of the solutions is to set the MAVEN_OPTS variable to -Xmx1024m -XX:MaxPermSize=386m -Xss16m

Eclipse

You can execute Maven commands over the project in Eclipse right-clicking on the pom.xml file in the parent project or in the module you want to command. Select Run As and choose the desired command.
There is 'Maven build...' option where you can add the goals, profiles and parameters you want to execute with 'mvn' command.
Note: Do not forget to update Maven dependencies and Update Project Configuration when needed.

Reports

To generate the reports you want you should add the report plug-ins you need into the reporting section at the end of the pom.xml file. For example this code in the base pom.xml installs the maven-javadoc-plugin and generate javadoc reports using the variables in the configuration section while executing 'mvn site' command:

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-javadoc-plugin</artifactId>
	   <configuration>
		<sourcepath>${basedir}/src/main/java</sourcepath>
		<javadocVersion>1.5</javadocVersion>
		<fork>true</fork>
		<failOnError>false</failOnError>					
	</configuration>
   </plugin> 

See http://docs.codehaus.org/display/MAVENUSER/Reporting+Plugins to get into.

The automatic generated reports are:

  • CPD Report: Duplicate code detection.
  • Checkstyle: Report on coding style conventions.
  • FindBugs Report: Generates a source code report with the FindBugs Library.
  • JavaDocs: JavaDoc API documentation.
  • Maven Surefire Report: Report on the test results of the project.
  • PMD Report: Verification of coding rules.
  • Source Xref: HTML based, cross-reference version of Java source code.
  • Dependancies Report: Dependency manipulation (copy, unpack) and analysis.
  • Mailing Lists Report: Information about our mailing lists.
  • Project Team report: The developing team.
  • Project License report: The license of the project.

Here is some documentation for these plug-ins: http://shale.apache.org/shale-apps/shale-mailreader/maven-reports.html

Use 'mvn site' command to generate the reports added in 'reporting' section in pom.xml file. The generated reports goes in [modulename]/target/site in our repository.

Comments

  • When you execute 'mvn assembly:directory' command MAVEN_OPTS have to be set to '-Xmx768m -XX:MaxPermSize=386m -Xss8m' value