diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF index 9942804a4..db0d03650 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.equinox.p2.publisher.eclipse;singleton:=true -Bundle-Version: 1.6.200.qualifier +Bundle-Version: 1.6.300.qualifier Bundle-Activator: org.eclipse.pde.internal.publishing.Activator Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java index 66b25a4b9..b11fbfa74 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/equinox/p2/publisher/eclipse/ProductAction.java @@ -233,9 +233,8 @@ private Collection versionElements(Collection elemen for (IVersionedId element : elements) { Version elementVersion = element.getVersion(); if (elementVersion == null || Version.emptyVersion.equals(elementVersion)) { - Iterator advice = versionAdvice.iterator(); - while (advice.hasNext()) { - elementVersion = advice.next().getVersion(namespace, element.getId()); + for (IVersionAdvice advice : versionAdvice) { + elementVersion = advice.getVersion(namespace, element.getId()); break; } } diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/publishing/Utils.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/publishing/Utils.java index ff6ed03f0..85ee83a92 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/publishing/Utils.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/publishing/Utils.java @@ -14,17 +14,11 @@ *******************************************************************************/ package org.eclipse.pde.internal.publishing; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Dictionary; -import java.util.Enumeration; - +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.util.*; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.util.ManifestElement; import org.osgi.framework.BundleException; @@ -32,34 +26,13 @@ public final class Utils { static public void copy(File source, File destination) throws IOException { - InputStream in = null; - OutputStream out = null; - try { - in = new BufferedInputStream(new FileInputStream(source)); - out = new BufferedOutputStream(new FileOutputStream(destination)); - final byte[] buffer = new byte[8192]; - while (true) { - int bytesRead = -1; - bytesRead = in.read(buffer); - if (bytesRead == -1) - break; - out.write(buffer, 0, bytesRead); - } - } finally { - try { - if (in != null) - in.close(); - } finally { - if (out != null) - out.close(); - } - } + Files.copy(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING); } - public static boolean guessUnpack(BundleDescription bundle, String[] classpath) { - if (bundle == null) + public static boolean guessUnpack(BundleDescription bundle, List classpath) { + if (bundle == null) { return true; - + } @SuppressWarnings("unchecked") Dictionary properties = (Dictionary) bundle.getUserObject(); String shape = null; @@ -68,39 +41,26 @@ public static boolean guessUnpack(BundleDescription bundle, String[] classpath) } // launcher fragments are a special case, they have no bundle-classpath - if (bundle.getHost() != null && bundle.getName().startsWith(Constants.BUNDLE_EQUINOX_LAUNCHER)) + if (bundle.getHost() != null && bundle.getName().startsWith(Constants.BUNDLE_EQUINOX_LAUNCHER)) { return true; - - if (new File(bundle.getLocation()).isFile()) - return false; - - if (classpath.length == 0) + } + if (new File(bundle.getLocation()).isFile()) { return false; - - for (String classpath1 : classpath) { - if (classpath1.equals(".")) { //$NON-NLS-1$ - return false; - } } - return true; + return !classpath.isEmpty() && classpath.stream().noneMatch("."::equals); //$NON-NLS-1$ } - public static String[] getBundleClasspath(Dictionary manifest) { + public static List getBundleClasspath(Dictionary manifest) { String fullClasspath = getBundleManifestHeader(manifest, Constants.BUNDLE_CLASSPATH); - String[] result = new String[0]; try { if (fullClasspath != null) { - ManifestElement[] classpathEntries; - classpathEntries = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, fullClasspath); - result = new String[classpathEntries.length]; - for (int i = 0; i < classpathEntries.length; i++) { - result[i] = classpathEntries[i].getValue(); - } + return Arrays.stream(ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, + fullClasspath)).map(ManifestElement::getValue).toList(); } } catch (BundleException e) { //Ignore } - return result; + return List.of(); } /** diff --git a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java index 104c0a72f..ba6924a55 100644 --- a/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java +++ b/bundles/org.eclipse.equinox.p2.publisher.eclipse/src/org/eclipse/pde/internal/swt/tools/IconExe.java @@ -179,8 +179,7 @@ public static Collection replaceIcons(File launcherFile, ImageData[ raf.close(); return Collections.emptyList(); } - Iterator originalIconsIterator = iconInfo.iterator(); - while (originalIconsIterator.hasNext()) { + for (Iterator originalIconsIterator = iconInfo.iterator(); originalIconsIterator.hasNext();) { IconResInfo iconToReplace = originalIconsIterator.next(); for (ImageData iconToWrite : Arrays.asList(icons)) { if (iconToWrite == null)