The services-war-app requires data- und ui-models to be provided in different classpath locations in order for them to be uploaded during server initialization procedure.
In <PROJECT_NAME> we currently keep data- and ui-models in the same folder in order to keep the ui designer workspace simple. How can we separate these models during build time so that the services-war-app is able to pick them up during initialization?
The maven build in <PROJECT_NAME> will use an ant invocation:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<ant dir="${project.basedir}" antfile="${project.basedir}/src/main/build/build.xml" target="split-document-models" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The ant build then does the separation:
<project name="cosmo-claims-models" default="split-document-models" basedir=".">
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask">
<classpath>
<pathelement path="${basedir}/target/ant-lib/xmltask.jar" />
</classpath>
</taskdef>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${basedir}/target/ant-lib/ant-contrib.jar" />
</classpath>
</taskdef>
<target name="split-document-models">
<foreach param="documentModel" target="copy-document-model-to-dir">
<path>
<fileset dir="${basedir}/src/main/resources/model/workspace">
<include name="*.xml" />
</fileset>
</path>
</foreach>
</target>
<target name="copy-document-model-to-dir">
<xmltask source="${documentModel}">
<copy path="namespace-uri(/*)" property="documentModelNamespace" />
</xmltask>
<if>
<equals arg1="http://www.mgm-tp.com/a12/platform/overview/model" arg2="${documentModelNamespace}" />
<then>
<copy file="${documentModel}" todir="${basedir}/target/classes/model/picus" />
</then>
<elseif>
<equals arg1="http://www.mgm-tp.com/a12/picus/model/v2" arg2="${documentModelNamespace}" />
<then>
<copy file="${documentModel}" todir="${basedir}/target/classes/model/picus" />
</then>
</elseif>
<elseif>
<equals arg1="http://www.mgm-tp.com/a12/melies/model" arg2="${documentModelNamespace}" />
<then>
<copy file="${documentModel}" todir="${basedir}/target/classes/model/melies" />
</then>
</elseif>
<else>
<fail message="Unable to handle ${documentModel}." />
</else>
</if>
</target>
</project>
The task definition com.oopsconsultancy.xmltask.ant.XmlTask refers to the xmltask ant task.
The above will write the model files to either target/classes/model/picus or ${basedir}/target/classes/model/melies depending on the xml namespace of the model.