| <?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 UML2 model to CDO is completely automated. |
| The following preconditions must be met before executing the 'migrate.ant' script: |
| |
| 1. A recent 'EMF SDK' feature must be installed into the Eclipse IDE. |
| |
| 2. The 'org.eclipse.emf.cdo.migrator' plugin must be installed into the Eclipse IDE. |
| |
| 3. UML2's Git repository must be cloned from |
| https://git.eclipse.org/r/uml2/org.eclipse.uml2 |
| to the local disk. Its disk location must then be passed into this script |
| through the 'git.clone.uml2' property. |
| |
| 4. This Ant script must be executed in the JRE of the running IDE! |
| |
| Ideally this script is executed via the accompanying 'Migrate UML2.launch'. |
| |
| Do NOT apply hand-written changes to the classes in the |
| org.eclipse.uml2.uml.cdo.internal.impl package. |
| This script will eventually overwrite them! |
| Rather modify the underlying UML2 code or this script. |
| --> |
| <target name="migrate"> |
| <property name="project.name" value="org.eclipse.uml2.uml" /> |
| |
| <!-- |
| Ensure that UML2's Git clone exists and is reachable. |
| --> |
| <fail unless="git.clone.uml2" message="Property 'git.clone.uml2' is undefined!" /> |
| <property name="uml" location="${git.clone.uml2}/plugins/${project.name}" /> |
| <fail message="The directory '${uml}' does not exist!"> |
| <condition> |
| <not> |
| <available file="${uml}" type="dir" /> |
| </not> |
| </condition> |
| </fail> |
| |
| <property name="uml.tmp" location="${basedir}/target/${project.name}" /> |
| <echo message="Migrating in ${uml.tmp} ..." /> |
| |
| <cdo.automaticBuild enable="false" /> |
| <cdo.deleteProject projectname=".JETEmitters" deletecontent="true" /> |
| |
| <backup.project project.name="${project.name}" /> |
| <backup.project project.name="org.eclipse.uml2" /> |
| |
| <copy todir="${basedir}/target/org.eclipse.uml2/templates" overwrite="true" verbose="true"> |
| <fileset dir="${basedir}/templates"> |
| <include name="**/*.javajet" /> |
| <include name="**/*.javajetinc" /> |
| </fileset> |
| </copy> |
| |
| <!-- |
| Migrate the 'UML.genmodel' to CDO and regenerate the model within the |
| imported 'org.eclipse.uml2.uml' project. |
| --> |
| <property name="model.path" value="/${project.name}/model/UML.genmodel" /> |
| <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.uml2.uml.cdo' project. |
| --> |
| <property name="impl" location="${basedir}/src/org/eclipse/uml2/uml/cdo/internal/impl" /> |
| <delete> |
| <fileset dir="${impl}"> |
| <include name="*.java" /> |
| </fileset> |
| </delete> |
| <copy todir="${impl}"> |
| <fileset dir="${uml.tmp}/src/org/eclipse/uml2/uml/internal/impl"> |
| <include name="*.java" /> |
| <exclude name="UMLPackageImpl.java" /> |
| </fileset> |
| |
| <!-- |
| Apply the following refactorings: |
| --> |
| <filterchain> |
| <!-- |
| Rename the Java package to 'org.eclipse.uml2.uml.cdo.internal.impl'. |
| --> |
| <replacestring from="org.eclipse.uml2.uml.internal.impl" to="org.eclipse.uml2.uml.cdo.internal.impl" /> |
| |
| <!-- |
| Replace EMF's EModelElementImpl base class with CDO's variant of that class. |
| --> |
| <replacestring from="extends EModelElementImpl" to="extends org.eclipse.uml2.uml.cdo.internal.util.CDOElementImpl" /> |
| |
| <!-- |
| Replace the eAnnotations field accesses that the generator has left in some |
| eIsSet() methods with calls to the getEAnnotations() method. |
| --> |
| <replacestring from="eAnnotations != null && !eAnnotations.isEmpty()" to="!getEAnnotations().isEmpty()" /> |
| |
| <!-- |
| Decrease the generated ESTATIC_FEATURE_COUNT from 1 to 0 because the inherited |
| EModelElement.eAnnotations feature is implemented dynamically, too. |
| --> |
| <replacestring from="ESTATIC_FEATURE_COUNT = 1" to="ESTATIC_FEATURE_COUNT = 0" /> |
| |
| <!-- |
| Fix hand-written code around ElementImpl.eAdapters() to not refer to eFlags anymore. |
| --> |
| <replacestring from="private static final int ADAPTING = 1 << 7;" to="private boolean adapting;" /> |
| <replacestring from="(eFlags & ADAPTING) == 0" to="!adapting" /> |
| <replacestring from="eFlags |= ADAPTING;" to="adapting = true; org.eclipse.emf.spi.cdo.InternalCDOView view = cdoView(); if (view != null && !view.isClosed()) {" /> |
| <replacestring from="eFlags &= ~ADAPTING;" to="adapting = false; }" /> |
| |
| <tokenfilter> |
| <filetokenizer /> |
| <!-- |
| Fix generated type mismatches: |
| * CreateLinkActionImpl.getEndData() |
| * DestroyLinkActionImpl.getEndData() |
| * ExtensionImpl.getOwnedEndsGen() ### UNUSED?! |
| --> |
| <replaceregex pattern="(public\s+EList<([^>]+)>\s*get[^(]+\(\)\s*\{\s*return\s*\(EList<)[^>]+(>\)\s*eDynamicGet)" replace="\1\2\3" flags="sg" /> |
| |
| <!-- |
| Replace all SubsetSuperset lists with CDO-specific variants. |
| --> |
| <replaceregex pattern="org.eclipse.uml2.common.util.SubsetSuperset([^;]+)EList;" replace="org.eclipse.uml2.uml.cdo.internal.util.SubsetSuperset\1EList;" flags="sg" /> |
| |
| <!-- |
| Insert the createList() method into all classes that contain a createSpecialList() method. |
| --> |
| <replaceregex pattern="@SuppressWarnings\("unused"\)([\r\n]+[ \t]*?)private EList<\?> createSpecialList\(EStructuralFeature eStructuralFeature\)" replace="@Override\1protected EList<?> createList(EStructuralFeature eStructuralFeature) {\1	EList<?> result = createSpecialList(eStructuralFeature);\1	if (result != null) {\1		return result;\1	}\1	\1	return super.createList(eStructuralFeature);\1}\1\1private EList<?> createSpecialList(EStructuralFeature eStructuralFeature)" flags="sg" /> |
| </tokenfilter> |
| </filterchain> |
| </copy> |
| |
| <!-- |
| Special persistence handling in: |
| * ActivityImpl.groups |
| * ActivityImpl.nodes |
| --> |
| <replaceregexp file="${impl}/ActivityImpl.java" match="([\r\n]+[ \t]*?)public EList<ActivityGroup> getGroups\(\)[^}]+?}[^}]+?}" replace="\1@SuppressWarnings("unchecked")\1public EList<ActivityGroup> getGroups() {\1	return (EList<ActivityGroup>) eDynamicGet(\1		UMLPackage.ACTIVITY__GROUP - ESTATIC_FEATURE_COUNT,\1		UMLPackage.Literals.ACTIVITY__GROUP, true, true);\1}" flags="sg" /> |
| <replaceregexp file="${impl}/ActivityImpl.java" match="([\r\n]+[ \t]*?)public EList<ActivityNode> getNodes\(\)[^}]+?}[^}]+?}" replace="\1@SuppressWarnings("unchecked")\1public EList<ActivityNode> getNodes() {\1	return (EList<ActivityNode>) eDynamicGet(\1		UMLPackage.ACTIVITY__NODE - ESTATIC_FEATURE_COUNT,\1		UMLPackage.Literals.ACTIVITY__NODE, true, true);\1}" flags="sg" /> |
| |
| <restore.project project.name="org.eclipse.uml2" /> |
| <restore.project project.name="${project.name}" /> |
| |
| <!-- |
| Apply source cleanup to the 'org.eclipse.uml2.uml.cdo' project. |
| This ensures that only relevant changes appear in the Git history. |
| --> |
| <cdo.cleanupProject projectname="org.eclipse.uml2.uml.cdo" /> |
| <cdo.automaticBuild enable="true" /> |
| </target> |
| |
| |
| <!-- |
| This macro copies a project from the UML2 Git repository to the |
| 'target' folder of the 'org.eclipse.uml2.uml.cdo' project and then |
| re-imports it from the new, temporary location into the workspace. |
| --> |
| <macrodef name="backup.project"> |
| <attribute name="project.name" /> |
| <sequential> |
| <echo message="Backing up project @{project.name}" /> |
| <delete failonerror="false" includeemptydirs="true"> |
| <fileset dir="${basedir}/target/@{project.name}"> |
| <include name="**" /> |
| </fileset> |
| </delete> |
| <copy todir="${basedir}/target/@{project.name}" verbose="false" failonerror="true" overwrite="true" includeemptydirs="false"> |
| <fileset dir="${git.clone.uml2}/plugins/@{project.name}" defaultexcludes="true"> |
| <include name="**/*" /> |
| <exclude name="bin/**" /> |
| </fileset> |
| </copy> |
| <replace dir="${basedir}/target/@{project.name}" token="@generated NOT_CDO" value="@generated"> |
| <include name="**/*.java" /> |
| </replace> |
| <cdo.deleteProject projectname="@{project.name}" /> |
| <cdo.importProject projectname="@{project.name}" fromlocation="${basedir}/target/@{project.name}" /> |
| </sequential> |
| </macrodef> |
| |
| <!-- |
| This macro reverts the effect of the "backup.project" macro for |
| the given workspace project, i.e., it re-imports the project from |
| its original location in the UML2 Git repository. |
| --> |
| <macrodef name="restore.project"> |
| <attribute name="project.name" /> |
| <sequential> |
| <echo message="Restoring project @{project.name}" /> |
| <cdo.deleteProject projectname="@{project.name}" /> |
| <cdo.importProject projectname="@{project.name}" fromlocation="${git.clone.uml2}/plugins/@{project.name}" /> |
| </sequential> |
| </macrodef> |
| |
| </project> |