diff options
author | Eike Stepper | 2018-10-29 12:50:27 +0000 |
---|---|---|
committer | Eike Stepper | 2018-10-29 12:50:27 +0000 |
commit | 4e192c345723f21204078b5f17e8b78570bdb648 (patch) | |
tree | 6972c535b5431d8e3cd23f070440eaf99ef4e689 /plugins/org.eclipse.emf.cdo.migrator | |
parent | d40ca5f25b3a69b771e9a701dc26e31e22806710 (diff) | |
download | cdo-4e192c345723f21204078b5f17e8b78570bdb648.tar.gz cdo-4e192c345723f21204078b5f17e8b78570bdb648.tar.xz cdo-4e192c345723f21204078b5f17e8b78570bdb648.zip |
[Releng] Add org.eclipse.emf.cdo.migrator.AutomaticBuildTask
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.migrator')
4 files changed, 144 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.migrator/plugin.xml b/plugins/org.eclipse.emf.cdo.migrator/plugin.xml index 30aac7fa87..084ae7c7f9 100644 --- a/plugins/org.eclipse.emf.cdo.migrator/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.migrator/plugin.xml @@ -59,6 +59,7 @@ </extension> <extension point="org.eclipse.ant.core.antTasks"> + <antTask library="ant_tasks/cdo.ant.tasks.jar" name="cdo.automaticBuild" class="org.eclipse.emf.cdo.internal.migrator.tasks.AutomaticBuildTask" /> <antTask library="ant_tasks/cdo.ant.tasks.jar" name="cdo.importProject" class="org.eclipse.emf.cdo.internal.migrator.tasks.ImportProjectTask" /> <antTask library="ant_tasks/cdo.ant.tasks.jar" name="cdo.deleteProject" class="org.eclipse.emf.cdo.internal.migrator.tasks.DeleteProjectTask" /> <antTask library="ant_tasks/cdo.ant.tasks.jar" name="cdo.cleanupProject" class="org.eclipse.emf.cdo.internal.migrator.tasks.CleanupProjectTask" /> diff --git a/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/AbstractPropertyTask.java b/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/AbstractPropertyTask.java new file mode 100644 index 0000000000..5f1621f4f6 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/AbstractPropertyTask.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018 Eike Stepper (Loehne, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.migrator.tasks; + +import org.apache.tools.ant.BuildException; + +/** + * @author Eike Stepper + */ +public abstract class AbstractPropertyTask extends CDOTask +{ + private String property; + + private String value; + + public void setProperty(String property) + { + this.property = property; + } + + public void setValue(String value) + { + this.value = value; + } + + protected boolean isPropertyRequired() + { + return false; + } + + @Override + protected void checkAttributes() throws BuildException + { + if (isPropertyRequired()) + { + assertTrue("'property' must be specified.", isSet(property)); + } + } + + @Override + protected final void doExecute() throws Exception + { + String result = doCompute(); + if (isSet(result) && isSet(property)) + { + if (isSet(value)) + { + result = value; + } + + getProject().setNewProperty(property, result); + } + } + + protected abstract String doCompute() throws Exception; +} diff --git a/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/AutomaticBuildTask.java b/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/AutomaticBuildTask.java new file mode 100644 index 0000000000..22be560ba8 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/AutomaticBuildTask.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2018 Eike Stepper (Loehne, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.migrator.tasks; + +import org.eclipse.core.resources.IWorkspaceDescription; + +import org.apache.tools.ant.BuildException; + +/** + * @author Eike Stepper + */ +public class AutomaticBuildTask extends AbstractPropertyTask +{ + private Boolean enable; + + private String _if; + + public void setEnable(Boolean enable) + { + this.enable = enable; + } + + public void setIf(String _if) + { + this._if = _if; + } + + @Override + protected void checkAttributes() throws BuildException + { + super.checkAttributes(); + assertTrue("'enable' must be specified.", enable != null); + } + + @Override + protected String doCompute() throws Exception + { + if (isSet(_if)) + { + if (!TRUE.equals(getProject().getProperty(_if))) + { + return FALSE; + } + } + + IWorkspaceDescription description = workspace.getDescription(); + boolean wasEnabled = description.isAutoBuilding(); + + if (wasEnabled == enable) + { + return FALSE; + } + + description.setAutoBuilding(enable); + workspace.setDescription(description); + + verbose("Automatic build " + (enable ? "enabled" : "disabled")); + return TRUE; + } +} diff --git a/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/CDOTask.java b/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/CDOTask.java index 5e52cc5c77..ee37487814 100644 --- a/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/CDOTask.java +++ b/plugins/org.eclipse.emf.cdo.migrator/src/org/eclipse/emf/cdo/internal/migrator/tasks/CDOTask.java @@ -10,6 +10,8 @@ */ package org.eclipse.emf.cdo.internal.migrator.tasks; +import org.eclipse.net4j.util.StringUtil; + import org.eclipse.ant.core.AntCorePlugin; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; @@ -37,6 +39,10 @@ import java.io.Writer; */ public abstract class CDOTask extends Task { + public static final String FALSE = Boolean.FALSE.toString(); + + public static final String TRUE = Boolean.TRUE.toString(); + public static final String NL = System.getProperty("line.separator"); public static final int EOF = -1; @@ -114,6 +120,11 @@ public abstract class CDOTask extends Task return new NullProgressMonitor(); } + public static boolean isSet(String str) + { + return !StringUtil.isEmpty(str); + } + public static void assertTrue(String message, boolean expression) throws BuildException { if (!expression) |