| <?xml version="1.0"?> |
| <!-- |
| Copyright (c) 2020 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.profile.standard" /> |
| |
| <!-- |
| Ensure that UML2's Git clone exists and is reachable. |
| --> |
| <fail unless="git.clone.uml2" message="Property 'git.clone.uml2' is undefined!" /> |
| <property name="standard" location="${git.clone.uml2}/plugins/${project.name}" /> |
| <fail message="The directory '${standard}' does not exist!"> |
| <condition> |
| <not> |
| <available file="${standard}" type="dir" /> |
| </not> |
| </condition> |
| </fail> |
| |
| <property name="standard.tmp" location="${basedir}/target/${project.name}" /> |
| <echo message="Migrating in ${standard.tmp} ..." /> |
| |
| <cdo.automaticBuild enable="false" /> |
| <cdo.deleteProject projectname=".JETEmitters" deletecontent="true" /> |
| <backup.project project.name="${project.name}" /> |
| |
| <!-- |
| Migrate the 'Standard.genmodel' to CDO and regenerate the model within the |
| imported 'org.eclipse.uml2.uml.profile.standard' project. |
| --> |
| <property name="model.path" value="/${project.name}/model/Standard.genmodel" /> |
| <cdo.migrateModel modelpath="${model.path}" dynamicfeaturedelegation="true" /> |
| <cdo.generateModel modelpath="${model.path}" /> |
| |
| <!-- |
| Copy all Java files from the generated 'impl' folder to the |
| 'org.eclipse.uml2.uml.profile.standard.cdo' project. |
| --> |
| <property name="impl" location="${basedir}/src/org/eclipse/uml2/uml/profile/standard/cdo" /> |
| <delete> |
| <fileset dir="${impl}"> |
| <include name="*.java" /> |
| </fileset> |
| </delete> |
| <copy todir="${impl}"> |
| <fileset dir="${standard.tmp}/src/org/eclipse/uml2/uml/profile/standard/internal/impl"> |
| <include name="*.java" /> |
| <exclude name="StandardPackageImpl.java" /> |
| </fileset> |
| |
| <!-- |
| Apply the following refactorings: |
| --> |
| <filterchain> |
| <!-- |
| Rename the Java package to 'org.eclipse.uml2.uml.profile.standard.cdo'. |
| --> |
| <replacestring from="org.eclipse.uml2.uml.profile.standard.internal.impl" to="org.eclipse.uml2.uml.profile.standard.cdo" /> |
| </filterchain> |
| </copy> |
| |
| <restore.project project.name="${project.name}" /> |
| |
| <!-- |
| Apply source cleanup to the 'org.eclipse.uml2.uml.profile.standard.cdo' project. |
| This ensures that only relevant changes appear in the Git history. |
| --> |
| <cdo.cleanupProject projectname="org.eclipse.uml2.uml.profile.standard.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.profile.standard.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> |