Mar 8, 2018 11:02:58 AM seb leridon avatar   1739

Using lutece Maven plugin


Introduction


Maven Logo The development under Lutece, including the construction and assembly of components, is based on the Apache Maven tool (http://maven.apache.org). The very large modularity of Lutece necessarily generates a complexity related to the assembly of components and the management of dependencies. This complexity is managed by the model proposed by Maven through the Project Object Model . In order to make the most of this tool, a specific plugin for Lutece has been created to handle complex construction and assembly tasks.

The Lutece plugin for Maven


This Maven plugin is used to frame the development and distribution tasks of Lutèce and its plugins. It also allows to prepare websites by "assembling" a version of the Lutèce kernel and a number of plugins.

The goals


The Lutece plugin for Maven introduces the following goals :

Name Description
lutece:clean delete the build directory of the project.
lutece:exploded prepares a test webapp for a Lutece project or plugin project.
lutece:package package an artifact "Lutece core" or "Lutece plugin".
lutece:assembly generates the source and binary distributions for a "Lutece core" or "Lutece plugin" project.
lutece:site-assembly generates the binary distribution for a Lutece site project

Development and testing of a plugin


Manual tests

To manually test your plugin in an environment containing the Core webapp, call the goal lutece:exploded

mvn lutece:exploded

This will:

  • recover the lutece-core artifact from the Maven repository;
  • install and prepare the version of the core in target / lutece;
  • copy plugin-specific components to this prepared directory;
  • copy all the specified configuration files (see this page).

Following this process, target / lutece contains an instance of Lutece with your plugin installed. You can configure the Tomcat context on this directory to start testing.

Automatic unit tests

To automatically test the plugin (unit test), you can use the following command:

mvn lutece:exploded antrun:run test

This will:

  • start with the operations described in the previous step (manual test).
  • erase and reset a database.
  • run unit tests with maven.

Note: unit tests are performed using a default database: a mysql server on localhost, base "lutece", user "lutece", no password. You must either make this configuration work, or write another configuration in the file "$HOME/lutece/conf/<ARTIFACT_ID>/WEB-INF/conf/db.properties", where ARTIFACT_ID is the value of the pom file .xml (example: "lutece-core" for the lutece-core project, "plugin-document" for the plugin-document project, etc.). For example, the following file allows you to use an embedded hsqldb database:

portal.poolservice=fr.paris.lutece.util.pool.service.LuteceConnectionService
portal.driver = org.hsqldb.jdbcDriver
portal.url = jdbc:hsqldb:file:target/LUTECE;shutdown=true
portal.user = sa
portal.password =
portal.initconns = 2
portal.maxconns = 5
portal.logintimeout = 2,000
portal.checkvalidconnectionsql = SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS

Creation of distribution


Generating a plugin distribution

mvn lutece:assembly

This command will generate two archives:

  • a ZIP containing the sources of the plugin
  • a ZIP containing a binary version of the plugin that can be pasted on an existing webapp (the plugin must be activated in the administration interface)

Generation of a distribution of the Core

mvn lutece:assembly

This command will generate two archives:

  • a ZIP containing the sources of the core
  • a ZIP containing:
  • a WAR file, a webapp core, minimal, ready to be deployed and can be used as a basis for the deployment of plugins (which must be activated in the administration interface).
  • the initialization files of the database

Note In the case of a webapp intended to exploit several plugins, it is advisable to create a Lutece site.

Multi-project mode

As for the Lutèce plugins, the multi project Lutèce provides a local deployment goal:

mvn lutece:exploded -P multi-project

This will:

  • install and prepare the core in target / lutece of the multi project;
  • install and prepare each plugin in target / lutece of the multi project;
  • copy all the specified configuration files (see this page).

Following this process, target / lutece of the multi project contains an instance of Lutece with the core and all the plugins installed. You can configure the Tomcat context on this directory to start testing.

To be able to erase and redeploy a multi project in one command, Unlike a classic project you can not use the following command sequence:

mvn clean lutece:exploded -P multi-project

Because this sequence, deploys all the modules and ends up erasing the target directory of the multiproject. We use the following command sequence:

mvn lutece:clean lutece:exploded -P multi-project

In order to avoid recompiling and redeploying all the modules of the multiproject, it is possible to do this on only one module. To do this, place it directly in the module directory at its pom.xml and run the following command:

  • for plugins:
mvn lutece:exploded -DtestWebappDirectory = "../../target/lutece"
  • for the Core:
mvn lutece:exploded -DtestWebappDirectory = "../target/lutece"

Other useful Maven commands

Maven projects (including Lutece) can have a hierarchical structure of pom.xml files. The following command shows the entire pom.xml (effective pom).

help:effective-pom

Remove the project dependencies from the local repository, and optionally re-resolve them.

dependency:purge-local-repository

The following command shows the different dependencies between the packages:

mvn dependency:tree -Dverbose

To parse dependencies on the org.apache.geronimo.specs package: geronimo-stax-api_1.0_spec for example:

mvn dependency:tree -Dverbose -Dincludes=org.apache.geronimo.specs:geronimo-stax-api_1.0_spec

Generate the doc without the reports (faster and do not try to connect to svn)

mvn site -DgenerateReports=false -Dmaven.test.skip=true

Note more memory needs to be allocated to Maven to generate reports via the env variable MAVEN_OPTS = -Xmx1024m