blob: 4ff2857282a41b532f1607f01678438a058b71c7 [file] [log] [blame]
<?xml version="1.0"?>
<!--
Copyright (c) 2018 CEA LIST and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Eike Stepper - initial API and implementation
-->
<project name="migrate" default="migrate">
<!--
The migration of the Style model to CDO is completely automated.
The 'org.eclipse.emf.cdo.migrator' plugin must be installed into the Eclipse IDE!!!
Then execute the following tasks:
-->
<fail unless="git.clone.papyrus" message="Property 'git.clone.papyrus' is undefined! Go to Preferences -> Run/Debug -> String Substitution..." />
<property name="project.name" value="org.eclipse.papyrus.infra.gmfdiag.style" />
<property name="style" location="${git.clone.papyrus}/plugins/infra/gmfdiag/${project.name}" />
<fail message="The directory '${style}' does not exist!">
<condition>
<not>
<available file="${style}" type="dir" />
</not>
</condition>
</fail>
<property name="style.tmp" location="${basedir}/target/${project.name}" />
<echo message="Source: ${style}" />
<echo message="Temp: ${style.tmp}" />
<echo message="Target: ${basedir}" />
<target name="migrate">
<!--
Copy the entire 'org.eclipse.papyrus.infra.gmfdiag.style' project
into the 'target' folder of the 'org.eclipse.papyrus.infra.gmfdiag.style.cdo' plugin to
be able to revert the changes that are applied below.
-->
<echo message="Backing up project ${project.name} to ${style.tmp}" />
<delete failonerror="false" includeemptydirs="true">
<fileset dir="${style.tmp}">
<include name="**" />
</fileset>
</delete>
<copy todir="${style.tmp}" verbose="false" failonerror="true" overwrite="true" includeemptydirs="true" preservelastmodified="true">
<fileset dir="${style}" defaultexcludes="true">
<include name="**/*" />
</fileset>
</copy>
<!--
Migrate the 'style.genmodel' to CDO and regenerate the model in-place.
-->
<property name="model.path" value="/${project.name}/model/style.genmodel" />
<echo message="Migrating ${model.path} in ${style} ..." />
<cdo.migrateModel modelpath="${model.path}" dynamicfeaturedelegation="true" />
<cdo.generateModel modelpath="${model.path}" />
<!--
Copy all Java files from the generated 'impl' folder to the 'impl' folder of the
'org.eclipse.papyrus.infra.gmfdiag.style.cdo' project. Apply the following refactorings:
1. Rename the Java package to 'org.eclipse.papyrus.infra.gmfdiag.style.cdo.impl'.
2. Replace the eAnnotations field accesses that the generator has left in some
eIsSet() methods with calls to the getEAnnotations() method.
-->
<property name="impl" location="${basedir}/src-gen/org/eclipse/papyrus/infra/gmfdiag/style/cdo/impl" />
<delete>
<fileset dir="${impl}">
<include name="*.java" />
</fileset>
</delete>
<copy todir="${impl}" verbose="true">
<fileset dir="${style}/src-gen/org/eclipse/papyrus/infra/gmfdiag/style/impl">
<include name="*.java" />
<exclude name="StylePackageImpl.java" />
</fileset>
<filterchain>
<replacestring from="${project.name}.impl" to="${project.name}.cdo.impl" />
<replacestring from="eAnnotations != null &amp;&amp; !eAnnotations.isEmpty()" to="!getEAnnotations().isEmpty()" />
</filterchain>
</copy>
<!--
Apply source cleanup to the 'org.eclipse.papyrus.infra.gmfdiag.style.cdo' project.
This ensures that only relevant changes appear in the Git history.
-->
<cdo.cleanupProject projectname="${project.name}.cdo" />
<!--
Copy the entire 'org.eclipse.papyrus.infra.gmfdiag.style' project back
from the 'target' folder of the 'org.eclipse.papyrus.infra.gmfdiag.style.cdo' plugin.
-->
<echo message="Restoring project ${project.name} from ${style.tmp}" />
<delete failonerror="true" includeemptydirs="true">
<fileset dir="${style}">
<include name="**" />
</fileset>
</delete>
<copy todir="${style}" verbose="false" failonerror="true" overwrite="true" includeemptydirs="true" preservelastmodified="true">
<fileset dir="${style.tmp}" defaultexcludes="true">
<include name="**/*" />
</fileset>
</copy>
</target>
</project>