h1. Integrating Content Validation into DMS

h1. 1.Current situation

We now need to propose two products to our customers:

    * DMS. It contains a set of Portlets and services aimed at managing documents in the JCR.
    * Workflow. It contains a set of Portlets and services aimed at managing and interfacing with business processes engines.
      These products are not coupled and have to be generated separately.


Optionally, we have to provide content validation option on top of DMS. We cannot do that by default, for royalties reasons. When this option is turned on, we need to merge Workflow into DMS and also add a set of services and business processes to the packaging.


In SVN, this was implemented the following way:
{code}
ecm
|___dms/
|___workflow/
|___content-validation/
{code}
content-validation was detached for two reasons:

    * it looked easier to manage separately permissions for differentiating customers who bought a subscription for DMS and those who bought the content-validation option.
    * if we put content-validation inside DMS package, then we thought we had to create a link from DMS to Workflow, which is not wished.




h1. 2.The problem


We now have a content-validation entry in SVN, which has "trunk", "tags" and "branches". This means it should be considered as a plain project, with a dedicated lifecycle and a JIRA project. The granularity is not well appropriated for that.

h1. 3.The solution
We are integrate content-validation inside DMS, which sounds more consistent by using Maven profile:

{code}
ecm
|___dms/
|     |___trunk/
|              |___ core/[Current DMS code goes here]
|              |___ ext/content-validation/
|___workflow/
{code}

So, in DMS we edit *dms/trunk/pom.xml* to build *dms/trunk/core* by default:

{code}
<project>

  <parent>
    <groupId>org.exoplatform</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>org.exoplatform.ecm</groupId>
  <artifactId>dms</artifactId>
  <name>eXo DMS Config</name>
  <version>2.3-SNAPSHOT</version>
  <packaging>pom</packaging>

  <modules>
    <module>core</module>
  </modules>
  ...
{code}

 And for using maven profile to build content validation, we declare in this *pom.xml* file:

{code}
<profiles>
    <profile>
      <id>default</id>
      <activation>
        <property><name>default</name></property>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <org.exoplatform.kernel.version>2.0.6</org.exoplatform.kernel.version>
        <org.exoplatform.core.version>2.1.4</org.exoplatform.core.version>
        <org.exoplatform.jcr.version>1.10.2</org.exoplatform.jcr.version>
        <org.exoplatform.ws.version>1.3.2</org.exoplatform.ws.version>
        <org.exoplatform.pc.version>2.0.4</org.exoplatform.pc.version>
        <org.exoplatform.portal.version>2.5.2</org.exoplatform.portal.version>
        <org.exoplatform.ecm.dms.version>2.3-SNAPSHOT</org.exoplatform.ecm.dms.version>
		<exo.test.classes>Test</exo.test.classes>
        <exo.test.skip>true</exo.test.skip>
        <bonita.version>3.0</bonita.version>
      </properties>
    </profile>
	<profile>
            <id>ext</id>
	    <activation>
	      <property>
	        <name>ext</name>
	      </property>
	      <activeByDefault>false</activeByDefault>
	    </activation>
            <modules>
              <module>/ext</module>
            </modules>
    </profile>
  </profiles>
{code}


 In *dms/trunk/core*, we create *pom.xml* file to build all module of current DMS

{code}
<project>
  <parent>
    <groupId>org.exoplatform.ecm.dms</groupId>
    <artifactId>config</artifactId>
    <version>2.3-SNAPSHOT</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>org.exoplatform.ecm.dms.core</groupId>
  <artifactId>config</artifactId>
  <name>eXo DMS Config</name>
  <version>2.3-SNAPSHOT</version>
  <packaging>pom</packaging>

  <modules>
    <module>component/cms</module>
	<module>component/deployment</module>
	<module>component/publication</module>
	<module>connectors/fckeditor</module>
	<module>webui/dms</module>
	<module>web/eXoDMSResources</module>	
  <module>portlet/ecm</module>
  <module>portlet/jcr-console</module>
    <module>web/dmsportal</module>
  </modules>

  <build>
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
	  <include>**/*.gtmpl</include>
	  <include>**/*.gif</include>
        </includes>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/java</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
      </testResource>
    </testResources>
   ....

  <profiles>
    <profile>
      <id>default</id>
      <activation>
        <property><name>default</name></property>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <org.exoplatform.kernel.version>2.0.6</org.exoplatform.kernel.version>
        <org.exoplatform.core.version>2.1.4</org.exoplatform.core.version>
        <org.exoplatform.jcr.version>1.10.2</org.exoplatform.jcr.version>
        <org.exoplatform.ws.version>1.3.2</org.exoplatform.ws.version>
        <org.exoplatform.pc.version>2.0.4</org.exoplatform.pc.version>
        <org.exoplatform.portal.version>2.5.2</org.exoplatform.portal.version>
        <org.exoplatform.ecm.dms.version>2.3-SNAPSHOT</org.exoplatform.ecm.dms.version>
	<exo.test.classes>Test</exo.test.classes>
        <exo.test.skip>true</exo.test.skip>
        <bonita.version>3.0</bonita.version>
      </properties>
    </profile>
  </profiles>
</project>
{code}

 And create *pom.xml* file in *ecm/dms/trunk/ext/* to build *contenvalidation* (and other module if have)

{code}
<project>

  <parent>
    <groupId>org.exoplatform.ecm.dms</groupId>
    <artifactId>config</artifactId>
    <version>2.3-SNAPSHOT</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>org.exoplatform.ecm.dms</groupId>
  <artifactId>ext</artifactId>
  <name>eXo Content Validation</name>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <modules>
    <module>contentvalidation</module>
  </modules>

  <profiles>
    <profile>
      <id>default</id>
      <activation>
        <property><name>default</name></property>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <exo.test.skip>true</exo.test.skip>
      </properties>
    </profile>
  </profiles>
</project>

{code}



h1. 4. Build DMS
 4.1 Build DMS with core:
by default in *dms/trunk/* we run:
{code}
mvn clean install
{code}
 4.2 Build DMS with *dms/core* and *dms/contentvalidation*, we use maven profile
in *dms/trunk/*, run
{code}
mvn clean install -P ext
{code}
 4.3 Build and deploy *dms* version *trunk*
{code}
exobuild --product=dms --exclude=all --build --deploy
{code}
 4.4 Build and deploy *dms* version *trunk* with *workflow*
{code}
exobuild --product=dms --exclude=all --build --deploy --enable-workflow
{code}
Because from now, we change in *tools/trunk/build/src/main/javascript/eXo/command/exobuild.js*
to use maven profile:
{code}
  if (enableWorkflow && (product.name == "eXoDMS")) {
    mvnArgs = ["clean", "install", "-P", "ext"];
  } else {
    mvnArgs = ["clean", "install"];
  }
{code}


