tmf: Fix TestImportExportPackageWizard on Eclipse 4.6M5
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Fri, 29 Jan 2016 23:08:59 +0000 (18:08 -0500)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Sat, 30 Jan 2016 04:44:13 +0000 (23:44 -0500)
ArchiveFileExportOperation doesn't include linked resources by
default anymore, we have to call setIncludeLinkedResources(true).
Because of that, the exported package did not contain the trace
files. The method doesn't exist in Eclipse 4.5 so we have to use
reflection for the time that we want to support both versions of
Eclipse.

Change-Id: Ie7216e81fd3004e362e4200946e6ce81f81aa676
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/65503
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/project/wizards/tracepkg/importexport/TracePackageExportOperation.java

index 1456bdae924333ec4bdd31b223598ab1d699770a..65db332d884557943195b1db38fab3c07790a5a9 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.import
 import java.io.ByteArrayInputStream;
 import java.io.StringWriter;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Set;
@@ -293,6 +294,13 @@ public class TracePackageExportOperation extends AbstractTracePackageOperation {
     private IStatus exportToArchive(IProgressMonitor monitor, int totalWork) throws InvocationTargetException, InterruptedException {
         ArchiveFileExportOperation op = new ArchiveFileExportOperation(new ArrayList<>(fResources), getFileName());
         op.setCreateLeadupStructure(false);
+        //FIXME: Remove use of reflection when support for Eclipse 4.5 is dropped
+        try {
+            Method method = op.getClass().getMethod("setIncludeLinkedResources", boolean.class); //$NON-NLS-1$
+            method.invoke(op, true);
+        } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException e) {
+            // Ignored, setIncludeLinkedResources doesn't exist in Eclipse < 4.6
+        }
         op.setUseCompression(fUseCompression);
         op.setUseTarFormat(fUseTar);
         op.run(SubMonitor.convert(monitor).newChild(totalWork / 2));
This page took 0.026132 seconds and 5 git commands to generate.