Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoubekeur Zendagui2016-04-05 07:24:07 +0000
committerThomas Guiu2016-04-05 11:07:59 +0000
commit245fa09bf228bd32aa97e2358e7db2fd240c456f (patch)
tree8bda542cdc91946d4689f5d94ff9b3e9998d1494
parent38260fce448393f60fdbf187ecab7b105ce49e68 (diff)
downloadorg.eclipse.emf.egf-245fa09bf228bd32aa97e2358e7db2fd240c456f.tar.gz
org.eclipse.emf.egf-245fa09bf228bd32aa97e2358e7db2fd240c456f.tar.xz
org.eclipse.emf.egf-245fa09bf228bd32aa97e2358e7db2fd240c456f.zip
[487725] [EGF - Portfolio] Add tasks for coping resources and plugin
management. Add IP headers Bug: 487725 Change-Id: I9e5b9494fb6566277fa0110b1c2cdaca191631a0 Signed-off-by: Boubekeur Zendagui <boubekeur.zendagui@obeo.fr>
-rw-r--r--portfolio/org.eclipse.egf.eclipse.resources.mgt/META-INF/MANIFEST.MF3
-rw-r--r--portfolio/org.eclipse.egf.eclipse.resources.mgt/fcs/Resources.fcore210
-rw-r--r--portfolio/org.eclipse.egf.eclipse.resources.mgt/src/org/eclipse/egf/eclipse/resources/mgt/CopyFilesTask.java147
-rw-r--r--portfolio/org.eclipse.egf.eclipse.resources.mgt/src/org/eclipse/egf/eclipse/resources/mgt/PluginManagementTask.java79
4 files changed, 347 insertions, 92 deletions
diff --git a/portfolio/org.eclipse.egf.eclipse.resources.mgt/META-INF/MANIFEST.MF b/portfolio/org.eclipse.egf.eclipse.resources.mgt/META-INF/MANIFEST.MF
index d8a574586..764f14464 100644
--- a/portfolio/org.eclipse.egf.eclipse.resources.mgt/META-INF/MANIFEST.MF
+++ b/portfolio/org.eclipse.egf.eclipse.resources.mgt/META-INF/MANIFEST.MF
@@ -10,7 +10,8 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Require-Bundle:
org.eclipse.egf.model.ftask;visibility:=reexport,
- org.eclipse.egf.core.pde
+ org.eclipse.egf.core.pde,
+ org.eclipse.pde.ui
Bundle-Activator:
org.eclipse.egf.eclipse.resources.mgt.Activator
Export-Package:
diff --git a/portfolio/org.eclipse.egf.eclipse.resources.mgt/fcs/Resources.fcore b/portfolio/org.eclipse.egf.eclipse.resources.mgt/fcs/Resources.fcore
index a287e805b..815aa65ea 100644
--- a/portfolio/org.eclipse.egf.eclipse.resources.mgt/fcs/Resources.fcore
+++ b/portfolio/org.eclipse.egf.eclipse.resources.mgt/fcs/Resources.fcore
@@ -1,91 +1,119 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:ftask="http://www.eclipse.org/egf/1.0.0/ftask"
- xmlns:types="http://www.eclipse.org/egf/1.0.0/types">
- <ftask:Task xmi:id="_d5v1IAqCEd-JA8Js2pdQ0g" description="Create an eclipse project. Does nothing if the project already exists. Open it if it exists but is closed."
- name="CreateProject" kind="java" implementation="org.eclipse.egf.eclipse.resources.mgt.CreateProjectTask">
- <contractContainer xmi:id="_1v2SIAqDEd-JA8Js2pdQ0g">
- <contracts xmi:id="_1_fQoAqDEd-JA8Js2pdQ0g" description="Name of the project to be created."
- name="name" mandatory="true">
- <type xmi:type="types:TypeString" xmi:id="_2wOKAAqDEd-JA8Js2pdQ0g"/>
- </contracts>
- <contracts xmi:id="_1YyAgAqEEd-JA8Js2pdQ0g" description="Path of the project. Returns a string representation of this path which uses the platform-dependent path separator defined by java.io.File."
- name="path" mode="Out">
- <type xmi:type="types:TypeString" xmi:id="_2c5I4AqEEd-JA8Js2pdQ0g"/>
- </contracts>
- </contractContainer>
- </ftask:Task>
- <ftask:Task xmi:id="_DSL_oIqSEd-U1srr1078Ww" name="Convert project to plugin" kind="java"
- implementation="org.eclipse.egf.eclipse.resources.mgt.ConvertProject2PluginTask">
- <contractContainer xmi:id="_6rGw4IqYEd-U1srr1078Ww">
- <contracts xmi:id="_WbRLgIqhEd-U1srr1078Ww" name="name" mandatory="true">
- <type xmi:type="types:TypeString" xmi:id="_Ymz2AIqhEd-U1srr1078Ww"/>
- </contracts>
- </contractContainer>
- </ftask:Task>
- <ftask:Task xmi:id="_tx1ZAJpNEeO0BorZRiG7mg" name="Create.Feature.Project" kind="java"
- implementation="org.eclipse.egf.eclipse.resources.mgt.CreateFeatureTask">
- <contractContainer xmi:id="_tx1ZAZpNEeO0BorZRiG7mg">
- <contracts xmi:id="_tx1ZAppNEeO0BorZRiG7mg" name="id" mandatory="true">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZA5pNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZBJpNEeO0BorZRiG7mg" name="label" mandatory="true">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZBZpNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZBppNEeO0BorZRiG7mg" name="provider" mandatory="true">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZB5pNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZCJpNEeO0BorZRiG7mg" name="version">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZCZpNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZCppNEeO0BorZRiG7mg" name="plugins.names.list">
- <type xmi:type="types:TypeList" xmi:id="_tx1ZC5pNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZDJpNEeO0BorZRiG7mg" name="incluted.feature.names.list">
- <type xmi:type="types:TypeList" xmi:id="_tx1ZDZpNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZDppNEeO0BorZRiG7mg" name="description.url">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZD5pNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZEJpNEeO0BorZRiG7mg" name="description.uri">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZEZpNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZEppNEeO0BorZRiG7mg" name="license.url">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZE5pNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZFJpNEeO0BorZRiG7mg" name="license.uri">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZFZpNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZFppNEeO0BorZRiG7mg" name="copyright.url">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZF5pNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZGJpNEeO0BorZRiG7mg" name="copyright.uri">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZGZpNEeO0BorZRiG7mg"/>
- </contracts>
- </contractContainer>
- </ftask:Task>
- <ftask:Task xmi:id="_tx1ZGppNEeO0BorZRiG7mg" name="Add.Plugin.or.Include.Feature.to.Existing.Feature"
- kind="java" implementation="org.eclipse.egf.eclipse.resources.mgt.UpdateFeatureTask">
- <contractContainer xmi:id="_tx1ZG5pNEeO0BorZRiG7mg">
- <contracts xmi:id="_tx1ZHJpNEeO0BorZRiG7mg" name="feature.name">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZHZpNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZHppNEeO0BorZRiG7mg" name="plugin.name.to.include">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZH5pNEeO0BorZRiG7mg"/>
- </contracts>
- <contracts xmi:id="_tx1ZIJpNEeO0BorZRiG7mg" name="feature.name.to.include">
- <type xmi:type="types:TypeString" xmi:id="_tx1ZIZpNEeO0BorZRiG7mg"/>
- </contracts>
- </contractContainer>
- </ftask:Task>
- <ftask:Task xmi:id="_bLHVECakEd-RhP-A_BvFzw" name="CreateJavaProject" kind="java"
- implementation="org.eclipse.egf.eclipse.resources.mgt.CreateJavaProjectTask">
- <contractContainer xmi:id="_FbHXACalEd-RhP-A_BvFzw">
- <contracts xmi:id="_Fs2AMCalEd-RhP-A_BvFzw" name="name" mandatory="true">
- <type xmi:type="types:TypeString" xmi:id="_H7ELQCalEd-RhP-A_BvFzw"/>
- </contracts>
- <contracts xmi:id="_VDCuICalEd-RhP-A_BvFzw" name="execution.environment">
- <type xmi:type="types:TypeString" xmi:id="_V4FfwCalEd-RhP-A_BvFzw" value="J2SE-1.5"/>
- </contracts>
- </contractContainer>
- </ftask:Task>
-</xmi:XMI>
+<?xml version="1.0" encoding="UTF-8"?>
+<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:ftask="http://www.eclipse.org/egf/1.0.0/ftask"
+ xmlns:types="http://www.eclipse.org/egf/1.0.0/types">
+ <ftask:Task xmi:id="_d5v1IAqCEd-JA8Js2pdQ0g" description="Create an eclipse project. Does nothing if the project already exists. Open it if it exists but is closed."
+ name="CreateProject" kind="java" implementation="org.eclipse.egf.eclipse.resources.mgt.CreateProjectTask">
+ <contractContainer xmi:id="_1v2SIAqDEd-JA8Js2pdQ0g">
+ <contracts xmi:id="_1_fQoAqDEd-JA8Js2pdQ0g" description="Name of the project to be created."
+ name="name" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_2wOKAAqDEd-JA8Js2pdQ0g"/>
+ </contracts>
+ <contracts xmi:id="_1YyAgAqEEd-JA8Js2pdQ0g" description="Path of the project. Returns a string representation of this path which uses the platform-dependent path separator defined by java.io.File."
+ name="path" mode="Out">
+ <type xmi:type="types:TypeString" xmi:id="_2c5I4AqEEd-JA8Js2pdQ0g"/>
+ </contracts>
+ </contractContainer>
+ </ftask:Task>
+ <ftask:Task xmi:id="_DSL_oIqSEd-U1srr1078Ww" name="Convert project to plugin" kind="java"
+ implementation="org.eclipse.egf.eclipse.resources.mgt.ConvertProject2PluginTask">
+ <contractContainer xmi:id="_6rGw4IqYEd-U1srr1078Ww">
+ <contracts xmi:id="_WbRLgIqhEd-U1srr1078Ww" name="name" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_Ymz2AIqhEd-U1srr1078Ww"/>
+ </contracts>
+ </contractContainer>
+ </ftask:Task>
+ <ftask:Task xmi:id="_tx1ZAJpNEeO0BorZRiG7mg" name="Create.Feature.Project" kind="java"
+ implementation="org.eclipse.egf.eclipse.resources.mgt.CreateFeatureTask">
+ <contractContainer xmi:id="_tx1ZAZpNEeO0BorZRiG7mg">
+ <contracts xmi:id="_tx1ZAppNEeO0BorZRiG7mg" name="id" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZA5pNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZBJpNEeO0BorZRiG7mg" name="label" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZBZpNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZBppNEeO0BorZRiG7mg" name="provider" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZB5pNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZCJpNEeO0BorZRiG7mg" name="version">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZCZpNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZCppNEeO0BorZRiG7mg" name="plugins.names.list">
+ <type xmi:type="types:TypeList" xmi:id="_tx1ZC5pNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZDJpNEeO0BorZRiG7mg" name="incluted.feature.names.list">
+ <type xmi:type="types:TypeList" xmi:id="_tx1ZDZpNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZDppNEeO0BorZRiG7mg" name="description.url">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZD5pNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZEJpNEeO0BorZRiG7mg" name="description.uri">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZEZpNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZEppNEeO0BorZRiG7mg" name="license.url">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZE5pNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZFJpNEeO0BorZRiG7mg" name="license.uri">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZFZpNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZFppNEeO0BorZRiG7mg" name="copyright.url">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZF5pNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZGJpNEeO0BorZRiG7mg" name="copyright.uri">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZGZpNEeO0BorZRiG7mg"/>
+ </contracts>
+ </contractContainer>
+ </ftask:Task>
+ <ftask:Task xmi:id="_tx1ZGppNEeO0BorZRiG7mg" name="Add.Plugin.or.Include.Feature.to.Existing.Feature"
+ kind="java" implementation="org.eclipse.egf.eclipse.resources.mgt.UpdateFeatureTask">
+ <contractContainer xmi:id="_tx1ZG5pNEeO0BorZRiG7mg">
+ <contracts xmi:id="_tx1ZHJpNEeO0BorZRiG7mg" name="feature.name">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZHZpNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZHppNEeO0BorZRiG7mg" name="plugin.name.to.include">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZH5pNEeO0BorZRiG7mg"/>
+ </contracts>
+ <contracts xmi:id="_tx1ZIJpNEeO0BorZRiG7mg" name="feature.name.to.include">
+ <type xmi:type="types:TypeString" xmi:id="_tx1ZIZpNEeO0BorZRiG7mg"/>
+ </contracts>
+ </contractContainer>
+ </ftask:Task>
+ <ftask:Task xmi:id="_bLHVECakEd-RhP-A_BvFzw" name="CreateJavaProject" kind="java"
+ implementation="org.eclipse.egf.eclipse.resources.mgt.CreateJavaProjectTask">
+ <contractContainer xmi:id="_FbHXACalEd-RhP-A_BvFzw">
+ <contracts xmi:id="_Fs2AMCalEd-RhP-A_BvFzw" name="name" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_H7ELQCalEd-RhP-A_BvFzw"/>
+ </contracts>
+ <contracts xmi:id="_VDCuICalEd-RhP-A_BvFzw" name="execution.environment">
+ <type xmi:type="types:TypeString" xmi:id="_V4FfwCalEd-RhP-A_BvFzw" value="J2SE-1.5"/>
+ </contracts>
+ </contractContainer>
+ </ftask:Task>
+ <ftask:Task xmi:id="_HCbnYNFiEeWW24r44ga24w" name="Plugin Management" kind="java"
+ implementation="org.eclipse.egf.eclipse.resources.mgt.PluginManagementTask">
+ <contractContainer xmi:id="_1FhfcNFtEeWW24r44ga24w">
+ <contracts xmi:id="_5XrRINFtEeWW24r44ga24w" name="plugin_id" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_9XGUENFtEeWW24r44ga24w"/>
+ </contracts>
+ <contracts xmi:id="__QxygNFtEeWW24r44ga24w" description="" name="plugin_version"
+ mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_Dhc9gNFuEeWW24r44ga24w"/>
+ </contracts>
+ <contracts xmi:id="_M4_UoNFuEeWW24r44ga24w" name="plugin_id_suffix">
+ <type xmi:type="types:TypeString" xmi:id="_QPhyoNFuEeWW24r44ga24w"/>
+ </contracts>
+ </contractContainer>
+ </ftask:Task>
+ <ftask:Task xmi:id="_YX8rQNFuEeWW24r44ga24w" name="Copy Files" kind="java" implementation="org.eclipse.egf.eclipse.resources.mgt.CopyFilesTask">
+ <contractContainer xmi:id="_c8TAMNFuEeWW24r44ga24w">
+ <contracts xmi:id="_djbRoNFuEeWW24r44ga24w" name="plugin_id" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_gbK60NFuEeWW24r44ga24w"/>
+ </contracts>
+ <contracts xmi:id="_kKZloNFuEeWW24r44ga24w" name="destination_path" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_nu61QNFuEeWW24r44ga24w"/>
+ </contracts>
+ <contracts xmi:id="_pRtdsNFuEeWW24r44ga24w" name="source_path" mandatory="true">
+ <type xmi:type="types:TypeString" xmi:id="_reTRENFuEeWW24r44ga24w"/>
+ </contracts>
+ </contractContainer>
+ </ftask:Task>
+</xmi:XMI>
diff --git a/portfolio/org.eclipse.egf.eclipse.resources.mgt/src/org/eclipse/egf/eclipse/resources/mgt/CopyFilesTask.java b/portfolio/org.eclipse.egf.eclipse.resources.mgt/src/org/eclipse/egf/eclipse/resources/mgt/CopyFilesTask.java
new file mode 100644
index 000000000..4c75d2ece
--- /dev/null
+++ b/portfolio/org.eclipse.egf.eclipse.resources.mgt/src/org/eclipse/egf/eclipse/resources/mgt/CopyFilesTask.java
@@ -0,0 +1,147 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2016 Thales Corporate Services S.A.S.
+ * 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:
+ * Thales Corporate Services S.A.S - initial API and implementation
+ *
+ * </copyright>
+ */
+package org.eclipse.egf.eclipse.resources.mgt;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.egf.core.producer.InvocationException;
+import org.eclipse.egf.ftask.producer.context.ITaskProductionContext;
+import org.eclipse.egf.ftask.producer.invocation.ITaskProduction;
+
+/**
+ * Copy files to a plug-in folder.
+ *
+ * @author Guillaume Gebhart
+ */
+public class CopyFilesTask implements ITaskProduction {
+
+ private static final String CONTRACT_PLUGIN_ID_TAG = "plugin_id"; //$NON-NLS-1$
+ private static final String DESTINATION_PATH = "destination_path"; //$NON-NLS-1$
+ private static final String SOURCE_PATH = "source_path"; //$NON-NLS-1$
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.egf.ftask.producer.invocation.ITaskProduction#doExecute(org
+ * .eclipse.egf.ftask.producer.context.ITaskProductionContext,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void doExecute(ITaskProductionContext productionContext, IProgressMonitor monitor) throws InvocationException {
+ IFolder source = getSourceFolder(productionContext);
+ IFolder destination = getDestinationFolder(productionContext);
+ try {
+ copy(source, destination);
+ } catch (CoreException e) {
+ throw new InvocationException(e);
+ }
+ }
+
+ private void copy(IFolder source, IFolder destination) throws CoreException {
+ for (IResource resource : source.members())
+ {
+ if (resource.getType() == IResource.FILE)
+ {
+ copy((IFile) resource, destination);
+ }
+ }
+ }
+
+ private void copy(IFile file, IFolder destination) throws CoreException {
+ IFile destinationFile = destination.getFile(file.getName());
+ if (destinationFile.exists())
+ {
+ // The file exists. We have to delete it.
+ destinationFile.delete(true, new NullProgressMonitor());
+ }
+ file.copy(destinationFile.getFullPath(), true, new NullProgressMonitor());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.egf.ftask.producer.invocation.ITaskProduction#postExecute
+ * (org.eclipse.egf.ftask.producer.context.ITaskProductionContext,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void postExecute(ITaskProductionContext productionContext, IProgressMonitor monitor) throws InvocationException {
+ // refresh destination path
+ IFolder folder = getDestinationFolder(productionContext);
+ try {
+ folder.refreshLocal(IResource.DEPTH_INFINITE,
+ new NullProgressMonitor());
+ } catch (CoreException e) {
+ throw new InvocationException(e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.egf.ftask.producer.invocation.ITaskProduction#preExecute(
+ * org.eclipse.egf.ftask.producer.context.ITaskProductionContext,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void preExecute(ITaskProductionContext productionContext,
+ IProgressMonitor monitor) throws InvocationException {
+ // refresh source and destination path.
+ IFolder source = getSourceFolder(productionContext);
+ IFolder destination = getDestinationFolder(productionContext);
+ try {
+ source.refreshLocal(IResource.DEPTH_INFINITE,
+ new NullProgressMonitor());
+ destination.refreshLocal(IResource.DEPTH_INFINITE,
+ new NullProgressMonitor());
+ } catch (CoreException e) {
+ throw new InvocationException(e);
+ }
+ }
+
+ private String getPluginId(ITaskProductionContext context)
+ throws InvocationException {
+ return context.getInputValue(CONTRACT_PLUGIN_ID_TAG, String.class);
+ }
+
+ private String getDestinationPath(ITaskProductionContext context)
+ throws InvocationException {
+ return context.getInputValue(DESTINATION_PATH, String.class);
+ }
+
+ private String getSourcePath(ITaskProductionContext context)
+ throws InvocationException {
+ return context.getInputValue(SOURCE_PATH, String.class);
+ }
+
+ private IFolder getDestinationFolder(ITaskProductionContext context)
+ throws InvocationException {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getPluginId(context));
+ return project.getFolder(new Path(getDestinationPath(context)));
+ }
+
+ private IFolder getSourceFolder(ITaskProductionContext context)
+ throws InvocationException {
+ return ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(getSourcePath(context)));
+ }
+
+}
diff --git a/portfolio/org.eclipse.egf.eclipse.resources.mgt/src/org/eclipse/egf/eclipse/resources/mgt/PluginManagementTask.java b/portfolio/org.eclipse.egf.eclipse.resources.mgt/src/org/eclipse/egf/eclipse/resources/mgt/PluginManagementTask.java
new file mode 100644
index 000000000..72e9d1165
--- /dev/null
+++ b/portfolio/org.eclipse.egf.eclipse.resources.mgt/src/org/eclipse/egf/eclipse/resources/mgt/PluginManagementTask.java
@@ -0,0 +1,79 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2016 Thales Corporate Services S.A.S.
+ * 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:
+ * Thales Corporate Services S.A.S - initial API and implementation
+ *
+ * </copyright>
+ */
+package org.eclipse.egf.eclipse.resources.mgt;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.egf.core.producer.InvocationException;
+import org.eclipse.egf.ftask.producer.context.ITaskProductionContext;
+import org.eclipse.egf.ftask.producer.invocation.ITaskProduction;
+import org.eclipse.pde.core.IBaseModel;
+import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
+import org.eclipse.pde.internal.ui.util.ModelModification;
+import org.eclipse.pde.internal.ui.util.PDEModelUtility;
+
+/**
+ *
+ * @author Guillaume Gebhart
+ *
+ */
+public class PluginManagementTask implements ITaskProduction {
+ /**
+ * Contract tags used in the FC.
+ */
+ private static final String CONTRACT_PLUGIN_ID_TAG = "plugin_id"; //$NON-NLS-1$
+ private static final String CONTRACT_PLUGIN_ID_SUFFIX_TAG = "plugin_id_suffix"; //$NON-NLS-1$
+ private static final String CONTRACT_PLUGIN_VERSION_TAG = "plugin_version"; //$NON-NLS-1$
+ private static final Path METAFEST_PATH = new Path("/META-INF/MANIFEST.MF"); //$NON-NLS-1$
+
+ @SuppressWarnings("restriction")
+ public void doExecute(ITaskProductionContext arg0, IProgressMonitor arg1) throws InvocationException {
+ String plugin_id = arg0.getInputValue(CONTRACT_PLUGIN_ID_TAG, String.class);
+ String plugin_id_suffix = arg0.getInputValue(CONTRACT_PLUGIN_ID_SUFFIX_TAG, String.class);
+ final String plugin_version = arg0.getInputValue(CONTRACT_PLUGIN_VERSION_TAG, String.class);
+
+ final String plugin_name = plugin_id + ((plugin_id_suffix != null) ? plugin_id_suffix : ""); //$NON-NLS-1$;
+
+ IProject pdeProject = ResourcesPlugin.getWorkspace().getRoot().getProject(plugin_name);
+
+ if (pdeProject.exists())
+ {
+ IFile manifestFile = pdeProject.getFile(METAFEST_PATH);
+
+ PDEModelUtility.modifyModel(new ModelModification(manifestFile) {
+ @Override
+ protected void modifyModel(IBaseModel model, IProgressMonitor innerMonitor) throws CoreException {
+ ((IBundlePluginModelBase) model).getPluginBase().setVersion(plugin_version);
+ }
+ }, arg1);
+
+ }
+ }
+
+ public void postExecute(ITaskProductionContext arg0, IProgressMonitor arg1)
+ throws InvocationException {
+
+ }
+
+ public void preExecute(ITaskProductionContext arg0, IProgressMonitor arg1)
+ throws InvocationException {
+
+ }
+
+}

Back to the top