Foreach and lambda cleanup
Change-Id: I8dd65b44956a4929a0ba08bf8a20476d57539b15
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AbstractScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AbstractScriptGenerator.java
index d0ab963..02d65fd 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AbstractScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AbstractScriptGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -546,9 +546,9 @@
Set<URI> uriSet = new HashSet<>();
uriSet.addAll(Arrays.asList(uris));
- for (int i = 0; i < uris.length; i++) {
+ for (URI element : uris) {
//try and find additional repos associated with a profile
- File uriFile = URIUtil.toFile(uris[i]);
+ File uriFile = URIUtil.toFile(element);
uriSet.addAll(getAssociatedRepositories(uriFile));
}
@@ -583,15 +583,15 @@
if (contexts == null)
return null;
ArrayList<URI> result = new ArrayList<>();
- for (int i = 0; i < contexts.length; i++) {
- File repo = URIUtil.toFile(contexts[i]);
+ for (URI context : contexts) {
+ File repo = URIUtil.toFile(context);
if (repo == null) {
//remote, not sure, just use it
- result.add(contexts[i]);
+ result.add(context);
} else {
String[] list = repo.list(repoFilter);
if (list != null && list.length > 0)
- result.add(contexts[i]);
+ result.add(context);
}
}
return result;
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AntLogAdapter.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AntLogAdapter.java
index d22ad74..21dbaac 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AntLogAdapter.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AntLogAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2013 IBM Corporation and others.
+ * Copyright (c) 2006, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -53,8 +53,8 @@
log.invoke(antLog, new Object[] {exceptionMessage, Integer.valueOf(mapLogLevels(status.getSeverity()))});
IStatus[] nestedStatus = status.getChildren();
if (nestedStatus != null) {
- for (int i = 0; i < nestedStatus.length; i++) {
- log(nestedStatus[i]);
+ for (IStatus element : nestedStatus) {
+ log(element);
}
}
} catch (IllegalArgumentException e) {
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleConfigScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleConfigScriptGenerator.java
index 9553e9f..521bb9f 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleConfigScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleConfigScriptGenerator.java
@@ -20,6 +20,7 @@
import java.io.File;
import java.io.IOException;
import java.util.*;
+import java.util.Map.Entry;
import java.util.jar.JarFile;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
@@ -98,9 +99,9 @@
if (getProductFile() == null)
return result;
String[] icons = os != null ? productFile.getIcons(os) : productFile.getIcons();
- for (int i = 0; i < icons.length; i++) {
+ for (String icon2 : icons) {
- String icon = Utils.makeRelative(new Path(icons[i]), new Path(productFile.getLocation().getParent())).toOSString();
+ String icon = Utils.makeRelative(new Path(icon2), new Path(productFile.getLocation().getParent())).toOSString();
String location = findFile(icon, true);
if (location == null) {
@@ -205,8 +206,7 @@
script.println("/>"); //$NON-NLS-1$
script.printTab();
- for (int i = 0; i < plugins.length; i++) {
- BundleDescription plugin = plugins[i];
+ for (BundleDescription plugin : plugins) {
script.printTab();
script.print("\t<iu "); //$NON-NLS-1$
script.printAttribute(ID, plugin.getSymbolicName(), true);
@@ -214,8 +214,7 @@
script.println("/>"); //$NON-NLS-1$
}
- for (int i = 0; i < features.length; i++) {
- BuildTimeFeature feature = features[i];
+ for (BuildTimeFeature feature : features) {
script.printTab();
script.print("\t<iu"); //$NON-NLS-1$
script.printAttribute(ID, getFeatureGroupId(feature), true);
@@ -223,8 +222,7 @@
script.println("/>"); //$NON-NLS-1$
}
- for (Iterator<BuildTimeFeature> iterator = rootFileProviders.iterator(); iterator.hasNext();) {
- BuildTimeFeature rootProvider = iterator.next();
+ for (BuildTimeFeature rootProvider : rootFileProviders) {
if (!(havePDEUIState() && rootProvider.getId().equals("org.eclipse.pde.container.feature"))) { //$NON-NLS-1$
script.printTab();
script.print("\t<iu"); //$NON-NLS-1$
@@ -400,8 +398,8 @@
if (rootFileProviders.size() == 0 || BuildDirector.p2Gathering)
return;
- for (Iterator<BuildTimeFeature> iter = rootFileProviders.iterator(); iter.hasNext();) {
- Properties featureProperties = getFeatureBuildProperties(iter.next());
+ for (BuildTimeFeature rootFileProvider : rootFileProviders) {
+ Properties featureProperties = getFeatureBuildProperties(rootFileProvider);
Utils.generatePermissions(featureProperties, configInfo, PROPERTY_ECLIPSE_BASE, script);
}
@@ -437,8 +435,7 @@
Map<String, String> properties = new HashMap<>(1);
properties.put(PROPERTY_DESTINATION_TEMP_FOLDER, Utils.getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS));
- for (int i = 0; i < plugins.length; i++) {
- BundleDescription plugin = plugins[i];
+ for (BundleDescription plugin : plugins) {
String placeToGather = getLocation(plugin);
script.printAntTask(DEFAULT_BUILD_SCRIPT_FILENAME, Utils.makeRelative(new Path(placeToGather), new Path(workingDirectory)).toOSString(), TARGET_GATHER_SOURCES, null, null, properties);
@@ -461,8 +458,7 @@
properties = new HashMap<>(1);
properties.put(PROPERTY_FEATURE_BASE, Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE));
- for (int i = 0; i < features.length; i++) {
- BuildTimeFeature feature = features[i];
+ for (BuildTimeFeature feature : features) {
String placeToGather = feature.getRootLocation();
script.printAntTask(DEFAULT_BUILD_SCRIPT_FILENAME, Utils.makeRelative(new Path(placeToGather), new Path(workingDirectory)).toOSString(), TARGET_GATHER_SOURCES, null, null, properties);
}
@@ -617,13 +613,11 @@
protected void generatePostProcessingTarget() {
script.printTargetDeclaration(TARGET_JAR_PROCESSING, null, null, null, null);
- for (int i = 0; i < plugins.length; i++) {
- BundleDescription plugin = plugins[i];
+ for (BundleDescription plugin : plugins) {
generatePostProcessingSteps(plugin.getSymbolicName(), plugin.getVersion().toString(), (String) shapeAdvisor.getFinalShape(plugin)[1], BUNDLE_TYPE);
}
- for (int i = 0; i < features.length; i++) {
- BuildTimeFeature feature = features[i];
+ for (BuildTimeFeature feature : features) {
generatePostProcessingSteps(feature.getId(), feature.getVersion(), (String) shapeAdvisor.getFinalShape(feature)[1], FEATURE_TYPE);
}
printCustomAssemblyAntCall(PROPERTY_POST + TARGET_JARUP, null);
@@ -633,15 +627,13 @@
protected void generateGatherBinPartsTarget() {
script.printTargetDeclaration(TARGET_GATHER_BIN_PARTS, null, null, null, null);
- for (int i = 0; i < plugins.length; i++) {
- BundleDescription plugin = plugins[i];
+ for (BundleDescription plugin : plugins) {
String placeToGather = getLocation(plugin);
printCustomGatherCall(ModelBuildScriptGenerator.getNormalizedName(plugin), Utils.makeRelative(new Path(placeToGather), new Path(workingDirectory)).toOSString(), PROPERTY_DESTINATION_TEMP_FOLDER, Utils.getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS), null);
}
Set<BuildTimeFeature> featureSet = new HashSet<>();
- for (int i = 0; i < features.length; i++) {
- BuildTimeFeature feature = features[i];
+ for (BuildTimeFeature feature : features) {
String placeToGather = feature.getRootLocation();
String featureFullName = feature.getId() + "_" + feature.getVersion(); //$NON-NLS-1$
printCustomGatherCall(featureFullName, Utils.makeRelative(new Path(placeToGather), new Path(workingDirectory)).toOSString(), PROPERTY_FEATURE_BASE, Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE), '/' + DEFAULT_FEATURE_LOCATION);
@@ -649,8 +641,7 @@
}
//This will generate gather.bin.parts call to features that provides files for the root
- for (Iterator<BuildTimeFeature> iter = rootFileProviders.iterator(); iter.hasNext();) {
- BuildTimeFeature feature = iter.next();
+ for (BuildTimeFeature feature : rootFileProviders) {
if (featureSet.contains(feature))
continue;
String placeToGather = feature.getRootLocation();
@@ -947,21 +938,20 @@
fileSets.add(new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE), false, null, "**/**", null, toExcludeFromArchive, null, productFile != null ? Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) : null, null, null)); //$NON-NLS-1$
fileSets.addAll(Arrays.asList(permissions));
} else {
- for (int i = 0; i < plugins.length; i++) {
- Object[] shape = shapeAdvisor.getFinalShape(plugins[i]);
+ for (BundleDescription plugin2 : plugins) {
+ Object[] shape = shapeAdvisor.getFinalShape(plugin2);
fileSets.add(new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_PLUGIN_LOCATION + '/' + (String) shape[0], shape[1] == ShapeAdvisor.FILE, null, null, null, null, null, Utils.getPropertyFormat(PROPERTY_PLUGIN_ARCHIVE_PREFIX) + '/' + (String) shape[0], null, null));
}
- for (int i = 0; i < features.length; i++) {
- Object[] shape = shapeAdvisor.getFinalShape(features[i]);
+ for (BuildTimeFeature feature2 : features) {
+ Object[] shape = shapeAdvisor.getFinalShape(feature2);
fileSets.add(new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_FEATURE_LOCATION + '/' + (String) shape[0], shape[1] == ShapeAdvisor.FILE, null, null, null, null, null, Utils.getPropertyFormat(PROPERTY_FEATURE_ARCHIVE_PREFIX) + '/' + (String) shape[0], null, null));
}
if (rootFileProviders.size() > 0) {
if (groupConfigs) {
List<Config> allConfigs = getConfigInfos();
- for (Iterator<Config> iter = allConfigs.iterator(); iter.hasNext();) {
- Config elt = iter.next();
+ for (Config elt : allConfigs) {
fileSets.add(new ZipFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + elt.toStringReplacingAny(".", ANY_STRING), false, null, "**/**", null, null, null, elt.toStringReplacingAny(".", ANY_STRING), null, null)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
} else {
@@ -988,29 +978,28 @@
String commonPermissions = ROOT_PREFIX + PERMISSIONS + '.';
ArrayList<ZipFileSet> fileSets = new ArrayList<>();
- for (Iterator<BuildTimeFeature> iter = getArchiveRootFileProviders().iterator(); iter.hasNext();) {
- Properties featureProperties = getFeatureBuildProperties(iter.next());
- for (Iterator<Map.Entry<Object, Object>> iter2 = featureProperties.entrySet().iterator(); iter2.hasNext();) {
- Map.Entry<Object, Object> permission = iter2.next();
+ for (BuildTimeFeature buildTimeFeature : getArchiveRootFileProviders()) {
+ Properties featureProperties = getFeatureBuildProperties(buildTimeFeature);
+ for (Entry<Object, Object> permission : featureProperties.entrySet()) {
String instruction = (String) permission.getKey();
String parameters = (String) permission.getValue();
String[] values = Utils.getArrayFromString(parameters);
- for (int i = 0; i < values.length; i++) {
- boolean isFile = !values[i].endsWith("/"); //$NON-NLS-1$
+ for (String value : values) {
+ boolean isFile = !value.endsWith("/"); //$NON-NLS-1$
if (instruction.startsWith(prefixPermissions)) {
- addedByPermissions.add(values[i]);
+ addedByPermissions.add(value);
if (zip)
- fileSets.add(new ZipFileSet(root + (isFile ? '/' + values[i] : ""), isFile, null, isFile ? null : values[i] + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + values[i] : ""), null, instruction.substring(prefixPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ fileSets.add(new ZipFileSet(root + (isFile ? '/' + value : ""), isFile, null, isFile ? null : value + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + value : ""), null, instruction.substring(prefixPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
else
- fileSets.add(new TarFileSet(root + (isFile ? '/' + values[i] : ""), isFile, null, isFile ? null : values[i] + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + values[i] : ""), null, instruction.substring(prefixPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ fileSets.add(new TarFileSet(root + (isFile ? '/' + value : ""), isFile, null, isFile ? null : value + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + value : ""), null, instruction.substring(prefixPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
continue;
}
if (instruction.startsWith(commonPermissions)) {
- addedByPermissions.add(values[i]);
+ addedByPermissions.add(value);
if (zip)
- fileSets.add(new ZipFileSet(root + (isFile ? '/' + values[i] : ""), isFile, null, isFile ? null : values[i] + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + values[i] : ""), null, instruction.substring(commonPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ fileSets.add(new ZipFileSet(root + (isFile ? '/' + value : ""), isFile, null, isFile ? null : value + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + value : ""), null, instruction.substring(commonPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
else
- fileSets.add(new TarFileSet(root + (isFile ? '/' + values[i] : ""), isFile, null, isFile ? null : values[i] + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + values[i] : ""), null, instruction.substring(commonPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ fileSets.add(new TarFileSet(root + (isFile ? '/' + value : ""), isFile, null, isFile ? null : value + "/**", null, null, null, Utils.getPropertyFormat(PROPERTY_ARCHIVE_PREFIX) + (isFile ? '/' + value : ""), null, instruction.substring(commonPermissions.length()))); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
continue;
}
}
@@ -1030,13 +1019,13 @@
fileSets.addAll(Arrays.asList(permissions));
} else {
//FileSet[] filesPlugins = new FileSet[plugins.length];
- for (int i = 0; i < plugins.length; i++) {
- Object[] shape = shapeAdvisor.getFinalShape(plugins[i]);
+ for (BundleDescription plugin2 : plugins) {
+ Object[] shape = shapeAdvisor.getFinalShape(plugin2);
fileSets.add(new TarFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_PLUGIN_LOCATION + '/' + (String) shape[0], shape[1] == ShapeAdvisor.FILE, null, null, null, null, null, Utils.getPropertyFormat(PROPERTY_PLUGIN_ARCHIVE_PREFIX) + '/' + (String) shape[0], null, null));
}
- for (int i = 0; i < features.length; i++) {
- Object[] shape = shapeAdvisor.getFinalShape(features[i]);
+ for (BuildTimeFeature feature2 : features) {
+ Object[] shape = shapeAdvisor.getFinalShape(feature2);
fileSets.add(new TarFileSet(Utils.getPropertyFormat(PROPERTY_ECLIPSE_BASE) + '/' + DEFAULT_FEATURE_LOCATION + '/' + (String) shape[0], shape[1] == ShapeAdvisor.FILE, null, null, null, null, null, Utils.getPropertyFormat(PROPERTY_FEATURE_ARCHIVE_PREFIX) + '/' + (String) shape[0], null, null));
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleScriptGenerator.java
index 40baacd..a249620 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssembleScriptGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -119,9 +119,9 @@
Collection<BuildTimeFeature> allFeatures = new LinkedHashSet<>();
Collection<BuildTimeFeature> features = new LinkedHashSet<>();
Collection<BuildTimeFeature> rootFiles = new LinkedHashSet<>();
- for (Iterator<Config> allConfigs = getConfigInfos().iterator(); allConfigs.hasNext();) {
+ for (Config config : getConfigInfos()) {
@SuppressWarnings("rawtypes")
- Collection[] configInfo = getConfigInfos(allConfigs.next());
+ Collection[] configInfo = getConfigInfos(config);
allPlugins.addAll(configInfo[0]);
allFeatures.addAll(configInfo[1]);
features.addAll(configInfo[2]);
@@ -129,8 +129,7 @@
}
basicGenerateAssembleConfigFileTargetCall(new Config("group", "group", "group"), allPlugins, allFeatures, features, rootFiles); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else {
- for (Iterator<Config> allConfigs = getConfigInfos().iterator(); allConfigs.hasNext();) {
- Config current = allConfigs.next();
+ for (Config current : getConfigInfos()) {
@SuppressWarnings("rawtypes")
Collection[] configInfo = getConfigInfos(current);
basicGenerateAssembleConfigFileTargetCall(current, configInfo[0], configInfo[1], configInfo[2], configInfo[3]);
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssemblyInformation.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssemblyInformation.java
index 984cb1e..66680a9 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssemblyInformation.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/AssemblyInformation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -28,8 +28,8 @@
public AssemblyInformation() {
// Initialize the content of the assembly information with the configurations
- for (Iterator<Config> iter = AbstractScriptGenerator.getConfigInfos().iterator(); iter.hasNext();) {
- assembleInformation.put(iter.next(), new AssemblyLevelConfigInfo());
+ for (Config config : AbstractScriptGenerator.getConfigInfos()) {
+ assembleInformation.put(config, new AssemblyLevelConfigInfo());
}
}
@@ -73,8 +73,8 @@
public Set<BundleDescription> getAllPlugins() {
Collection<AssemblyLevelConfigInfo> pluginsByConfig = assembleInformation.values();
Set<BundleDescription> result = new LinkedHashSet<>();
- for (Iterator<AssemblyLevelConfigInfo> iter = pluginsByConfig.iterator(); iter.hasNext();) {
- Collection<BundleDescription> allPlugins = iter.next().getPlugins();
+ for (AssemblyLevelConfigInfo assemblyLevelConfigInfo : pluginsByConfig) {
+ Collection<BundleDescription> allPlugins = assemblyLevelConfigInfo.getPlugins();
result.addAll(allPlugins);
}
return result;
@@ -83,8 +83,7 @@
public Collection<BundleDescription> getBinaryPlugins(Config config) {
Collection<BundleDescription> allPlugins = getPlugins(config);
Set<BundleDescription> result = new LinkedHashSet<>(allPlugins.size());
- for (Iterator<BundleDescription> iter = allPlugins.iterator(); iter.hasNext();) {
- BundleDescription bundle = iter.next();
+ for (BundleDescription bundle : allPlugins) {
Properties bundleProperties = ((Properties) bundle.getUserObject());
if (bundleProperties == null || bundleProperties.get(IS_COMPILED) == null || Boolean.FALSE == bundleProperties.get(IS_COMPILED))
result.add(bundle);
@@ -95,8 +94,7 @@
public Collection<BundleDescription> getCompiledPlugins(Config config) {
Collection<BundleDescription> allPlugins = getPlugins(config);
Set<BundleDescription> result = new LinkedHashSet<>(allPlugins.size());
- for (Iterator<BundleDescription> iter = allPlugins.iterator(); iter.hasNext();) {
- BundleDescription bundle = iter.next();
+ for (BundleDescription bundle : allPlugins) {
Properties bundleProperties = ((Properties) bundle.getUserObject());
if (bundleProperties != null && Boolean.TRUE == bundleProperties.get(IS_COMPILED))
result.add(bundle);
@@ -107,10 +105,9 @@
public Set<BundleDescription> getAllCompiledPlugins() {
Collection<AssemblyLevelConfigInfo> pluginsByConfig = assembleInformation.values();
Set<BundleDescription> result = new LinkedHashSet<>();
- for (Iterator<AssemblyLevelConfigInfo> iter2 = pluginsByConfig.iterator(); iter2.hasNext();) {
- Collection<BundleDescription> allPlugins = iter2.next().getPlugins();
- for (Iterator<BundleDescription> iter = allPlugins.iterator(); iter.hasNext();) {
- BundleDescription bundle = iter.next();
+ for (AssemblyLevelConfigInfo assemblyLevelConfigInfo : pluginsByConfig) {
+ Collection<BundleDescription> allPlugins = assemblyLevelConfigInfo.getPlugins();
+ for (BundleDescription bundle : allPlugins) {
if (!Utils.isBinary(bundle)) {
result.add(bundle);
}
@@ -122,8 +119,7 @@
public Collection<BuildTimeFeature> getCompiledFeatures(Config config) {
Collection<BuildTimeFeature> allFeatures = getFeatures(config);
ArrayList<BuildTimeFeature> result = new ArrayList<>(allFeatures.size());
- for (Iterator<BuildTimeFeature> iter = allFeatures.iterator(); iter.hasNext();) {
- BuildTimeFeature tmp = iter.next();
+ for (BuildTimeFeature tmp : allFeatures) {
if (!tmp.isBinary())
result.add(tmp);
}
@@ -133,8 +129,7 @@
public Collection<BuildTimeFeature> getBinaryFeatures(Config config) {
Collection<BuildTimeFeature> allFeatures = getFeatures(config);
ArrayList<BuildTimeFeature> result = new ArrayList<>(allFeatures.size());
- for (Iterator<BuildTimeFeature> iter = allFeatures.iterator(); iter.hasNext();) {
- BuildTimeFeature tmp = iter.next();
+ for (BuildTimeFeature tmp : allFeatures) {
if (tmp.isBinary())
result.add(tmp);
}
@@ -175,8 +170,7 @@
public void addRootFileProvider(BuildTimeFeature feature) {
if (rootFileProviders.contains(feature))
return;
- for (Iterator<BuildTimeFeature> iter = rootFileProviders.iterator(); iter.hasNext();) {
- BuildTimeFeature featureDescriptor = iter.next();
+ for (BuildTimeFeature featureDescriptor : rootFileProviders) {
if (feature == featureDescriptor)
return;
if (feature.getId().equals(featureDescriptor.getId()) && feature.getVersion().equals(featureDescriptor.getVersion()))
@@ -202,8 +196,7 @@
}
public void addFeature(BuildTimeFeature feature) {
- for (Iterator<BuildTimeFeature> iter = features.iterator(); iter.hasNext();) {
- BuildTimeFeature featureDescriptor = iter.next();
+ for (BuildTimeFeature featureDescriptor : features) {
if (feature.getId().equals(featureDescriptor.getId()) && (feature).getVersion().equals(featureDescriptor.getVersion()))
return;
}
@@ -215,8 +208,7 @@
}
public void removeFeature(BuildTimeFeature feature) {
- for (Iterator<BuildTimeFeature> iter = features.iterator(); iter.hasNext();) {
- BuildTimeFeature featureDescriptor = iter.next();
+ for (BuildTimeFeature featureDescriptor : features) {
if (feature.getId().equals(featureDescriptor.getId()) && feature.getVersion().equals(featureDescriptor.getVersion())) {
features.remove(featureDescriptor);
return;
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BuildApplication.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BuildApplication.java
index 0cd656a..26adf05 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BuildApplication.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BuildApplication.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2020 IBM Corporation and others.
+ * Copyright (c) 2007, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -43,8 +43,7 @@
}
private String[] updateArgs(String[] args) throws IOException {
- for (int i = 0; i < args.length; i++) {
- String string = args[i];
+ for (String string : args) {
if (string.equals("-f") || string.equals("-buildfile")) //$NON-NLS-1$ //$NON-NLS-2$
return args;
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BuildScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BuildScriptGenerator.java
index 710bc8e..7be8ec5 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BuildScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BuildScriptGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -140,10 +140,10 @@
protected void sortElements(List<String> features, List<String> plugins) {
if (elements == null)
return;
- for (int i = 0; i < elements.length; i++) {
- int index = elements[i].indexOf('@');
- String type = elements[i].substring(0, index);
- String element = elements[i].substring(index + 1);
+ for (String element2 : elements) {
+ int index = element2.indexOf('@');
+ String type = element2.substring(0, index);
+ String element = element2.substring(index + 1);
if (type.equals(PLUGIN) || type.equals(FRAGMENT))
plugins.add(element);
else if (type.equals(FEATURE))
@@ -159,12 +159,12 @@
protected void generateModels(List<String> models) throws CoreException {
ModelBuildScriptGenerator generator = null;
try {
- for (Iterator<String> iterator = models.iterator(); iterator.hasNext();) {
+ for (String model : models) {
generator = new ModelBuildScriptGenerator();
generator.setReportResolutionErrors(reportResolutionErrors);
generator.setIgnoreMissingPropertiesFile(ignoreMissingPropertiesFile);
//Filtering is not required here, since we are only generating the build for a plugin or a fragment
- String[] modelInfo = getNameAndVersion(iterator.next());
+ String[] modelInfo = getNameAndVersion(model);
generator.setBuildSiteFactory(siteFactory);
generator.setModelId(modelInfo[0], modelInfo[1]);
generator.setFeatureGenerator(new BuildDirector());
@@ -176,13 +176,13 @@
generator.generate();
}
if (bundlesToBuild != null)
- for (int i = 0; i < bundlesToBuild.length; i++) {
+ for (BundleDescription element : bundlesToBuild) {
generator = new ModelBuildScriptGenerator();
generator.setReportResolutionErrors(reportResolutionErrors);
generator.setIgnoreMissingPropertiesFile(ignoreMissingPropertiesFile);
//Filtering is not required here, since we are only generating the build for a plugin or a fragment
generator.setBuildSiteFactory(siteFactory);
- generator.setModel(bundlesToBuild[i]);
+ generator.setModel(element);
generator.setFeatureGenerator(new BuildDirector());
generator.setPluginPath(pluginPath);
generator.setDevEntries(devEntries);
@@ -247,8 +247,8 @@
if (generator != null) {
try {
String[] featureInfo = null;
- for (Iterator<String> i = features.iterator(); i.hasNext();) {
- featureInfo = getNameAndVersion(i.next());
+ for (String feature2 : features) {
+ featureInfo = getNameAndVersion(feature2);
BuildTimeFeature feature = getSite(false).findFeature(featureInfo[0], featureInfo[1], true);
generator.generate(feature);
}
@@ -298,8 +298,8 @@
if (sourceBundleFeatureId == null)
sourceBundleFeatureId = sourceBundleTemplateFeature + ".source"; //$NON-NLS-1$
- for (Iterator<? extends Object> iterator = allBundles.iterator(); iterator.hasNext();) {
- BundleDescription bundle = (BundleDescription) iterator.next();
+ for (Object bundle2 : allBundles) {
+ BundleDescription bundle = (BundleDescription) bundle2;
if (!Utils.isSourceBundle(bundle))
feature.addEntry(new FeatureEntry(bundle.getSymbolicName(), bundle.getVersion().toString(), true));
}
@@ -324,8 +324,7 @@
//For each configuration, save the version of all the features in a file
//and save the version of all the plug-ins in another file
- for (Iterator<Config> iter = configs.iterator(); iter.hasNext();) {
- Config config = iter.next();
+ for (Config config : configs) {
String configString = config.toStringReplacingAny("_", ANY_STRING); //$NON-NLS-1$
//Features
@@ -334,8 +333,7 @@
features.addAll(featureList);
String featureFile = DEFAULT_FEATURE_VERSION_FILENAME_PREFIX + '.' + configString + PROPERTIES_FILE_SUFFIX;
readVersions(versions, featureFile);
- for (Iterator<BuildTimeFeature> i = featureList.iterator(); i.hasNext();) {
- BuildTimeFeature feature = i.next();
+ for (BuildTimeFeature feature : featureList) {
recordVersion(feature.getId(), new Version(feature.getVersion()), versions);
}
saveVersions(versions, featureFile);
@@ -346,8 +344,7 @@
plugins.addAll(bundleList);
String pluginFile = DEFAULT_PLUGIN_VERSION_FILENAME_PREFIX + '.' + configString + PROPERTIES_FILE_SUFFIX;
readVersions(versions, pluginFile);
- for (Iterator<BundleDescription> i = bundleList.iterator(); i.hasNext();) {
- BundleDescription bundle = i.next();
+ for (BundleDescription bundle : bundleList) {
recordVersion(bundle.getSymbolicName(), bundle.getVersion(), versions);
}
saveVersions(versions, pluginFile);
@@ -357,8 +354,7 @@
versions.clear();
String featureFile = DEFAULT_FEATURE_VERSION_FILENAME_PREFIX + PROPERTIES_FILE_SUFFIX;
readVersions(versions, featureFile);
- for (Iterator<BuildTimeFeature> i = features.iterator(); i.hasNext();) {
- BuildTimeFeature feature = i.next();
+ for (BuildTimeFeature feature : features) {
recordVersion(feature.getId(), new Version(feature.getVersion()), versions);
}
saveVersions(versions, featureFile);
@@ -367,8 +363,7 @@
versions.clear();
String pluginVersion = DEFAULT_PLUGIN_VERSION_FILENAME_PREFIX + PROPERTIES_FILE_SUFFIX;
readVersions(versions, pluginVersion);
- for (Iterator<BundleDescription> i = plugins.iterator(); i.hasNext();) {
- BundleDescription bundle = i.next();
+ for (BundleDescription bundle : plugins) {
recordVersion(bundle.getSymbolicName(), bundle.getVersion(), versions);
}
saveVersions(versions, pluginVersion);
@@ -603,10 +598,10 @@
archivesFormat = new ArchiveTable(getConfigInfos().size() + 1);
String[] configs = Utils.getArrayFromStringWithBlank(formatString, "&"); //$NON-NLS-1$
- for (int i = 0; i < configs.length; i++) {
- String[] configElements = Utils.getArrayFromStringWithBlank(configs[i], ","); //$NON-NLS-1$
+ for (String config : configs) {
+ String[] configElements = Utils.getArrayFromStringWithBlank(config, ","); //$NON-NLS-1$
if (configElements.length != 3) {
- IStatus error = new Status(IStatus.ERROR, IPDEBuildConstants.PI_PDEBUILD, IPDEBuildConstants.EXCEPTION_CONFIG_FORMAT, NLS.bind(Messages.error_configWrongFormat, configs[i]), null);
+ IStatus error = new Status(IStatus.ERROR, IPDEBuildConstants.PI_PDEBUILD, IPDEBuildConstants.EXCEPTION_CONFIG_FORMAT, NLS.bind(Messages.error_configWrongFormat, config), null);
throw new CoreException(error);
}
String[] archAndFormat = Utils.getArrayFromStringWithBlank(configElements[2], "-"); //$NON-NLS-1$
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BundleHelper.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BundleHelper.java
index d969f85..9f8fb50 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BundleHelper.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/BundleHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -141,16 +141,15 @@
if (nativeCodeSpec != null) {
NativeCodeDescription[] possibleSuppliers = nativeCodeSpec.getPossibleSuppliers();
ArrayList<Filter> supplierFilters = new ArrayList<>(possibleSuppliers.length);
- for (int i = 0; i < possibleSuppliers.length; i++) {
- if (possibleSuppliers[i].getFilter() != null)
- supplierFilters.add(possibleSuppliers[i].getFilter());
+ for (NativeCodeDescription possibleSupplier : possibleSuppliers) {
+ if (possibleSupplier.getFilter() != null)
+ supplierFilters.add(possibleSupplier.getFilter());
}
if (supplierFilters.size() == 1)
nativeFilter = supplierFilters.get(0).toString();
else if (supplierFilters.size() > 1) {
StringBuffer buffer = new StringBuffer("(|"); //$NON-NLS-1$
- for (Iterator<Filter> iterator = supplierFilters.iterator(); iterator.hasNext();) {
- Filter filter = iterator.next();
+ for (Filter filter : supplierFilters) {
buffer.append(filter.toString());
}
buffer.append(")"); //$NON-NLS-1$
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FeatureGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FeatureGenerator.java
index 0b2adb2..72f6af0 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FeatureGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FeatureGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2017 IBM Corporation and others.
+ * Copyright (c) 2006, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -111,9 +111,9 @@
if (contents == null)
return new LinkedHashSet<>(0);
Set<Entry> result = new LinkedHashSet<>(contents.length);
- for (int i = 0; i < contents.length; i++)
- if (contents[i] != null) {
- StringTokenizer tokenizer = new StringTokenizer(contents[i], ";"); //$NON-NLS-1$
+ for (String content : contents)
+ if (content != null) {
+ StringTokenizer tokenizer = new StringTokenizer(content, ";"); //$NON-NLS-1$
Entry entry = new Entry(tokenizer.nextToken());
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
@@ -151,8 +151,7 @@
if (product != null) {
List<FeatureEntry> entries = product.getProductEntries();
- for (Iterator<FeatureEntry> iterator = entries.iterator(); iterator.hasNext();) {
- FeatureEntry featureEntry = iterator.next();
+ for (FeatureEntry featureEntry : entries) {
Entry newEntry = new Entry(featureEntry.getId(), featureEntry.getVersion());
if (featureEntry.unpackSet())
newEntry.addAttribute(Utils.EXTRA_UNPACK, String.valueOf(featureEntry.isUnpack()));
@@ -317,8 +316,7 @@
List<Config> configs = getConfigInfos();
// only include the fragments for the platforms we are attempting to build, since the others
// probably aren't around
- for (Iterator<Config> iterator = configs.iterator(); iterator.hasNext();) {
- Config config = iterator.next();
+ for (Config config : configs) {
String fragment = BUNDLE_EQUINOX_LAUNCHER + '.' + config.getWs() + '.' + config.getOs();
//macosx doesn't have the arch on its fragment
if (config.getOs().compareToIgnoreCase("macosx") != 0 || config.getArch().equals("x86_64")) //$NON-NLS-1$ //$NON-NLS-2$
@@ -465,8 +463,7 @@
}
}
- for (Iterator<Entry> iter = features.iterator(); iter.hasNext();) {
- Entry entry = iter.next();
+ for (Entry entry : features) {
String name = entry.getId();
String featureVersion = entry.getVersion();
if (verify) {
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FeatureWriter.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FeatureWriter.java
index 36e51a7..65bf03b 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FeatureWriter.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FeatureWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -134,10 +134,10 @@
printTag("update", parameters, true, true, true); //$NON-NLS-1$
}
- for (int i = 0; i < siteEntries.length; i++) {
+ for (URLEntry siteEntry : siteEntries) {
parameters.clear();
- parameters.put("url", siteEntries[i].getURL()); //$NON-NLS-1$
- parameters.put("label", siteEntries[i].getAnnotation()); //$NON-NLS-1$
+ parameters.put("url", siteEntry.getURL()); //$NON-NLS-1$
+ parameters.put("label", siteEntry.getAnnotation()); //$NON-NLS-1$
printTag("discovery", parameters, true, true, true); //$NON-NLS-1$
}
endTag("url"); //$NON-NLS-1$
@@ -146,17 +146,17 @@
public void printIncludes() throws CoreException {
FeatureEntry[] entries = feature.getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].isRequires() || entries[i].isPlugin())
+ for (FeatureEntry entry : entries) {
+ if (entry.isRequires() || entry.isPlugin())
continue;
parameters.clear();
try {
- parameters.put(ID, entries[i].getId());
- BuildTimeFeature tmpFeature = site.findFeature(entries[i].getId(), null, true);
+ parameters.put(ID, entry.getId());
+ BuildTimeFeature tmpFeature = site.findFeature(entry.getId(), null, true);
parameters.put(VERSION, tmpFeature.getVersion());
} catch (CoreException e) {
- String message = NLS.bind(Messages.exception_missingFeature, entries[i].getId());
+ String message = NLS.bind(Messages.exception_missingFeature, entry.getId());
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_FEATURE_MISSING, message, null));
}
@@ -168,8 +168,8 @@
boolean haveRequires = false;
FeatureEntry[] entries = feature.getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (!entries[i].isRequires())
+ for (FeatureEntry entry : entries) {
+ if (!entry.isRequires())
continue;
if (!haveRequires) {
@@ -177,15 +177,15 @@
haveRequires = true;
}
parameters.clear();
- if (entries[i].isPlugin()) {
- parameters.put(PLUGIN, entries[i].getId());
- parameters.put(VERSION, entries[i].getVersion());
+ if (entry.isPlugin()) {
+ parameters.put(PLUGIN, entry.getId());
+ parameters.put(VERSION, entry.getVersion());
} else {
//The import refers to a feature
- parameters.put(FEATURE, entries[i].getId());
- parameters.put(VERSION, entries[i].getVersion());
+ parameters.put(FEATURE, entry.getId());
+ parameters.put(VERSION, entry.getVersion());
}
- parameters.put("match", entries[i].getMatch()); //$NON-NLS-1$
+ parameters.put("match", entry.getMatch()); //$NON-NLS-1$
printTag("import", parameters, true, true, true); //$NON-NLS-1$
}
if (haveRequires)
@@ -214,32 +214,32 @@
public void printPlugins() throws CoreException {
FeatureEntry[] entries = feature.getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].isRequires() || !entries[i].isPlugin())
+ for (FeatureEntry entry : entries) {
+ if (entry.isRequires() || !entry.isPlugin())
continue;
parameters.clear();
- parameters.put(ID, entries[i].getId());
+ parameters.put(ID, entry.getId());
- String versionRequested = entries[i].getVersion();
+ String versionRequested = entry.getVersion();
BundleDescription effectivePlugin = null;
try {
- effectivePlugin = site.getRegistry().getResolvedBundle(entries[i].getId(), versionRequested);
+ effectivePlugin = site.getRegistry().getResolvedBundle(entry.getId(), versionRequested);
} catch (CoreException e) {
- String message = NLS.bind(Messages.exception_missingPlugin, entries[i].getId() + "_" + entries[i].getVersion()); //$NON-NLS-1$
+ String message = NLS.bind(Messages.exception_missingPlugin, entry.getId() + "_" + entry.getVersion()); //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_PLUGIN_MISSING, message, null));
}
if (effectivePlugin == null) {
- String message = NLS.bind(Messages.exception_missingPlugin, entries[i].getId() + "_" + entries[i].getVersion()); //$NON-NLS-1$
+ String message = NLS.bind(Messages.exception_missingPlugin, entry.getId() + "_" + entry.getVersion()); //$NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_PLUGIN_MISSING, message, null));
}
parameters.put(VERSION, effectivePlugin.getVersion().toString());
- if (entries[i].isFragment())
- parameters.put(FRAGMENT, String.valueOf(entries[i].isFragment()));
- parameters.put("os", entries[i].getOS()); //$NON-NLS-1$
- parameters.put("arch", entries[i].getArch()); //$NON-NLS-1$
- parameters.put("ws", entries[i].getWS()); //$NON-NLS-1$
- parameters.put("nl", entries[i].getNL()); //$NON-NLS-1$
- if (!entries[i].isUnpack())
+ if (entry.isFragment())
+ parameters.put(FRAGMENT, String.valueOf(entry.isFragment()));
+ parameters.put("os", entry.getOS()); //$NON-NLS-1$
+ parameters.put("arch", entry.getArch()); //$NON-NLS-1$
+ parameters.put("ws", entry.getWS()); //$NON-NLS-1$
+ parameters.put("nl", entry.getNL()); //$NON-NLS-1$
+ if (!entry.isUnpack())
parameters.put("unpack", Boolean.FALSE.toString()); //$NON-NLS-1$
// parameters.put("download-size", new Long(entries[i].getDownloadSize() != -1 ? entries[i].getDownloadSize() : 0)); //$NON-NLS-1$
// parameters.put("install-size", new Long(entries[i].getInstallSize() != -1 ? entries[i].getInstallSize() : 0)); //$NON-NLS-1$
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FetchScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FetchScriptGenerator.java
index 1295d8e..6c4daeb 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FetchScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FetchScriptGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -167,12 +167,12 @@
*/
private void generateFetchFilesForIncludedFeatures() throws CoreException {
FeatureEntry[] referencedFeatures = feature.getIncludedFeatureReferences();
- for (int i = 0; i < referencedFeatures.length; i++) {
- String featureId = referencedFeatures[i].getId();
+ for (FeatureEntry referencedFeature : referencedFeatures) {
+ String featureId = referencedFeature.getId();
if (featureProperties.containsKey(GENERATION_SOURCE_FEATURE_PREFIX + featureId))
continue;
- FetchScriptGenerator generator = new FetchScriptGenerator("feature@" + featureId + ',' + referencedFeatures[i].getVersion()); //$NON-NLS-1$
+ FetchScriptGenerator generator = new FetchScriptGenerator("feature@" + featureId + ',' + referencedFeature.getVersion()); //$NON-NLS-1$
generator.setDirectoryLocation(directoryLocation);
generator.setFetchChildren(fetchChildren);
generator.setFetchCache(fetchCache);
@@ -329,8 +329,8 @@
script.printTargetDeclaration(TARGET_FETCH_RECURSIVELY, null, FEATURES_RECURSIVELY, null, null);
FeatureEntry[] compiledFeatures = feature.getIncludedFeatureReferences();
- for (int i = 0; i < compiledFeatures.length; i++) {
- String featureId = compiledFeatures[i].getId();
+ for (FeatureEntry compiledFeature : compiledFeatures) {
+ String featureId = compiledFeature.getId();
if (featureProperties.containsKey(GENERATION_SOURCE_FEATURE_PREFIX + featureId)) {
String[] extraElementsToFetch = Utils.getArrayFromString(featureProperties.getProperty(GENERATION_SOURCE_FEATURE_PREFIX + featureId), ","); //$NON-NLS-1$
for (int j = 1; j < extraElementsToFetch.length; j++) {
@@ -341,7 +341,7 @@
}
//Included features can be available in the baseLocation.
- if (getRepositoryInfo(IFetchFactory.ELEMENT_TYPE_FEATURE + '@' + featureId, new Version(compiledFeatures[i].getVersion())) != null)
+ if (getRepositoryInfo(IFetchFactory.ELEMENT_TYPE_FEATURE + '@' + featureId, new Version(compiledFeature.getVersion())) != null)
script.printAntTask(Utils.getPropertyFormat(PROPERTY_BUILD_DIRECTORY) + '/' + FETCH_FILE_PREFIX + featureId + ".xml", null, TARGET_FETCH, null, null, null); //$NON-NLS-1$
else if (getSite(false).findFeature(featureId, null, false) == null) {
String message = NLS.bind(Messages.error_cannotFetchNorFindFeature, featureId);
@@ -426,9 +426,9 @@
FeatureEntry[] compiledChildren = feature.getPluginEntries();
String elementId;
- for (int i = 0; i < allChildren.length; i++) {
- elementId = allChildren[i].getId();
- Version versionId = new Version(allChildren[i].getVersion());
+ for (FeatureEntry child : allChildren) {
+ elementId = child.getId();
+ Version versionId = new Version(child.getVersion());
// We are not fetching the elements that are said to be generated, but we are fetching some elements that can be associated
if (featureProperties.containsKey(GENERATION_SOURCE_PLUGIN_PREFIX + elementId)) {
String[] extraElementsToFetch = Utils.getArrayFromString(featureProperties.getProperty(GENERATION_SOURCE_PLUGIN_PREFIX + elementId), ","); //$NON-NLS-1$
@@ -440,12 +440,12 @@
}
boolean generated = true;
- if (allChildren[i].isFragment())
- generated = generateFetchEntry(IFetchFactory.ELEMENT_TYPE_FRAGMENT + '@' + elementId, versionId, !Utils.isIn(compiledChildren, allChildren[i]));
+ if (child.isFragment())
+ generated = generateFetchEntry(IFetchFactory.ELEMENT_TYPE_FRAGMENT + '@' + elementId, versionId, !Utils.isIn(compiledChildren, child));
else
- generated = generateFetchEntry(IFetchFactory.ELEMENT_TYPE_PLUGIN + '@' + elementId, versionId, !Utils.isIn(compiledChildren, allChildren[i]));
+ generated = generateFetchEntry(IFetchFactory.ELEMENT_TYPE_PLUGIN + '@' + elementId, versionId, !Utils.isIn(compiledChildren, child));
if (generated == false)
- generateFetchEntry(IFetchFactory.ELEMENT_TYPE_BUNDLE + '@' + elementId, versionId, !Utils.isIn(compiledChildren, allChildren[i]));
+ generateFetchEntry(IFetchFactory.ELEMENT_TYPE_BUNDLE + '@' + elementId, versionId, !Utils.isIn(compiledChildren, child));
}
elementId = feature.getLicenseFeature();
@@ -582,8 +582,8 @@
// for some unknown reason, list() can return null.
// Just skip the children If it does.
if (list != null)
- for (int i = 0; i < list.length; i++)
- result &= clear(new java.io.File(root, list[i]));
+ for (String element2 : list)
+ result &= clear(new java.io.File(root, element2));
}
try {
if (root.exists())
@@ -655,8 +655,7 @@
return null;
Map.Entry<MapFileEntry, Object> bestMatch = null;
- for (Iterator<Entry<MapFileEntry, Object>> iterator = candidates.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry<MapFileEntry, Object> entry = iterator.next();
+ for (Entry<MapFileEntry, Object> entry : candidates.entrySet()) {
MapFileEntry aCandidate = entry.getKey();
//Find the exact match
if (aCandidate.v.equals(version))
@@ -681,8 +680,7 @@
if (directory != null)
return;
directory = new TreeMap<>();
- for (Iterator<Entry<Object, Object>> iter = directoryFile.entrySet().iterator(); iter.hasNext();) {
- Map.Entry<Object, Object> entry = iter.next();
+ for (Entry<Object, Object> entry : directoryFile.entrySet()) {
String[] entryInfo = Utils.getArrayFromString((String) entry.getKey());
if (entryInfo.length == 0)
continue;
@@ -749,8 +747,8 @@
* Generates additional targets submitted by the fetch task factory.
*/
private void generateAdditionalTargets() {
- for (Iterator<IFetchFactory> iter = encounteredTypeOfRepo.iterator(); iter.hasNext();) {
- iter.next().addTargets(script);
+ for (IFetchFactory iFetchFactory : encounteredTypeOfRepo) {
+ iFetchFactory.addTargets(script);
}
}
@@ -803,11 +801,11 @@
fetchTags = new Properties();
String[] entries = Utils.getArrayFromString(value);
- for (int i = 0; i < entries.length; i++) {
- if (entries[i] == null)
+ for (String entry : entries) {
+ if (entry == null)
continue;
- String[] elements = Utils.getArrayFromString(entries[i], ";"); //$NON-NLS-1$
+ String[] elements = Utils.getArrayFromString(entry, ";"); //$NON-NLS-1$
// REPO=tag;project=otherTag;project2=tag3
if (elements.length > 0) {
@@ -833,7 +831,7 @@
if (idx != -1)
overrides.setProperty(projectOverride.substring(0, idx), projectOverride.substring(idx + 1, projectOverride.length()).trim());
else
- throw new IllegalArgumentException("FetchTag " + entries[i]); //$NON-NLS-1$
+ throw new IllegalArgumentException("FetchTag " + entry); //$NON-NLS-1$
}
}
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java
index 01662dd..16e033f 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/FetchTaskFactoriesRegistry.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2004, 2017 Eclipse Foundation and others.
+ * Copyright (c) 2004, 2021 Eclipse Foundation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -92,8 +92,7 @@
*/
private void initializeRegistry() {
IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_FETCH_TASK_FACTORIES);
- for (int i = 0; i < extensions.length; i++) {
- IConfigurationElement extension = extensions[i];
+ for (IConfigurationElement extension : extensions) {
if (ELEM_FACTORY.equals(extension.getName())) {
String id = extension.getAttribute(ATTR_ID);
if (null != id && id.trim().length() > 0) {
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/P2ConfigScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/P2ConfigScriptGenerator.java
index 67405b1..9e99abe 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/P2ConfigScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/P2ConfigScriptGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 IBM Corporation and others.
+ * Copyright (c) 2009, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -75,8 +75,7 @@
Collection<Object> p = new LinkedHashSet<>();
Collection<Object> f = new LinkedHashSet<>();
Collection<BuildTimeFeature> r = new LinkedHashSet<>();
- for (Iterator<Config> iterator = getConfigInfos().iterator(); iterator.hasNext();) {
- Config config = iterator.next();
+ for (Config config : getConfigInfos()) {
p.addAll(assemblyInformation.getPlugins(config));
f.addAll(assemblyInformation.getFeatures(config));
r.addAll(assemblyInformation.getRootFileProviders(config));
@@ -142,8 +141,7 @@
ProductFile product = getProductFile();
if (product != null) {
List<Config> configs = getConfigInfos();
- for (Iterator<Config> iterator = configs.iterator(); iterator.hasNext();) {
- Config config = iterator.next();
+ for (Config config : configs) {
if (Config.genericConfig().equals(config))
continue;
script.printTab();
@@ -178,18 +176,18 @@
script.printAttribute("alias", Utils.getPropertyFormat(PROPERTY_SIGN_ALIAS), true); //$NON-NLS-1$
script.printAttribute("unsign", Utils.getPropertyFormat(PROPERTY_UNSIGN), true); //$NON-NLS-1$
script.print(" />\n"); //$NON-NLS-1$
- for (int i = 0; i < plugins.length; i++) {
+ for (BundleDescription plugin2 : plugins) {
script.printTab();
script.print("\t<plugin"); //$NON-NLS-1$
- script.printAttribute("id", plugins[i].getSymbolicName(), true); //$NON-NLS-1$
- script.printAttribute("version", plugins[i].getVersion().toString(), true); //$NON-NLS-1$
+ script.printAttribute("id", plugin2.getSymbolicName(), true); //$NON-NLS-1$
+ script.printAttribute("version", plugin2.getVersion().toString(), true); //$NON-NLS-1$
script.print(" /> \n"); //$NON-NLS-1$
}
- for (int i = 0; i < features.length; i++) {
+ for (BuildTimeFeature feature2 : features) {
script.printTab();
script.print("\t<feature"); //$NON-NLS-1$
- script.printAttribute("id", features[i].getId(), true); //$NON-NLS-1$
- script.printAttribute("version", features[i].getVersion(), true); //$NON-NLS-1$
+ script.printAttribute("id", feature2.getId(), true); //$NON-NLS-1$
+ script.printAttribute("version", feature2.getVersion(), true); //$NON-NLS-1$
script.print(" />\n"); //$NON-NLS-1$
}
script.println("</p2.process.artifacts>"); //$NON-NLS-1$
@@ -252,8 +250,7 @@
script.println("/>"); //$NON-NLS-1$
}
- for (Iterator<Config> iterator = getConfigInfos().iterator(); iterator.hasNext();) {
- Config config = iterator.next();
+ for (Config config : getConfigInfos()) {
if (Config.genericConfig().equals(config))
continue;
@@ -287,8 +284,7 @@
protected void generateCopyConfigs(ProductFile product, String productDir) {
if (!product.haveCustomConfig())
return;
- for (Iterator<Config> iterator = getConfigInfos().iterator(); iterator.hasNext();) {
- Config config = iterator.next();
+ for (Config config : getConfigInfos()) {
String entry = product.getConfigIniPath(config.getOs());
if (entry == null)
continue;
@@ -309,8 +305,7 @@
ArrayList<BuildTimeFeature> binaryFeatures = null;
if (product == null) {
binaryFeatures = new ArrayList<>();
- for (int i = 0; i < features.length; i++) {
- BuildTimeFeature feature = features[i];
+ for (BuildTimeFeature feature : features) {
if (feature.isBinary())
binaryFeatures.add(feature);
}
@@ -383,8 +378,7 @@
script.printAttribute(VERSION, version, true);
script.println("/>"); //$NON-NLS-1$
} else {
- for (int i = 0; i < features.length; i++) {
- BuildTimeFeature feature = features[i];
+ for (BuildTimeFeature feature : features) {
if (feature.isBinary()) {
binaryFeatures.add(feature);
script.print("\t<iu"); //$NON-NLS-1$
@@ -446,8 +440,7 @@
ArrayList<FileSet> binaryFeatures = new ArrayList<>();
ArrayList<FileSet> binaryBundles = new ArrayList<>();
script.printTargetDeclaration(TARGET_GATHER_BIN_PARTS, null, null, null, null);
- for (int i = 0; i < plugins.length; i++) {
- BundleDescription plugin = plugins[i];
+ for (BundleDescription plugin : plugins) {
Path pluginLocation = new Path(plugin.getLocation());
if (Utils.isBinary(plugin))
binaryBundles.add(new FileSet(pluginLocation.removeLastSegments(1).toOSString(), null, pluginLocation.lastSegment(), null, null, null, null));
@@ -456,8 +449,7 @@
}
Set<BuildTimeFeature> featureSet = BuildDirector.p2Gathering ? new HashSet<>() : null;
- for (int i = 0; i < features.length; i++) {
- BuildTimeFeature feature = features[i];
+ for (BuildTimeFeature feature : features) {
IPath featureLocation = new Path(feature.getRootLocation());
if (feature.isBinary()) {
binaryFeatures.add(new FileSet(featureLocation.removeLastSegments(1).toOSString(), null, featureLocation.lastSegment(), null, null, null, null));
@@ -469,8 +461,7 @@
}
//This will generate gather.bin.parts call to features that provides files for the root
- for (Iterator<BuildTimeFeature> iter = rootFileProviders.iterator(); iter.hasNext();) {
- BuildTimeFeature feature = iter.next();
+ for (BuildTimeFeature feature : rootFileProviders) {
if (featureSet.contains(feature))
continue;
if (isOldExecutableFeature(feature)) {
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ProductGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ProductGenerator.java
index 71de0df..2b18740 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ProductGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ProductGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2018 IBM Corporation and others.
+ * Copyright (c) 2006, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -61,8 +61,7 @@
return;
String location = null, fileList = null;
- for (Iterator<Config> iter = getConfigInfos().iterator(); iter.hasNext();) {
- Config config = iter.next();
+ for (Config config : getConfigInfos()) {
location = DEFAULT_PRODUCT_ROOT_FILES_DIR + '/' + config.toStringReplacingAny(".", ANY_STRING); //$NON-NLS-1$
String rootLocation = root + location;
@@ -255,8 +254,7 @@
}
List<Config> configs = getConfigInfos();
- for (int i = 0; i < configs.size(); i++) {
- Config config = configs.get(i);
+ for (Config config : configs) {
if (config.equals(Config.genericConfig()))
continue;
String fragmentName = BUNDLE_EQUINOX_LAUNCHER + '.' + config.getWs() + '.' + config.getOs();
@@ -301,12 +299,12 @@
Properties properties = AbstractScriptGenerator.readProperties(new Path(rootFeature.getRootLocation()).toOSString(), PROPERTIES_FILE, IStatus.OK);
String[] extraEntries = Utils.getArrayFromString(properties.getProperty(PRODUCT_PREFIX + productFile.getId()));
- for (int i = 0; i < extraEntries.length; i++) {
- Map<String, Object> entry = Utils.parseExtraBundlesString(extraEntries[i], true);
+ for (String extraEntry : extraEntries) {
+ Map<String, Object> entry = Utils.parseExtraBundlesString(extraEntry, true);
String id = (String) entry.get(Utils.EXTRA_ID);
Version version = (Version) entry.get(Utils.EXTRA_VERSION);
- boolean feature = extraEntries[i].startsWith("feature@");//$NON-NLS-1$
+ boolean feature = extraEntry.startsWith("feature@");//$NON-NLS-1$
VersionRange range = null;
String versionString = version.toString();
if (feature) {
@@ -360,8 +358,7 @@
List<FeatureEntry> pluginList = productFile.getProductEntries();
List<BundleDescription> results = new ArrayList<>(pluginList.size());
- for (Iterator<FeatureEntry> iter = pluginList.iterator(); iter.hasNext();) {
- FeatureEntry entry = iter.next();
+ for (FeatureEntry entry : pluginList) {
if (!entry.isPlugin())
continue;
@@ -464,8 +461,7 @@
BundleHelper helper = BundleHelper.getDefault();
Map<String, BundleInfo> infos = productFile.getConfigurationInfo();
boolean first = true;
- for (Iterator<BundleDescription> iter = bundles.iterator(); iter.hasNext();) {
- BundleDescription bundle = iter.next();
+ for (BundleDescription bundle : bundles) {
String id = bundle.getSymbolicName();
if (BUNDLE_OSGI.equals(id) || BUNDLE_EQUINOX_LAUNCHER.equals(id))
continue;
@@ -525,8 +521,8 @@
if (!properties.containsKey("osgi.bundles.defaultStartLevel")) //$NON-NLS-1$
properties.put("osgi.bundles.defaultStartLevel", "4"); //$NON-NLS-1$ //$NON-NLS-2$
- for (Iterator<Object> iterator = properties.keySet().iterator(); iterator.hasNext();) {
- String key = (String) iterator.next();
+ for (Object object : properties.keySet()) {
+ String key = (String) object;
buffer.append(key);
buffer.append('=');
buffer.append(properties.getProperty(key));
@@ -611,10 +607,10 @@
BundleDescription bundle = state.getResolvedBundle(plugin);
if (bundle != null) {
BundleDescription[] fragments = bundle.getFragments();
- for (int i = 0; i < fragments.length; i++) {
- Filter filter = helper.getFilter(fragments[i]);
+ for (BundleDescription fragment2 : fragments) {
+ Filter filter = helper.getFilter(fragment2);
if (filter == null || filter.match(environment)) {
- String fragmentId = fragments[i].getSymbolicName();
+ String fragmentId = fragment2.getSymbolicName();
if (productFile.containsPlugin(fragmentId)) {
buffer.append(",platform:/base/plugins/"); //$NON-NLS-1$
buffer.append(fragmentId);
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ShapeAdvisor.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ShapeAdvisor.java
index c70a959..91db790 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ShapeAdvisor.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ShapeAdvisor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -90,9 +90,8 @@
if (entries != null && entries.size() > 0) {
Boolean result = null;
boolean contradiction = false;
- for (@SuppressWarnings("rawtypes")
- Iterator iterator = entries.iterator(); iterator.hasNext();) {
- FeatureEntry entry = (FeatureEntry) iterator.next();
+ for (Object entry2 : entries) {
+ FeatureEntry entry = (FeatureEntry) entry2;
if (entry.unpackSet()) {
if (result == null)
result = Boolean.valueOf(entry.isUnpack());
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/SourceFeatureWriter.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/SourceFeatureWriter.java
index 541c5f2..5e2814f 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/SourceFeatureWriter.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/SourceFeatureWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -31,20 +31,20 @@
Map<String, String> parameters = new LinkedHashMap<>();
// TO CHECK Here we should have the raw list...
FeatureEntry[] features = feature.getEntries();
- for (int i = 0; i < features.length; i++) {
- if (features[i].isRequires() || features[i].isPlugin())
+ for (FeatureEntry feature2 : features) {
+ if (feature2.isRequires() || feature2.isPlugin())
continue;
parameters.clear();
- parameters.put(ID, features[i].getId());
- parameters.put(VERSION, features[i].getVersion());
- if (features[i].isOptional())
+ parameters.put(ID, feature2.getId());
+ parameters.put(VERSION, feature2.getVersion());
+ if (feature2.isOptional())
parameters.put("optional", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- if (features[i].getArch() != null)
- parameters.put("arch", features[i].getArch()); //$NON-NLS-1$
- if (features[i].getWS() != null)
- parameters.put("ws", features[i].getWS()); //$NON-NLS-1$
- if (features[i].getOS() != null)
- parameters.put("os", features[i].getOS()); //$NON-NLS-1$
+ if (feature2.getArch() != null)
+ parameters.put("arch", feature2.getArch()); //$NON-NLS-1$
+ if (feature2.getWS() != null)
+ parameters.put("ws", feature2.getWS()); //$NON-NLS-1$
+ if (feature2.getOS() != null)
+ parameters.put("os", feature2.getOS()); //$NON-NLS-1$
printTag("includes", parameters, true, true, true); //$NON-NLS-1$
}
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/Utils.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/Utils.java
index 454554f..1a5b509 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/Utils.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/Utils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -245,8 +245,8 @@
try {
URL[] result = new URL[target.size()];
int i = 0;
- for (Iterator<File> iter = target.iterator(); iter.hasNext();) {
- result[i++] = iter.next().toURL();
+ for (File file : target) {
+ result[i++] = file.toURL();
}
return result;
} catch (MalformedURLException e) {
@@ -300,12 +300,12 @@
public static String getStringFromCollection(Collection<?> collection, String separator) {
StringBuffer result = new StringBuffer();
boolean first = true;
- for (Iterator<?> i = collection.iterator(); i.hasNext();) {
+ for (Object name : collection) {
if (first)
first = false;
else
result.append(separator);
- result.append(i.next());
+ result.append(name);
}
return result.toString();
}
@@ -437,9 +437,9 @@
plugins = feature.getPluginEntries();
List<FeatureEntry> foundEntries = new ArrayList<>(5);
- for (int i = 0; i < plugins.length; i++) {
- if (plugins[i].getId().equals(pluginId))
- foundEntries.add(plugins[i]);
+ for (FeatureEntry plugin2 : plugins) {
+ if (plugin2.getId().equals(pluginId))
+ foundEntries.add(plugin2);
}
return foundEntries.toArray(new FeatureEntry[foundEntries.size()]);
@@ -462,14 +462,9 @@
if (featureDirectoryContent == null)
return null;
- for (int i = 0; i < featureDirectoryContent.length; i++) {
- if (featureDirectoryContent[i].isDirectory()) {
- File[] featureFiles = featureDirectoryContent[i].listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.equals(filename);
- }
- });
+ for (File element : featureDirectoryContent) {
+ if (element.isDirectory()) {
+ File[] featureFiles = element.listFiles((FilenameFilter) (dir, name) -> name.equals(filename));
if (featureFiles.length != 0)
collectedElements.add(featureFiles[0]);
}
@@ -478,8 +473,8 @@
}
public static boolean isIn(FeatureEntry[] array, FeatureEntry element) {
- for (int i = 0; i < array.length; i++) {
- if (array[i].getId().equals(element.getId()) && array[i].getVersion().equals(element.getVersion()))
+ for (FeatureEntry element2 : array) {
+ if (element2.getId().equals(element.getId()) && element2.getVersion().equals(element.getVersion()))
return true;
}
return false;
@@ -491,15 +486,14 @@
if (templateLocation.exists()) {
File[] files = templateLocation.listFiles();
if (files != null) {
- for (int i = 0; i < files.length; i++) {
- if (files[i].isDirectory()) {
- File subDir = new File(toDir, files[i].getName());
+ for (File file : files) {
+ if (file.isDirectory()) {
+ File subDir = new File(toDir, file.getName());
if (!subDir.exists())
subDir.mkdirs();
- Collection<String> subFiles = copyFiles(fromDir + '/' + files[i].getName(), toDir + '/' + files[i].getName());
- for (Iterator<String> iter = subFiles.iterator(); iter.hasNext();) {
- String sub = iter.next();
- copiedFiles.add(files[i].getName() + '/' + sub);
+ Collection<String> subFiles = copyFiles(fromDir + '/' + file.getName(), toDir + '/' + file.getName());
+ for (String sub : subFiles) {
+ copiedFiles.add(file.getName() + '/' + sub);
}
continue;
}
@@ -508,13 +502,13 @@
FileOutputStream outputStream = null;
try {
- inputStream = new FileInputStream(files[i]);
+ inputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
- String message = NLS.bind(Messages.exception_missingFile, files[i].getAbsolutePath());
+ String message = NLS.bind(Messages.exception_missingFile, file.getAbsolutePath());
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_READING_FILE, message, e));
}
- String fileToCopy = toDir + '/' + files[i].getName();
+ String fileToCopy = toDir + '/' + file.getName();
try {
outputStream = new FileOutputStream(fileToCopy);
} catch (FileNotFoundException e) {
@@ -529,7 +523,7 @@
try {
Utils.transferStreams(inputStream, outputStream);
- copiedFiles.add(files[i].getName());
+ copiedFiles.add(file.getName());
} catch (IOException e) {
String message = NLS.bind(Messages.exception_writingFile, fileToCopy);
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_WRITING_FILE, message, e));
@@ -545,8 +539,7 @@
if (initialList.size() == toExtract.size())
return initialList;
List<BundleDescription> result = new ArrayList<>(toExtract.size());
- for (Iterator<BundleDescription> iter = initialList.iterator(); iter.hasNext();) {
- BundleDescription element = iter.next();
+ for (BundleDescription element : initialList) {
if (toExtract.contains(element)) {
result.add(element);
if (result.size() == toExtract.size())
@@ -628,11 +621,9 @@
//merge the common properties into each of the configs
if (common.size() > 0 && mergeCommon) {
- for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext();) {
- String key = iterator.next();
+ for (String key : map.keySet()) {
Map<String, String> submap = map.get(key);
- for (Iterator<String> commonKeys = common.keySet().iterator(); commonKeys.hasNext();) {
- String commonKey = commonKeys.next();
+ for (String commonKey : common.keySet()) {
if (submap.containsKey(commonKey)) {
String existing = submap.get(commonKey);
submap.put(commonKey, existing + "," + common.get(commonKey)); //$NON-NLS-1$
@@ -658,8 +649,7 @@
String prefixLinks = ROOT_PREFIX + configInfix + '.' + LINK;
String commonPermissions = ROOT_PREFIX + PERMISSIONS + '.';
String commonLinks = ROOT_PREFIX + LINK;
- for (Iterator<Entry<Object, Object>> iter = featureProperties.entrySet().iterator(); iter.hasNext();) {
- Map.Entry<Object, Object> permission = iter.next();
+ for (Entry<Object, Object> permission : featureProperties.entrySet()) {
String instruction = (String) permission.getKey();
String parameters = removeEndingSlashes((String) permission.getValue());
if (instruction.startsWith(prefixPermissions)) {
@@ -793,17 +783,17 @@
} catch (BundleException e1) {
return Collections.emptyMap();
}
- for (int i = 0; i < elements.length; i++) {
- String key = elements[i].getValue();
+ for (ManifestElement element : elements) {
+ String key = element.getValue();
HashMap<String, String> subMap = new HashMap<>(2);
map.put(key, subMap);
- for (Enumeration<String> e = elements[i].getDirectiveKeys(); e != null && e.hasMoreElements();) {
+ for (Enumeration<String> e = element.getDirectiveKeys(); e != null && e.hasMoreElements();) {
String directive = e.nextElement();
- subMap.put(directive, elements[i].getDirective(directive));
+ subMap.put(directive, element.getDirective(directive));
}
- for (Enumeration<String> e = elements[i].getKeys(); e != null && e.hasMoreElements();) {
+ for (Enumeration<String> e = element.getKeys(); e != null && e.hasMoreElements();) {
String attribute = e.nextElement();
- subMap.put(attribute, elements[i].getAttribute(attribute));
+ subMap.put(attribute, element.getAttribute(attribute));
}
}
return map;
@@ -901,10 +891,10 @@
*/
static public int scan(StringBuffer buf, int start, String[] targets) {
for (int i = start; i < buf.length(); i++) {
- for (int j = 0; j < targets.length; j++) {
- if (i < buf.length() - targets[j].length()) {
- String match = buf.substring(i, i + targets[j].length());
- if (targets[j].equals(match))
+ for (String target : targets) {
+ if (i < buf.length() - target.length()) {
+ String match = buf.substring(i, i + target.length());
+ if (target.equals(match))
return i;
}
}
@@ -1015,21 +1005,21 @@
return null;
StringBuffer result = new StringBuffer();
- for (int i = 0; i < entries.length; i++) {
- String versionRequested = entries[i].getVersion();
+ for (FeatureEntry entry : entries) {
+ String versionRequested = entry.getVersion();
if (versionRequested == null)
versionRequested = GENERIC_VERSION_NUMBER;
- String id = entries[i].getId();
+ String id = entry.getId();
String newVersion = null;
if (!needsReplacement(versionRequested))
continue;
try {
- if (entries[i].isPlugin()) {
+ if (entry.isPlugin()) {
BundleDescription model = null;
if (assembly != null)
- model = assembly.getPlugin(entries[i].getId(), versionRequested);
+ model = assembly.getPlugin(entry.getId(), versionRequested);
if (model == null)
model = site.getRegistry().getResolvedBundle(id, versionRequested);
if (model != null)
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/AntScript.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/AntScript.java
index 108015d..fde7509 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/AntScript.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/AntScript.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -82,8 +82,7 @@
output.println(">"); //$NON-NLS-1$
indent++;
Set<Map.Entry<String, String>> entries = params.entrySet();
- for (Iterator<Map.Entry<String, String>> iter = entries.iterator(); iter.hasNext();) {
- Entry<String, String> entry = iter.next();
+ for (Entry<String, String> entry : entries) {
printParam(entry.getKey(), entry.getValue());
}
indent--;
@@ -107,11 +106,11 @@
printAttribute("categoryVersion", categoryVersion, false); //$NON-NLS-1$
output.println(">"); //$NON-NLS-1$
indent++;
- for (int i = 0; i < features.length; i++) {
- features[i].printAs("features", this); //$NON-NLS-1$
+ for (FileSet feature : features) {
+ feature.printAs("features", this); //$NON-NLS-1$
}
- for (int i = 0; i < bundles.length; i++) {
- bundles[i].printAs("bundles", this); //$NON-NLS-1$
+ for (FileSet bundle : bundles) {
+ bundle.printAs("bundles", this); //$NON-NLS-1$
}
for (int i = 0; contextMetadata != null && i < contextMetadata.length; i++) {
@@ -153,9 +152,9 @@
//printAttribute("filesetmanifest", filesetManifest, false); //$NON-NLS-1$
output.println(">"); //$NON-NLS-1$
indent++;
- for (int i = 0; i < files.length; i++)
- if (files[i] != null)
- files[i].print(this);
+ for (FileSet file : files)
+ if (file != null)
+ file.print(this);
indent--;
printTab();
output.println("</jar>"); //$NON-NLS-1$
@@ -208,9 +207,9 @@
printAttribute("duplicate", duplicate, false); //$NON-NLS-1$
output.println(">"); //$NON-NLS-1$
indent++;
- for (int i = 0; i < otherFiles.length; i++)
- if (otherFiles[i] != null)
- otherFiles[i].print(this);
+ for (FileSet otherFile : otherFiles)
+ if (otherFile != null)
+ otherFile.print(this);
indent--;
output.println("</jar>"); //$NON-NLS-1$
}
@@ -290,15 +289,13 @@
indent++;
if (properties != null) {
Set<Map.Entry<String, String>> entries = properties.entrySet();
- for (Iterator<Entry<String, String>> iter = entries.iterator(); iter.hasNext();) {
- Map.Entry<String, String> entry = iter.next();
+ for (Entry<String, String> entry : entries) {
printProperty(entry.getKey(), entry.getValue());
}
}
if (references != null) {
Set<Map.Entry<String, String>> entries = references.entrySet();
- for (Iterator<Entry<String, String>> iter = entries.iterator(); iter.hasNext();) {
- Map.Entry<String, String> entry = iter.next();
+ for (Entry<String, String> entry : entries) {
printTab();
print("<reference refid=\"" + entry.getKey() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
if (entry.getValue() != null) {
@@ -329,15 +326,13 @@
indent++;
if (properties != null) {
Set<Map.Entry<String, String>> entries = properties.entrySet();
- for (Iterator<Entry<String, String>> iter = entries.iterator(); iter.hasNext();) {
- Map.Entry<String, String> entry = iter.next();
+ for (Entry<String, String> entry : entries) {
printProperty(entry.getKey(), entry.getValue());
}
}
if (references != null) {
Set<Map.Entry<String, String>> entries = references.entrySet();
- for (Iterator<Entry<String, String>> iter = entries.iterator(); iter.hasNext();) {
- Map.Entry<String, String> entry = iter.next();
+ for (Entry<String, String> entry : entries) {
printTab();
print("<reference refid=\"" + entry.getKey() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
if (entry.getValue() != null) {
@@ -375,9 +370,9 @@
else {
output.println(">"); //$NON-NLS-1$
indent++;
- for (int i = 0; i < fileSets.length; i++)
- if (fileSets[i] != null)
- fileSets[i].print(this);
+ for (FileSet fileSet : fileSets)
+ if (fileSet != null)
+ fileSet.print(this);
indent--;
printTab();
output.println("</zip>"); //$NON-NLS-1$
@@ -417,9 +412,9 @@
else {
output.println(">"); //$NON-NLS-1$
indent++;
- for (int i = 0; i < fileSets.length; i++)
- if (fileSets[i] != null)
- fileSets[i].print(this);
+ for (FileSet fileSet : fileSets)
+ if (fileSet != null)
+ fileSet.print(this);
indent--;
printTab();
output.println("</tar>"); //$NON-NLS-1$
@@ -511,9 +506,9 @@
else {
output.println(">"); //$NON-NLS-1$
indent++;
- for (int i = 0; i < fileSets.length; i++)
- if (fileSets[i] != null)
- fileSets[i].print(this);
+ for (FileSet fileSet : fileSets)
+ if (fileSet != null)
+ fileSet.print(this);
indent--;
printTab();
output.println("</copy>"); //$NON-NLS-1$
@@ -527,9 +522,9 @@
printAttribute("failonerror", failOnError ? "true" : "false", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
output.println(">"); //$NON-NLS-1$
indent++;
- for (int i = 0; i < fileSets.length; i++)
- if (fileSets[i] != null)
- fileSets[i].print(this);
+ for (FileSet fileSet : fileSets)
+ if (fileSet != null)
+ fileSet.print(this);
indent--;
printTab();
output.println("</move>"); //$NON-NLS-1$
@@ -575,9 +570,9 @@
else {
output.println(">"); //$NON-NLS-1$
indent++;
- for (int i = 0; i < fileSets.length; i++)
- if (fileSets[i] != null)
- fileSets[i].print(this);
+ for (FileSet fileSet : fileSets)
+ if (fileSet != null)
+ fileSet.print(this);
indent--;
printTab();
output.println("</delete>"); //$NON-NLS-1$
@@ -614,8 +609,7 @@
else {
output.println(">"); //$NON-NLS-1$
indent++;
- for (int i = 0; i < lineArgs.size(); i++) {
- String arg = lineArgs.get(i);
+ for (String arg : lineArgs) {
printArg(arg, useValue && arg.indexOf(' ') == -1);
}
indent--;
@@ -695,8 +689,7 @@
if (paths != null) {
indent++;
- for (Iterator<Object> iter = paths.iterator(); iter.hasNext();) {
- Object path = iter.next();
+ for (Object path : paths) {
printTab();
print("<pathelement"); //$NON-NLS-1$
printAttribute("path", path.toString(), false); //$NON-NLS-1$
@@ -804,8 +797,7 @@
output.print("<"); //$NON-NLS-1$
output.print(tag);
Set<Map.Entry<String, String>> entries = arguments.entrySet();
- for (Iterator<Entry<String, String>> iter = entries.iterator(); iter.hasNext();) {
- Map.Entry<String, String> entry = iter.next();
+ for (Entry<String, String> entry : entries) {
printAttribute(entry.getKey(), entry.getValue(), true);
}
output.println(">"); //$NON-NLS-1$
@@ -834,8 +826,7 @@
output.print(tag);
if (null != arguments) {
Set<Map.Entry<String, String>> entries = arguments.entrySet();
- for (Iterator<Entry<String, String>> iter = entries.iterator(); iter.hasNext();) {
- Map.Entry<String, String> entry = iter.next();
+ for (Entry<String, String> entry : entries) {
printAttribute(entry.getKey(), entry.getValue(), true);
}
}
@@ -1059,8 +1050,7 @@
println("<macrodef name=\"" + macroName + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
indent++;
if (null != attributes)
- for (Iterator<String> iterator = attributes.iterator(); iterator.hasNext();) {
- String attribute = iterator.next();
+ for (String attribute : attributes) {
println("<attribute name=\"" + attribute + "\" />"); //$NON-NLS-1$ //$NON-NLS-2$
}
println("<sequential>"); //$NON-NLS-1$
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/JavacTask.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/JavacTask.java
index e64587b..f96b62c 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/JavacTask.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/ant/JavacTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -87,10 +87,10 @@
}
script.println("<classpath refid=\"" + classpathId + "\" />"); //$NON-NLS-1$ //$NON-NLS-2$
- for (int i = 0; i < srcdir.length; i++) {
+ for (String element : srcdir) {
script.printTab();
script.print("<src path="); //$NON-NLS-1$
- script.printQuotes(srcdir[i]);
+ script.printQuotes(element);
script.println("/>"); //$NON-NLS-1$
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/BuildDirector.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/BuildDirector.java
index 2a1e513..091fc21 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/BuildDirector.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/BuildDirector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -117,8 +117,7 @@
Set<BundleDescription> computedElements = new LinkedHashSet<>(5);
Properties featureProperties = getBuildProperties(feature);
FeatureEntry[] pluginList = feature.getPluginEntries();
- for (int i = 0; i < pluginList.length; i++) {
- FeatureEntry entry = pluginList[i];
+ for (FeatureEntry entry : pluginList) {
BundleDescription model;
if (selectConfigs(entry).size() == 0)
continue;
@@ -152,7 +151,7 @@
associateModelAndEntry(model, entry);
computedElements.add(model);
- collectElementToAssemble(pluginList[i]);
+ collectElementToAssemble(entry);
}
return computedElements;
}
@@ -251,9 +250,9 @@
protected void generateIncludedFeatureBuildFile(BuildTimeFeature feature) throws CoreException {
FeatureEntry[] referencedFeatures = feature.getIncludedFeatureReferences();
- for (int i = 0; i < referencedFeatures.length; i++) {
- String featureId = referencedFeatures[i].getId();
- String featureVersion = referencedFeatures[i].getVersion();
+ for (FeatureEntry referencedFeature : referencedFeatures) {
+ String featureId = referencedFeature.getId();
+ String featureVersion = referencedFeature.getVersion();
BuildTimeFeature nestedFeature = null;
Properties featureProperties = getBuildProperties(feature);
@@ -268,7 +267,7 @@
nestedFeature = getSite(false).findFeature(featureId, featureVersion, true);
generate(nestedFeature, false);
} catch (CoreException exception) {
- absorbExceptionIfOptionalFeature(referencedFeatures[i], exception);
+ absorbExceptionIfOptionalFeature(referencedFeature, exception);
}
}
}
@@ -392,8 +391,8 @@
// Loop through the included features, adding the version number parts
// to the running totals and storing the qualifier suffixes.
- for (int i = 0; i < referencedFeatures.length; i++) {
- BuildTimeFeature refFeature = getSite(false).findFeature(referencedFeatures[i].getId(), null, false);
+ for (FeatureEntry referencedFeature : referencedFeatures) {
+ BuildTimeFeature refFeature = getSite(false).findFeature(referencedFeature.getId(), null, false);
if (refFeature == null) {
qualifiers[++idx] = ""; //$NON-NLS-1$
continue;
@@ -425,9 +424,7 @@
// Loop through the included plug-ins and fragments, adding the version
// number parts to the running totals and storing the qualifiers.
- for (int i = 0; i < pluginList.length; i++) {
- FeatureEntry entry = pluginList[i];
-
+ for (FeatureEntry entry : pluginList) {
String versionRequested = entry.getVersion();
BundleDescription model = getSite(false).getRegistry().getBundle(entry.getId(), versionRequested, false);
Version version = null;
@@ -517,8 +514,7 @@
return;
Set<BundleDescription> generatedScripts = new HashSet<>(models.size());
- for (Iterator<BundleDescription> iterator = models.iterator(); iterator.hasNext();) {
- BundleDescription model = iterator.next();
+ for (BundleDescription model : models) {
if (generatedScripts.contains(model))
continue;
generatedScripts.add(model);
@@ -619,8 +615,7 @@
List<Config> correctConfigs = selectConfigs(featureToCollect);
// Here, we could sort if the feature is a common one or not by
// comparing the size of correctConfigs
- for (Iterator<Config> iter = correctConfigs.iterator(); iter.hasNext();) {
- Config config = iter.next();
+ for (Config config : correctConfigs) {
assemblyData.addFeature(config, featureToCollect);
}
}
@@ -700,8 +695,8 @@
String versionRequested = entryToCollect.getVersion();
BundleDescription effectivePlugin = null;
effectivePlugin = getSite(false).getRegistry().getResolvedBundle(entryToCollect.getId(), versionRequested);
- for (Iterator<Config> iter = correctConfigs.iterator(); iter.hasNext();) {
- assemblyData.addPlugin(iter.next(), effectivePlugin);
+ for (Config correctConfig : correctConfigs) {
+ assemblyData.addPlugin(correctConfig, effectivePlugin);
}
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/ClasspathComputer3_0.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/ClasspathComputer3_0.java
index 8dfac14..ca639bb 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/ClasspathComputer3_0.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/ClasspathComputer3_0.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -178,8 +178,8 @@
model.setUserObject(bundleProperties);
}
StringBuffer buffer = new StringBuffer();
- for (Iterator<Long> iterator = requiredIds.iterator(); iterator.hasNext();) {
- buffer.append(iterator.next().toString());
+ for (Long requiredId : requiredIds) {
+ buffer.append(requiredId.toString());
buffer.append(':');
}
bundleProperties.setProperty(PROPERTY_REQUIRED_BUNDLE_IDS, buffer.toString());
@@ -196,13 +196,13 @@
private void addVisiblePackagesFromState(StateHelper helper, BundleDescription model, Map<String, String> packages) {
ExportPackageDescription[] exports = helper.getVisiblePackages(model);
- for (int i = 0; i < exports.length; i++) {
- BundleDescription exporter = exports[i].getExporter();
+ for (ExportPackageDescription export : exports) {
+ BundleDescription exporter = export.getExporter();
if (exporter == null)
continue;
- boolean discouraged = helper.getAccessCode(model, exports[i]) == StateHelper.ACCESS_DISCOURAGED;
- String pattern = exports[i].getName().replaceAll("\\.", "/") + "/*"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ boolean discouraged = helper.getAccessCode(model, export) == StateHelper.ACCESS_DISCOURAGED;
+ String pattern = export.getName().replaceAll("\\.", "/") + "/*"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String rule = (discouraged ? '~' : '+') + pattern;
String packagesKey = exporter.getSymbolicName() + "_" + exporter.getVersion(); //$NON-NLS-1$
@@ -253,9 +253,9 @@
Properties modelProps = getBuildPropertiesFor(model);
if (modelProps != AbstractScriptGenerator.MissingProperties.getInstance())
ModelBuildScriptGenerator.specialDotProcessing(modelProps, libraries);
- for (int i = 0; i < libraries.length; i++) {
- addDevEntries(model, baseLocation, classpath, Utils.getArrayFromString(modelProps.getProperty(PROPERTY_OUTPUT_PREFIX + libraries[i])), modelProps);
- addPathAndCheck(model, base, libraries[i], modelProps, classpath);
+ for (String element : libraries) {
+ addDevEntries(model, baseLocation, classpath, Utils.getArrayFromString(modelProps.getProperty(PROPERTY_OUTPUT_PREFIX + element)), modelProps);
+ addPathAndCheck(model, base, element, modelProps, classpath);
}
}
@@ -272,22 +272,22 @@
if (fragments == null)
return;
- for (int i = 0; i < fragments.length; i++) {
- if (fragments[i] == generator.getModel())
+ for (BundleDescription fragment2 : fragments) {
+ if (fragment2 == generator.getModel())
continue;
- if (matchFilter(fragments[i]) == false)
+ if (matchFilter(fragment2) == false)
continue;
- requiredIds.add(Long.valueOf(fragments[i].getBundleId()));
+ requiredIds.add(Long.valueOf(fragment2.getBundleId()));
- if (!afterPlugin && isPatchFragment(fragments[i])) {
- addPluginLibrariesToFragmentLocations(plugin, fragments[i], classpath, baseLocation);
- addRuntimeLibraries(fragments[i], classpath, baseLocation);
+ if (!afterPlugin && isPatchFragment(fragment2)) {
+ addPluginLibrariesToFragmentLocations(plugin, fragment2, classpath, baseLocation);
+ addRuntimeLibraries(fragment2, classpath, baseLocation);
continue;
}
- if ((afterPlugin && !isPatchFragment(fragments[i])) || all) {
- addRuntimeLibraries(fragments[i], classpath, baseLocation);
- addPluginLibrariesToFragmentLocations(plugin, fragments[i], classpath, baseLocation);
+ if ((afterPlugin && !isPatchFragment(fragment2)) || all) {
+ addRuntimeLibraries(fragment2, classpath, baseLocation);
+ addPluginLibrariesToFragmentLocations(plugin, fragment2, classpath, baseLocation);
continue;
}
}
@@ -318,8 +318,8 @@
String root = generator.getLocation(fragment);
IPath base = Utils.makeRelative(new Path(root), new Path(baseLocation));
Properties modelProps = getBuildPropertiesFor(fragment);
- for (int i = 0; i < libraries.length; i++) {
- addPathAndCheck(fragment, base, libraries[i], modelProps, classpath);
+ for (String element : libraries) {
+ addPathAndCheck(fragment, base, element, modelProps, classpath);
}
}
@@ -415,8 +415,8 @@
HostSpecification host = model.getHost();
if (host != null) {
BundleDescription[] hosts = host.getHosts();
- for (int i = 0; i < hosts.length; i++)
- addPluginAndPrerequisites(hosts[i], classpath, location, pluginChain, addedPlugins);
+ for (BundleDescription host2 : hosts)
+ addPluginAndPrerequisites(host2, classpath, location, pluginChain, addedPlugins);
}
// Add the libraries
@@ -427,8 +427,7 @@
// based on the order specified by the plugin.xml. Both library that we compile and .jar provided are processed
String[] libraries = getClasspathEntries(model);
if (libraries != null) {
- for (int i = 0; i < libraries.length; i++) {
- String libraryName = libraries[i];
+ for (String libraryName : libraries) {
if (jar.getName(false).equals(libraryName))
continue;
@@ -445,16 +444,15 @@
} else {
// otherwise we add all the predecessor jars
String[] order = Utils.getArrayFromString(jarOrder);
- for (int i = 0; i < order.length; i++) {
- if (order[i].equals(jar.getName(false)))
+ for (String element : order) {
+ if (element.equals(jar.getName(false)))
break;
- addDevEntries(model, location, classpath, Utils.getArrayFromString((String) modelProperties.get(PROPERTY_OUTPUT_PREFIX + order[i])), modelProperties);
- addPathAndCheck(model, Path.EMPTY, order[i], modelProperties, classpath);
+ addDevEntries(model, location, classpath, Utils.getArrayFromString((String) modelProperties.get(PROPERTY_OUTPUT_PREFIX + element)), modelProperties);
+ addPathAndCheck(model, Path.EMPTY, element, modelProperties, classpath);
}
// Then we add all the "pure libraries" (the one that does not contain source)
String[] libraries = getClasspathEntries(model);
- for (int i = 0; i < libraries.length; i++) {
- String libraryName = libraries[i];
+ for (String libraryName : libraries) {
if (modelProperties.get(PROPERTY_SOURCE_PREFIX + libraryName) == null) {
//Potential pb: if the pure library is something that is being compiled (which is supposetly not the case, but who knows...)
//the user will get $basexx instead of $ws
@@ -468,10 +466,10 @@
if (extraClasspath != null) {
String[] extra = Utils.getArrayFromString(extraClasspath, ";,"); //$NON-NLS-1$
- for (int i = 0; i < extra.length; i++) {
+ for (String element : extra) {
//Potential pb: if the path refers to something that is being compiled (which is supposetly not the case, but who knows...)
//the user will get $basexx instead of $ws
- String[] toAdd = computeExtraPath(extra[i], classpath, location);
+ String[] toAdd = computeExtraPath(element, classpath, location);
if (toAdd != null && toAdd.length == 2)
addPathAndCheck(null, new Path(toAdd[0]), toAdd[1], modelProperties, classpath);
}
@@ -479,10 +477,10 @@
// add extra classpath if it is specified for the given jar
String[] jarSpecificExtraClasspath = jar.getExtraClasspath();
- for (int i = 0; i < jarSpecificExtraClasspath.length; i++) {
+ for (String element : jarSpecificExtraClasspath) {
//Potential pb: if the path refers to something that is being compiled (which is supposetly not the case, but who knows...)
//the user will get $basexx instead of $ws
- String[] toAdd = computeExtraPath(jarSpecificExtraClasspath[i], classpath, location);
+ String[] toAdd = computeExtraPath(element, classpath, location);
if (toAdd != null && toAdd.length == 2)
addPathAndCheck(null, new Path(toAdd[0]), toAdd[1], modelProperties, classpath);
}
@@ -559,8 +557,8 @@
}
// else exception
String cycleString = ""; //$NON-NLS-1$
- for (Iterator<BundleDescription> iter = pluginChain.iterator(); iter.hasNext();)
- cycleString += iter.next().toString() + ", "; //$NON-NLS-1$
+ for (BundleDescription bundleDescription : pluginChain)
+ cycleString += bundleDescription.toString() + ", "; //$NON-NLS-1$
cycleString += target.toString();
String message = NLS.bind(Messages.error_pluginCycle, cycleString);
throw new CoreException(new Status(IStatus.ERROR, IPDEBuildConstants.PI_PDEBUILD, EXCEPTION_CLASSPATH_CYCLE, message, null));
@@ -572,8 +570,8 @@
// as all required plugins may be required for compilation.
BundleDescription[] requires = PDEState.getDependentBundles(target);
pluginChain.add(target);
- for (int i = 0; i < requires.length; i++) {
- addPluginAndPrerequisites(requires[i], classpath, baseLocation, pluginChain, addedPlugins);
+ for (BundleDescription require : requires) {
+ addPluginAndPrerequisites(require, classpath, baseLocation, pluginChain, addedPlugins);
}
pluginChain.remove(target);
addedPlugins.add(target);
@@ -583,8 +581,7 @@
private boolean isAllowableCycle(BundleDescription target, List<BundleDescription> pluginChain) {
boolean haveNonBinary = false;
boolean inCycle = false;
- for (Iterator<BundleDescription> iterator = pluginChain.iterator(); iterator.hasNext();) {
- BundleDescription bundle = iterator.next();
+ for (BundleDescription bundle : pluginChain) {
if (bundle == target) {
inCycle = true;
haveNonBinary = !Utils.isBinary(bundle);
@@ -681,8 +678,8 @@
entries = generator.devEntries.getDevClassPath(model.getSymbolicName());
IPath root = Utils.makeRelative(new Path(generator.getLocation(model)), new Path(baseLocation));
- for (int i = 0; i < entries.length; i++) {
- addPathAndCheck(model, root, entries[i], modelProperties, classpath);
+ for (String entry : entries) {
+ addPathAndCheck(model, root, entry, modelProperties, classpath);
}
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/CompilationScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/CompilationScriptGenerator.java
index 8948ed5..3ab65d7 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/CompilationScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/CompilationScriptGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2018 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which accompanies this distribution,
@@ -96,8 +96,7 @@
script.printParallel(threadCount, threadsPerProcessor);
}
- for (Iterator<BundleDescription> iterator = sortedPlugins.iterator(); iterator.hasNext();) {
- BundleDescription bundle = iterator.next();
+ for (BundleDescription bundle : sortedPlugins) {
// Individual source bundles have empty build.jars targets, skip them
if (Utils.isSourceBundle(bundle))
continue;
@@ -125,9 +124,9 @@
String required = properties.getProperty(PROPERTY_REQUIRED_BUNDLE_IDS);
if (required != null) {
String[] ids = Utils.getArrayFromString(required, ":"); //$NON-NLS-1$
- for (int i = 0; i < ids.length; i++) {
+ for (String id2 : ids) {
try {
- if (bucket.contains(Long.valueOf(ids[i]))) {
+ if (bucket.contains(Long.valueOf(id2))) {
return true;
}
} catch (NumberFormatException e) {
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/FeatureBuildScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/FeatureBuildScriptGenerator.java
index 8e78aad..e77a75a 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/FeatureBuildScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/FeatureBuildScriptGenerator.java
@@ -107,8 +107,8 @@
}
/* need to do root files here because we won't be doing the gatherBinParts where it normally happens */
List<Config> configs = getConfigInfos();
- for (Iterator<Config> iter = configs.iterator(); iter.hasNext();) {
- director.getAssemblyData().addRootFileProvider(iter.next(), feature);
+ for (Config config : configs) {
+ director.getAssemblyData().addRootFileProvider(config, feature);
}
//Feature had a custom build script, we need to update the version in it.
@@ -204,8 +204,7 @@
private void generateBuildZipsTarget() throws CoreException {
StringBuffer zips = new StringBuffer();
Properties props = getBuildProperties();
- for (Iterator<Entry<Object, Object>> iterator = props.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry<Object, Object> entry = iterator.next();
+ for (Entry<Object, Object> entry : props.entrySet()) {
String key = (String) entry.getKey();
if (key.startsWith(PROPERTY_SOURCE_PREFIX) && key.endsWith(PROPERTY_ZIP_SUFFIX)) {
String zipName = key.substring(PROPERTY_SOURCE_PREFIX.length());
@@ -295,8 +294,7 @@
Properties properties = getBuildProperties();
Map<String, Map<String, String>> root = Utils.processRootProperties(properties, true);
Map<String, String> common = root.get(Utils.ROOT_COMMON);
- for (Iterator<Config> iter = getConfigInfos().iterator(); iter.hasNext();) {
- Config aConfig = iter.next();
+ for (Config aConfig : getConfigInfos()) {
String configKey = aConfig.toString("."); //$NON-NLS-1$
if (root.containsKey(configKey) || common.size() > 0)
director.getAssemblyData().addRootFileProvider(aConfig, feature);
@@ -484,16 +482,14 @@
script.printTargetEnd();
script.println();
- for (Iterator<Config> iter = getConfigInfos().iterator(); iter.hasNext();) {
- Config aConfig = iter.next();
+ for (Config aConfig : getConfigInfos()) {
script.printTargetDeclaration(TARGET_ROOTFILES_PREFIX + aConfig.toString("_"), null, null, null, null); //$NON-NLS-1$
generateCopyRootFiles(aConfig);
Utils.generatePermissions(getBuildProperties(), aConfig, PROPERTY_FEATURE_BASE, script);
script.printTargetEnd();
}
script.printTargetDeclaration(TARGET_ROOTFILES_PREFIX + "group_group_group", null, null, null, null); //$NON-NLS-1$
- for (Iterator<Config> iter = getConfigInfos().iterator(); iter.hasNext();) {
- Config aConfig = iter.next();
+ for (Config aConfig : getConfigInfos()) {
script.printAntCallTask(TARGET_ROOTFILES_PREFIX + aConfig.toString("_"), true, null);//.getPropertyFormat(PROPERTY_OS) + '_' + Utils.getPropertyFormat(PROPERTY_WS) + '_' + Utils.getPropertyFormat(PROPERTY_ARCH)) //$NON-NLS-1$
}
script.printTargetEnd();
@@ -515,8 +511,8 @@
Object[] folders = foldersToCopy.keySet().toArray();
String fileList = null;
- for (int i = 0; i < folders.length; i++) {
- String folder = (String) folders[i];
+ for (Object folder2 : folders) {
+ String folder = (String) folder2;
if (folder.equals(Utils.ROOT_LINK) || folder.startsWith(Utils.ROOT_PERMISSIONS))
continue;
fileList = foldersToCopy.get(folder);
@@ -642,8 +638,7 @@
script.println();
script.printTargetDeclaration(TARGET_ALL_PLUGINS, TARGET_INIT, null, null, null);
Set<BundleDescription> writtenCalls = new HashSet<>(sortedPlugins.size());
- for (Iterator<BundleDescription> iter = sortedPlugins.iterator(); iter.hasNext();) {
- BundleDescription current = iter.next();
+ for (BundleDescription current : sortedPlugins) {
//If it is not a compiled element, then we don't generate a call
Properties bundleProperties = (Properties) current.getUserObject();
if (bundleProperties == null || bundleProperties.get(IS_COMPILED) == null || bundleProperties.get(IS_COMPILED) == Boolean.FALSE)
@@ -653,8 +648,8 @@
continue;
writtenCalls.add(current);
FeatureEntry[] entries = Utils.getPluginEntry(feature, current.getSymbolicName(), false); //TODO This can be improved to use the value from the user object in the bundleDescription
- for (int j = 0; j < entries.length; j++) {
- List<Config> list = director.selectConfigs(entries[j]);
+ for (FeatureEntry entry : entries) {
+ List<Config> list = director.selectConfigs(entry);
if (list.size() == 0)
continue;
Map<String, String> params = null;
@@ -676,8 +671,7 @@
protected Set<BundleDescription> computeElements() throws CoreException {
Set<BundleDescription> computedElements = new LinkedHashSet<>(5);
FeatureEntry[] pluginList = feature.getPluginEntries();
- for (int i = 0; i < pluginList.length; i++) {
- FeatureEntry entry = pluginList[i];
+ for (FeatureEntry entry : pluginList) {
BundleDescription model;
if (director.selectConfigs(entry).size() == 0)
continue;
@@ -698,12 +692,12 @@
script.printTargetDeclaration(TARGET_ALL_FEATURES, TARGET_INIT, null, null, null);
//if (analyseIncludedFeatures) {
FeatureEntry[] features = feature.getIncludedFeatureReferences();
- for (int i = 0; i < features.length; i++) {
- String featureId = features[i].getId();
- String versionId = features[i].getVersion();
+ for (FeatureEntry feature2 : features) {
+ String featureId = feature2.getId();
+ String versionId = feature2.getVersion();
BuildTimeFeature includedFeature = getSite(false).findFeature(featureId, versionId, false);
if (includedFeature == null) {
- if (features[i].isOptional())
+ if (feature2.isOptional())
continue;
String message = NLS.bind(Messages.exception_missingFeature, featureId + ' ' + versionId);
throw new CoreException(new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_FEATURE_MISSING, message, null));
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/ModelBuildScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/ModelBuildScriptGenerator.java
index 5e44360..1232632 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/ModelBuildScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/ModelBuildScriptGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which accompanies this distribution,
@@ -337,8 +337,7 @@
File previousSrcRoot = Utils.getOldSourceLocation(model);
Set<BundleDescription> pluginsToGatherSourceFrom = featureGenerator.sourceToGather.getElementEntries().get(model.getSymbolicName());
if (pluginsToGatherSourceFrom != null) {
- for (Iterator<BundleDescription> iter = pluginsToGatherSourceFrom.iterator(); iter.hasNext();) {
- BundleDescription plugin = iter.next();
+ for (BundleDescription plugin : pluginsToGatherSourceFrom) {
// We are not trying to gather the source from ourself since we are generated and we know we don't have source...
if (plugin.getSymbolicName().equals(model.getSymbolicName()))
continue;
@@ -386,13 +385,13 @@
params.put(PROPERTY_BUILD_RESULT_FOLDER, Utils.getPropertyFormat(PROPERTY_BUILD_RESULT_FOLDER));
script.printSubantTask(Utils.getPropertyFormat(PROPERTY_CUSTOM_BUILD_CALLBACKS), PROPERTY_PRE + TARGET_CLEAN, customCallbacksBuildpath, customCallbacksFailOnError, customCallbacksInheritAll, params, null);
}
- for (int i = 0; i < availableJars.length; i++) {
- String jarName = availableJars[i].getName(true);
+ for (CompiledEntry availableJar : availableJars) {
+ String jarName = availableJar.getName(true);
String jarLocation = getJARLocation(jarName);
//avoid destructive cleans
if (jarLocation.equals("") || jarLocation.startsWith(DOT + DOT) || jarLocation.equals(Utils.getPropertyFormat(PROPERTY_BUILD_RESULT_FOLDER))) //$NON-NLS-1$
continue;
- if (availableJars[i].type == CompiledEntry.JAR) {
+ if (availableJar.type == CompiledEntry.JAR) {
script.printDeleteTask(null, jarLocation, null);
} else {
script.printDeleteTask(jarLocation, null, null);
@@ -429,14 +428,14 @@
List<IPath> destinations = new ArrayList<>(5);
Properties properties = getBuildProperties();
CompiledEntry[] availableJars = extractEntriesToCompile(properties);
- for (int i = 0; i < availableJars.length; i++) {
- String name = availableJars[i].getName(true);
+ for (CompiledEntry availableJar : availableJars) {
+ String name = availableJar.getName(true);
IPath destination = baseDestination.append(name).removeLastSegments(1); // remove the jar name
if (!destinations.contains(destination)) {
script.printMkdirTask(destination.toString());
destinations.add(destination);
}
- String logFolder = (availableJars[i].getType() == CompiledEntry.FOLDER) ? getJARLocation(name) : getTempJARFolderLocation(name);
+ String logFolder = (availableJar.getType() == CompiledEntry.FOLDER) ? getJARLocation(name) : getTempJARFolderLocation(name);
Path logPath = new Path(logFolder + Utils.getPropertyFormat(PROPERTY_LOG_EXTENSION));
FileSet logSet = new FileSet(logPath.removeLastSegments(1).toString(), null, logPath.lastSegment(), null, null, null, null);
script.printCopyTask(null, destination.toString(), new FileSet[] {logSet}, false, false);
@@ -481,8 +480,8 @@
List<IPath> destinations = new ArrayList<>(5);
Properties properties = getBuildProperties();
CompiledEntry[] availableJars = extractEntriesToCompile(properties);
- for (int i = 0; i < availableJars.length; i++) {
- String jar = availableJars[i].getName(true);
+ for (CompiledEntry availableJar : availableJars) {
+ String jar = availableJar.getName(true);
IPath destination = baseDestination.append(jar).removeLastSegments(1); // remove the jar name
if (!destinations.contains(destination)) {
script.printMkdirTask(destination.toString());
@@ -519,8 +518,8 @@
Properties properties = getBuildProperties();
CompiledEntry[] availableJars = extractEntriesToCompile(properties);
- for (int i = 0; i < availableJars.length; i++) {
- String jar = availableJars[i].getName(true);
+ for (CompiledEntry availableJar : availableJars) {
+ String jar = availableJar.getName(true);
String srcName = getSRCName(jar);
script.printAntCallTask("copy." + srcName, true, copyParams); //$NON-NLS-1$
@@ -567,11 +566,9 @@
Set<String> classpathEntries = new HashSet<>(Arrays.asList(getClasspathEntries(model)));
StringBuffer binaryFolders = new StringBuffer();
if (workspaceOutputFolders != null && workspaceOutputFolders.size() > 0) {
- for (Iterator<String> iterator = workspaceOutputFolders.keySet().iterator(); iterator.hasNext();) {
- String key = iterator.next();
+ for (String key : workspaceOutputFolders.keySet()) {
Set<IPath> paths = workspaceOutputFolders.get(key);
- for (Iterator<IPath> iterator2 = paths.iterator(); iterator2.hasNext();) {
- IPath path = iterator2.next();
+ for (IPath path : paths) {
if (binaryFolders.length() > 0)
binaryFolders.append(File.pathSeparator);
binaryFolders.append(Utils.getPropertyFormat(PROPERTY_BASEDIR) + '/' + path.toString());
@@ -597,8 +594,7 @@
classpathEntries.remove(EXPANDED_DOT);
}
}
- for (Iterator<String> iterator = classpathEntries.iterator(); iterator.hasNext();) {
- String entry = iterator.next();
+ for (String entry : classpathEntries) {
if (entry.equals(EXPANDED_DOT) || new File(model.getLocation(), entry).exists()) {
if (binaryFolders.length() > 0)
binaryFolders.append(File.pathSeparator);
@@ -667,8 +663,7 @@
if (Utils.isSourceBundle(model)) {
Set<BundleDescription> pluginsToGatherSourceFrom = getPluginSourceProviders();
if (pluginsToGatherSourceFrom != null) {
- for (Iterator<BundleDescription> iter = pluginsToGatherSourceFrom.iterator(); iter.hasNext();) {
- BundleDescription plugin = iter.next();
+ for (BundleDescription plugin : pluginsToGatherSourceFrom) {
IPath location = Utils.makeRelative(new Path(getLocation(plugin)), new Path(getLocation(model)));
Map<String, String> taskParams = new HashMap<>(1);
taskParams.put(PROPERTY_DESTINATION_TEMP_FOLDER, Utils.getPropertyFormat(PROPERTY_BUILD_RESULT_FOLDER) + "/sources"); //$NON-NLS-1$
@@ -705,12 +700,10 @@
//reuse workspace compiled classes
script.println(">"); //$NON-NLS-1$
- for (Iterator<String> iterator = workspaceOutputFolders.keySet().iterator(); iterator.hasNext();) {
- String key = iterator.next();
+ for (String key : workspaceOutputFolders.keySet()) {
Set<IPath> paths = workspaceOutputFolders.get(key);
- for (Iterator<IPath> pathIterator = paths.iterator(); pathIterator.hasNext();) {
- IPath path = pathIterator.next();
+ for (IPath path : paths) {
script.printTabs();
script.print(" <outputFolder "); //$NON-NLS-1$
script.printAttribute("library", key, true); //$NON-NLS-1$
@@ -728,8 +721,7 @@
private String[] getCompiledLocations() {
int count = 0;
String[] fileSetValues = new String[compiledJarNames.size()];
- for (Iterator<CompiledEntry> iter = compiledJarNames.iterator(); iter.hasNext();) {
- CompiledEntry entry = iter.next();
+ for (CompiledEntry entry : compiledJarNames) {
String formatedName = entry.getName(false) + (entry.getType() == CompiledEntry.FOLDER ? "/" : ""); //$NON-NLS-1$//$NON-NLS-2$
if (dotOnTheClasspath && formatedName.startsWith(EXPANDED_DOT)) {
continue;
@@ -808,8 +800,7 @@
if (Utils.isSourceBundle(model)) {
Set<BundleDescription> pluginsToGatherSourceFrom = getPluginSourceProviders();
if (pluginsToGatherSourceFrom != null) {
- for (Iterator<BundleDescription> iter = pluginsToGatherSourceFrom.iterator(); iter.hasNext();) {
- BundleDescription plugin = iter.next();
+ for (BundleDescription plugin : pluginsToGatherSourceFrom) {
IPath location = Utils.makeRelative(new Path(getLocation(plugin)), new Path(getLocation(model)));
Map<String, String> taskParams = new HashMap<>(1);
taskParams.put(PROPERTY_DESTINATION_TEMP_FOLDER, root);
@@ -893,8 +884,7 @@
private void generatePermissionProperties(String directory) throws CoreException {
getPermissionProperties();
- for (Iterator<Entry<Object, Object>> iter = permissionProperties.entrySet().iterator(); iter.hasNext();) {
- Map.Entry<Object, Object> permission = iter.next();
+ for (Entry<Object, Object> permission : permissionProperties.entrySet()) {
String instruction = (String) permission.getKey();
String parameters = (String) permission.getValue();
int index;
@@ -1115,20 +1105,20 @@
}
ProfileManager profileManager = getSite(false).getRegistry().getProfileManager();
- for (int i = 0; i < environments.length; i++) {
+ for (String environment : environments) {
if (bootClasspath == null)
- script.printConditionIsSet(PROPERTY_BUNDLE_BOOTCLASSPATH, Utils.getPropertyFormat(environments[i]), environments[i]);
+ script.printConditionIsSet(PROPERTY_BUNDLE_BOOTCLASSPATH, Utils.getPropertyFormat(environment), environment);
- source = profileManager.getJavacSource(environments[i]);
+ source = profileManager.getJavacSource(environment);
if (source == null)
- source = (String) environmentMappings.get(environments[i] + '.' + IXMLConstants.PROPERTY_JAVAC_SOURCE);
- target = profileManager.getJavacTarget(environments[i]);
+ source = (String) environmentMappings.get(environment + '.' + IXMLConstants.PROPERTY_JAVAC_SOURCE);
+ target = profileManager.getJavacTarget(environment);
if (target == null)
- target = (String) environmentMappings.get(environments[i] + '.' + IXMLConstants.PROPERTY_JAVAC_TARGET);
+ target = (String) environmentMappings.get(environment + '.' + IXMLConstants.PROPERTY_JAVAC_TARGET);
if (javacSource == null && source != null)
- script.printConditionIsSet(PROPERTY_BUNDLE_JAVAC_SOURCE, source, environments[i]);
+ script.printConditionIsSet(PROPERTY_BUNDLE_JAVAC_SOURCE, source, environment);
if (javacTarget == null && target != null)
- script.printConditionIsSet(PROPERTY_BUNDLE_JAVAC_TARGET, target, environments[i]);
+ script.printConditionIsSet(PROPERTY_BUNDLE_JAVAC_TARGET, target, environment);
}
if (javacSource == null)
@@ -1189,8 +1179,7 @@
private void generateBuildZipsTarget() throws CoreException {
StringBuffer zips = new StringBuffer();
Properties props = getBuildProperties();
- for (Iterator<Entry<Object, Object>> iterator = props.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry<Object, Object> entry = iterator.next();
+ for (Entry<Object, Object> entry : props.entrySet()) {
String key = (String) entry.getKey();
if (key.startsWith(PROPERTY_SOURCE_PREFIX) && key.endsWith(PROPERTY_ZIP_SUFFIX)) {
String zipName = key.substring(PROPERTY_SOURCE_PREFIX.length());
@@ -1223,8 +1212,8 @@
CompiledEntry[] availableJars = extractEntriesToCompile(properties);
compiledJarNames = new ArrayList<>(availableJars.length);
Map<String, CompiledEntry> jars = new HashMap<>(availableJars.length);
- for (int i = 0; i < availableJars.length; i++)
- jars.put(availableJars[i].getName(false), availableJars[i]);
+ for (CompiledEntry availableJar : availableJars)
+ jars.put(availableJar.getName(false), availableJar);
// Put the jars in a correct compile order
String jarOrder = (String) getBuildProperties().get(PROPERTY_JAR_ORDER);
@@ -1232,19 +1221,18 @@
if (jarOrder != null) {
String[] order = Utils.getArrayFromString(jarOrder);
- for (int i = 0; i < order.length; i++) {
- CompiledEntry jar = jars.get(order[i]);
+ for (String element : order) {
+ CompiledEntry jar = jars.get(element);
if (jar == null)
continue;
compiledJarNames.add(jar);
generateCompilationTarget(classpath.getClasspath(pluginModel, jar), jar);
generateSRCTarget(jar);
- jars.remove(order[i]);
+ jars.remove(element);
}
}
- for (Iterator<CompiledEntry> iterator = jars.values().iterator(); iterator.hasNext();) {
- CompiledEntry jar = iterator.next();
+ for (CompiledEntry jar : jars.values()) {
compiledJarNames.add(jar);
generateCompilationTarget(classpath.getClasspath(pluginModel, jar), jar);
generateSRCTarget(jar);
@@ -1259,8 +1247,8 @@
params.put(PROPERTY_BUILD_RESULT_FOLDER, Utils.getPropertyFormat(PROPERTY_BUILD_RESULT_FOLDER));
script.printSubantTask(Utils.getPropertyFormat(PROPERTY_CUSTOM_BUILD_CALLBACKS), PROPERTY_PRE + TARGET_BUILD_JARS, customCallbacksBuildpath, customCallbacksFailOnError, customCallbacksInheritAll, params, null);
}
- for (Iterator<CompiledEntry> iter = compiledJarNames.iterator(); iter.hasNext();) {
- String name = iter.next().getName(false);
+ for (CompiledEntry compiledJarName : compiledJarNames) {
+ String name = compiledJarName.getName(false);
script.printAvailableTask(name, replaceVariables(getJARLocation(name), true));
script.printAntCallTask(name, true, null);
}
@@ -1276,8 +1264,8 @@
if (customBuildCallbacks != null) {
script.printSubantTask(Utils.getPropertyFormat(PROPERTY_CUSTOM_BUILD_CALLBACKS), PROPERTY_PRE + TARGET_BUILD_SOURCES, customCallbacksBuildpath, customCallbacksFailOnError, customCallbacksInheritAll, params, null);
}
- for (Iterator<CompiledEntry> iter = compiledJarNames.iterator(); iter.hasNext();) {
- String jarName = iter.next().getName(false);
+ for (CompiledEntry compiledJarName : compiledJarNames) {
+ String jarName = compiledJarName.getName(false);
String srcName = getSRCName(jarName);
script.printAvailableTask(srcName, getSRCLocation(jarName));
script.printAntCallTask(srcName, true, null);
@@ -1298,8 +1286,8 @@
script.printStartTag("eclipse.logCompileError", arguments); //$NON-NLS-1$
script.incrementIdent();
arguments.clear();
- for (Iterator<Object> iter = getPrequisitePaths().iterator(); iter.hasNext();) {
- arguments.put("name", iter.next().toString()); //$NON-NLS-1$
+ for (Object object : getPrequisitePaths()) {
+ arguments.put("name", object.toString()); //$NON-NLS-1$
script.printElement("include", arguments); //$NON-NLS-1$
}
script.decrementIdent();
@@ -1317,9 +1305,9 @@
if (required != null) {
State state = getSite(false).getRegistry().getState();
String[] ids = Utils.getArrayFromString(required, ":"); //$NON-NLS-1$
- for (int i = 0; i < ids.length; i++) {
+ for (String id2 : ids) {
try {
- BundleDescription bundle = state.getBundle(Long.valueOf(ids[i]).longValue());
+ BundleDescription bundle = state.getBundle(Long.valueOf(id2).longValue());
if (bundle != null && !Utils.isBinary(bundle)) {
Path bundleLocation = new Path(bundle.getLocation());
results.add(bundleLocation.append("compilation.problem")); //$NON-NLS-1$
@@ -1410,8 +1398,8 @@
if (customEncodingsVal != null) {
String[] encodings = customEncodingsVal.split(","); //$NON-NLS-1$
if (encodings.length > 0) {
- for (int i = 0; i < encodings.length; i++) {
- writer.write(ADAPTER_ENCODING + encodings[i] + "\n"); //$NON-NLS-1$
+ for (String encoding : encodings) {
+ writer.write(ADAPTER_ENCODING + encoding + "\n"); //$NON-NLS-1$
}
}
}
@@ -1419,8 +1407,8 @@
Properties data = (Properties) model.getUserObject();
if (data == null || !data.containsKey(PROPERTY_CONVERTED_MANIFEST)) {
if (classpath.size() > 0 && classpath.get(0) instanceof ClasspathElement) {
- for (Iterator<Object> iterator = classpath.iterator(); iterator.hasNext();) {
- ClasspathElement element = (ClasspathElement) iterator.next();
+ for (Object object : classpath) {
+ ClasspathElement element = (ClasspathElement) object;
if (element.getPath() != null && element.getAccessRules().length() > 0) {
String path = null;
if (element.getSubPath() == null)
@@ -1467,8 +1455,8 @@
}
List<Object> extracted = new ArrayList<>(classpath.size());
- for (Iterator<Object> iterator = classpath.iterator(); iterator.hasNext();) {
- ClasspathElement element = (ClasspathElement) iterator.next();
+ for (Object object : classpath) {
+ ClasspathElement element = (ClasspathElement) object;
if (element.getSubPath() == null)
extracted.add(element);
@@ -1531,8 +1519,7 @@
workspaceFiles = new FileSet[paths.size()];
int i = 0;
- for (Iterator<IPath> iterator = paths.iterator(); iterator.hasNext();) {
- IPath path = iterator.next();
+ for (IPath path : paths) {
workspaceFiles[i++] = new FileSet(Utils.getPropertyFormat(PROPERTY_BASEDIR) + "/" + path.toOSString(), null, null, null, "**/package.htm*", null, null); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -1695,8 +1682,7 @@
public static CompiledEntry[] extractEntriesToCompile(Properties properties, BundleDescription model) throws CoreException {
List<CompiledEntry> result = new ArrayList<>(5);
int prefixLength = PROPERTY_SOURCE_PREFIX.length();
- for (Iterator<Entry<Object, Object>> iterator = properties.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry<Object, Object> entry = iterator.next();
+ for (Entry<Object, Object> entry : properties.entrySet()) {
String key = (String) entry.getKey();
if (!(key.startsWith(PROPERTY_SOURCE_PREFIX)))
continue;
@@ -1729,9 +1715,9 @@
filterNonExistingSourceFolders(sources);
FileSet[] fileSets = new FileSet[sources.length];
int count = 0;
- for (int i = 0; i < sources.length; i++) {
- if (sources[i] != null)
- fileSets[count++] = new FileSet(sources[i], null, getFormattedSourceFileExtensions(), null, null, null, null);
+ for (String element : sources) {
+ if (element != null)
+ fileSets[count++] = new FileSet(element, null, getFormattedSourceFileExtensions(), null, null, null, null);
}
String srcLocation = getSRCLocation(name);
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/SourceGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/SourceGenerator.java
index 1f8a942..7bad03d 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/SourceGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/builder/SourceGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -93,8 +93,7 @@
private void collectSourceEntries(BuildTimeFeature feature) throws CoreException {
FeatureEntry[] pluginList = feature.getPluginEntries();
- for (int i = 0; i < pluginList.length; i++) {
- FeatureEntry entry = pluginList[i];
+ for (FeatureEntry entry : pluginList) {
BundleDescription model;
if (director.selectConfigs(entry).size() == 0)
continue;
@@ -104,7 +103,7 @@
if (model == null)
continue;
- collectSourcePlugins(feature, pluginList[i], model);
+ collectSourcePlugins(feature, entry, model);
}
}
@@ -122,8 +121,7 @@
}
// Here we fan the plugins into the source fragment where they should go
List<Config> correctConfigs = director.selectConfigs(pluginEntry);
- for (Iterator<Config> iter = correctConfigs.iterator(); iter.hasNext();) {
- Config configInfo = iter.next();
+ for (Config configInfo : correctConfigs) {
director.sourceToGather.addElementEntry(sourceId + "." + configInfo.toString("."), model); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -153,10 +151,10 @@
}
FeatureEntry[] plugins = feature.getPluginEntries();
- for (int i = 0; i < plugins.length; i++) {
- if (director.selectConfigs(plugins[i]).size() == 0)
+ for (FeatureEntry plugin2 : plugins) {
+ if (director.selectConfigs(plugin2).size() == 0)
continue;
- createSourceBundle(sourceFeature, plugins[i]);
+ createSourceBundle(sourceFeature, plugin2);
}
} else {
/* one source bundle + platform fragments */
@@ -215,8 +213,7 @@
private void generateSourceFragments(BuildTimeFeature sourceFeature, FeatureEntry sourcePlugin) throws CoreException {
Map<String, Set<BundleDescription>> fragments = director.sourceToGather.getElementEntries();
- for (Iterator<Config> iter = AbstractScriptGenerator.getConfigInfos().iterator(); iter.hasNext();) {
- Config configInfo = iter.next();
+ for (Config configInfo : AbstractScriptGenerator.getConfigInfos()) {
if (configInfo.equals(Config.genericConfig()))
continue;
String sourceFragmentId = sourceFeature.getId() + "." + configInfo.toString("."); //$NON-NLS-1$ //$NON-NLS-2$
@@ -266,8 +263,8 @@
result.setUpdateSiteURL(featureExample.getUpdateSiteURL());
URLEntry[] siteEntries = featureExample.getDiscoverySites();
- for (int i = 0; i < siteEntries.length; i++) {
- result.addDiscoverySite(siteEntries[i].getAnnotation(), siteEntries[i].getURL());
+ for (URLEntry siteEntry : siteEntries) {
+ result.addDiscoverySite(siteEntry.getAnnotation(), siteEntry.getURL());
}
result.setEnvironment(featureExample.getOS(), featureExample.getWS(), featureExample.getArch(), null);
@@ -455,8 +452,7 @@
if (excludedEntries != null && excludedEntries.containsKey(bundle.getSymbolicName())) {
List<Version> excludedVersions = excludedEntries.get(bundle.getSymbolicName());
- for (Iterator<Version> iterator = excludedVersions.iterator(); iterator.hasNext();) {
- Version version = iterator.next();
+ for (Version version : excludedVersions) {
if (Utils.matchVersions(bundle.getVersion().toString(), version.toString()))
return null;
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java
index edc2908..2c3447b 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/COPYFetchTasksFactory.java
@@ -1,5 +1,5 @@
/**********************************************************************
- * Copyright (c) 2004, 2013 Eclipse Foundation and others.
+ * Copyright (c) 2004, 2021 Eclipse Foundation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -75,8 +75,7 @@
String root = (String) entryInfos.get(KEY_ROOT);
String path = (String) entryInfos.get(KEY_PATH);
- for (int i = 0; i < files.length; i++) {
- String file = files[i];
+ for (String file : files) {
IPath filePath = new Path(root);
if (path != null) {
filePath = filePath.append(path).append(file);
@@ -127,10 +126,10 @@
script.println("/>"); //$NON-NLS-1$
else {
script.println(">"); //$NON-NLS-1$
- for (int i = 0; i < dirs.length; i++) {
+ for (String dir : dirs) {
script.printTabs();
script.print("\t<fileset"); //$NON-NLS-1$
- script.printAttribute("dir", dirs[i], true); //$NON-NLS-1$
+ script.printAttribute("dir", dir, true); //$NON-NLS-1$
script.println("/>"); //$NON-NLS-1$
}
script.println("</copy>"); //$NON-NLS-1$
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java
index aeb3516..3150ad1 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/CVSFetchTaskFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -133,8 +133,7 @@
public void generateRetrieveFilesCall(final Map<String, Object> entryInfos, IPath destination, final String[] files, IAntScript script) {
generateAuthentificationAntTask(entryInfos, script);
String path = (String) entryInfos.get(KEY_PATH);
- for (int i = 0; i < files.length; i++) {
- String file = files[i];
+ for (String file : files) {
IPath filePath;
if (path != null) {
filePath = new Path(path).append(file);
@@ -180,8 +179,7 @@
// build up the table of arguments in the map file entry
Map<String, String> table = new HashMap<>();
- for (int i = 0; i < arguments.length; i++) {
- String arg = arguments[i];
+ for (String arg : arguments) {
// if we have at least one arg without an equals sign, then
// revert back to the legacy parsing
int index = arg.indexOf('=');
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/P2IUFetchFactory.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/P2IUFetchFactory.java
index 329b806..bb87d1e 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/P2IUFetchFactory.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/fetch/P2IUFetchFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2018 IBM Corporation and others.
+ * Copyright (c) 2009, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -106,8 +106,7 @@
script.printTargetDeclaration(TARGET_GET_IUS_FROM_REPO, null, null, null, null);
Map<String, String> args = new LinkedHashMap<>(2);
- for (Iterator<Entry<String, ArrayList<IUFetchInfo>>> stream = iusToFetchBySource.entrySet().iterator(); stream.hasNext();) {
- Entry<String, ArrayList<IUFetchInfo>> entry = stream.next();
+ for (Entry<String, ArrayList<IUFetchInfo>> entry : iusToFetchBySource.entrySet()) {
String sourceRepository = entry.getKey();
ArrayList<IUFetchInfo> iusToFetch = entry.getValue();
@@ -118,8 +117,7 @@
script.printStartTag(TASK_REPO2RUNNABLE, args);
script.incrementIdent();
- for (Iterator<IUFetchInfo> stream2 = iusToFetch.iterator(); stream2.hasNext();) {
- IUFetchInfo iuFetchInfo = stream2.next();
+ for (IUFetchInfo iuFetchInfo : iusToFetch) {
args.clear();
args.put(ATTRIBUTE_ID, iuFetchInfo.id);
args.put(ATTRIBUTE_VERSION, iuFetchInfo.version);
@@ -191,8 +189,8 @@
script.incrementIdent();
args.clear();
args.put("dir", destination.toOSString()); //$NON-NLS-1$
- for (int i = 0; i < files.length; i++) {
- args.put("includes", "features/*/" + files[i]); //$NON-NLS-1$ //$NON-NLS-2$
+ for (String file : files) {
+ args.put("includes", "features/*/" + file); //$NON-NLS-1$ //$NON-NLS-2$
script.printElement("fileset", args); //$NON-NLS-1$
}
script.decrementIdent();
@@ -205,8 +203,7 @@
// build up the table of arguments in the map file entry
Map<String, String> table = new HashMap<>();
- for (int i = 0; i < arguments.length; i++) {
- String arg = arguments[i];
+ for (String arg : arguments) {
// if we have at least one arg without an equals sign then we are malformed and should bail
int index = arg.indexOf('=');
if (index == -1)
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/ElementCollector.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/ElementCollector.java
index 8f0b79a..b3aec10 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/ElementCollector.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/ElementCollector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2013 IBM Corporation and others.
+ * Copyright (c) 2005, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.pde.internal.build.packager;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry;
@@ -30,8 +29,8 @@
@Override
protected void generateIncludedFeatureBuildFile(BuildTimeFeature feature) throws CoreException {
FeatureEntry[] referencedFeatures = feature.getIncludedFeatureReferences();
- for (int i = 0; i < referencedFeatures.length; i++) {
- String featureId = referencedFeatures[i].getId();
+ for (FeatureEntry referencedFeature : referencedFeatures) {
+ String featureId = referencedFeature.getId();
BuildTimeFeature nestedFeature = getSite(false).findFeature(featureId, null, true);
@@ -39,7 +38,7 @@
generate(nestedFeature, false);
} catch (CoreException exception) {
//If the referenced feature is not optional, there is a real problem and the exception is re-thrown.
- if (exception.getStatus().getCode() != EXCEPTION_FEATURE_MISSING || (exception.getStatus().getCode() == EXCEPTION_FEATURE_MISSING && !referencedFeatures[i].isOptional()))
+ if (exception.getStatus().getCode() != EXCEPTION_FEATURE_MISSING || (exception.getStatus().getCode() == EXCEPTION_FEATURE_MISSING && !referencedFeature.isOptional()))
throw exception;
}
}
@@ -51,8 +50,7 @@
return;
List<Config> correctConfigs = selectConfigs(featureToCollect);
// Here, we could sort if the feature is a common one or not by comparing the size of correctConfigs
- for (Iterator<Config> iter = correctConfigs.iterator(); iter.hasNext();) {
- Config config = iter.next();
+ for (Config config : correctConfigs) {
assemblyData.addFeature(config, featureToCollect);
}
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/FetchFileGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/FetchFileGenerator.java
index bbba1b1..cea1ecd 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/FetchFileGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/FetchFileGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -119,8 +119,7 @@
mapContent = readProperties(mapLocation, "", IStatus.ERROR); //$NON-NLS-1$
- for (Iterator<Entry<Object, Object>> iter = mapContent.entrySet().iterator(); iter.hasNext();) {
- Map.Entry<Object, Object> mapEntry = iter.next();
+ for (Entry<Object, Object> mapEntry : mapContent.entrySet()) {
String fileName = (String) mapEntry.getKey();
String[] fileDescription = Utils.getArrayFromStringWithBlank((String) mapEntry.getValue(), DATA_SEPARATOR);
@@ -160,9 +159,9 @@
if (entryFilters.length == 0)
return true;
- for (int i = 0; i < entryFilters.length; i++) {
- for (int j = 0; j < filters.length; j++) {
- if (filters[j].equals(entryFilters[i]))
+ for (String entryFilter : entryFilters) {
+ for (String filter : filters) {
+ if (filter.equals(entryFilter))
return true;
}
}
@@ -175,9 +174,9 @@
if (entryConfigs.length == 0 || containsGenericConfig(getConfigInfos()))
return true;
- for (int i = 0; i < entryConfigs.length; i++) {
+ for (String entryConfig : entryConfigs) {
Iterator<Config> iter = getConfigInfos().iterator();
- Config aConfig = new Config(entryConfigs[i]);
+ Config aConfig = new Config(entryConfig);
while (iter.hasNext()) {
if (aConfig.equals(iter.next()) || aConfig.equals(Config.genericConfig())) {
return true;
@@ -203,8 +202,8 @@
if (componentName.equals(UNKNOWN) || componentFilter == null)
return true;
- for (int i = 0; i < componentFilter.length; i++) {
- if (componentFilter[i].equalsIgnoreCase(componentName) || componentFilter[i].equalsIgnoreCase(UNKNOWN))
+ for (String element : componentFilter) {
+ if (element.equalsIgnoreCase(componentName) || element.equalsIgnoreCase(UNKNOWN))
return true;
}
return false;
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/PackageConfigScriptGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/PackageConfigScriptGenerator.java
index 40c3eaa..cd8977d 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/PackageConfigScriptGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/PackageConfigScriptGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -87,8 +87,8 @@
ArrayList<FileSet> p2Features = BuildDirector.p2Gathering ? new ArrayList<>() : null;
ArrayList<FileSet> p2Bundles = BuildDirector.p2Gathering ? new ArrayList<>() : null;
- for (int i = 0; i < plugins.length; i++) {
- Path pluginLocation = new Path(plugins[i].getLocation());
+ for (BundleDescription plugin2 : plugins) {
+ Path pluginLocation = new Path(plugin2.getLocation());
String location = pluginLocation.toOSString();
boolean isFolder = isFolder(pluginLocation);
@@ -100,14 +100,14 @@
if (BuildDirector.p2Gathering) {
p2Bundles.add(new FileSet(pluginLocation.removeLastSegments(1).toOSString(), null, pluginLocation.lastSegment(), null, null, null, null));
} else if (isFolder) {
- script.printCopyTask(null, Utils.getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS) + '/' + getFinalName(plugins[i], ShapeAdvisor.FOLDER), new FileSet[] {new FileSet(location, null, null, null, excludedFiles, null, null)}, false, false);
+ script.printCopyTask(null, Utils.getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS) + '/' + getFinalName(plugin2, ShapeAdvisor.FOLDER), new FileSet[] {new FileSet(location, null, null, null, excludedFiles, null, null)}, false, false);
} else {
- script.printCopyFileTask(location, Utils.getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS) + '/' + getFinalName(plugins[i], ShapeAdvisor.FILE), false);
+ script.printCopyFileTask(location, Utils.getPropertyFormat(PROPERTY_ECLIPSE_PLUGINS) + '/' + getFinalName(plugin2, ShapeAdvisor.FILE), false);
}
}
- for (int i = 0; i < features.length; i++) {
- IPath featureLocation = new Path(features[i].getRootLocation()); // Here we assume that all the features are local
+ for (BuildTimeFeature feature2 : features) {
+ IPath featureLocation = new Path(feature2.getRootLocation()); // Here we assume that all the features are local
String location = featureLocation.toOSString();
if (baseLocation != null && baseLocation.isPrefixOf(featureLocation)) {
IPath relative = featureLocation.removeFirstSegments(baseLocation.segmentCount());
@@ -117,7 +117,7 @@
if (BuildDirector.p2Gathering) {
p2Features.add(new FileSet(featureLocation.removeLastSegments(1).toOSString(), null, featureLocation.lastSegment(), null, null, null, null));
} else {
- script.printCopyTask(null, Utils.getPropertyFormat(PROPERTY_ECLIPSE_FEATURES) + '/' + getFinalName(features[i]), new FileSet[] {new FileSet(location, null, null, null, null, null, null)}, false, false);
+ script.printCopyTask(null, Utils.getPropertyFormat(PROPERTY_ECLIPSE_FEATURES) + '/' + getFinalName(feature2), new FileSet[] {new FileSet(location, null, null, null, null, null, null)}, false, false);
}
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/PackagerGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/PackagerGenerator.java
index 059ca7b..48ea1db 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/PackagerGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/PackagerGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -36,8 +36,8 @@
@Override
protected void sortElements(List<String> features, List<String> plugins) {
String[] allFeatures = Utils.getArrayFromString(featureList);
- for (int i = 0; i < allFeatures.length; i++) {
- features.add(allFeatures[i]);
+ for (String feature2 : allFeatures) {
+ features.add(feature2);
}
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/UnzipperGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/UnzipperGenerator.java
index 6da4a6c..c677734 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/UnzipperGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/packager/UnzipperGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -95,8 +95,8 @@
List<String[]> toUnzipWithOrder = new ArrayList<>(unzipOrder.length);
String[] allZipEntries = Utils.getArrayFromString(zipEntries, ENTRY_SEPARATOR);
- for (int i = 0; i < allZipEntries.length; i++) {
- String[] entryDetail = Utils.getArrayFromString(allZipEntries[i], DATA_SEPARATOR);
+ for (String zipEntry : allZipEntries) {
+ String[] entryDetail = Utils.getArrayFromString(zipEntry, DATA_SEPARATOR);
script.printComment("Uncompress " + entryDetail[ARCHIVE_NAME]); //$NON-NLS-1$
if (!entryDetail[FOLDER].equals(".")) //$NON-NLS-1$
@@ -112,10 +112,10 @@
}
//Deal with the entries that have a specific order.
- for (int i = 0; i < unzipOrder.length; i++) {
+ for (String element : unzipOrder) {
for (Iterator<String[]> iter = toUnzipWithOrder.iterator(); iter.hasNext();) {
String[] entry = iter.next();
- if (entry[ARCHIVE_NAME].startsWith(unzipOrder[i])) {
+ if (entry[ARCHIVE_NAME].startsWith(element)) {
generateUncompress(entry);
iter.remove();
}
@@ -137,8 +137,8 @@
}
private boolean delayed(String fileName) {
- for (int i = 0; i < unzipOrder.length; i++) {
- if (fileName.startsWith(unzipOrder[i]))
+ for (String element : unzipOrder) {
+ if (fileName.startsWith(element))
return true;
}
return false;
@@ -151,8 +151,8 @@
} else {
String[] configs = Utils.getArrayFromString(entryDetail[CONFIGS], "&"); //$NON-NLS-1$
applyingConfigs = new ArrayList<>(configs.length);
- for (int i = 0; i < configs.length; i++) {
- applyingConfigs.add(new Config(configs[i]));
+ for (String config : configs) {
+ applyingConfigs.add(new Config(config));
}
}
return applyingConfigs;
@@ -168,8 +168,7 @@
//Uncompress the root files into a platform specific folder
private void generateUnzipRootFiles(String[] entryDetail) {
//Unzip the root files in a "config specific folder" for all the configurations that matched this entry
- for (Iterator<Config> iter = getMatchingConfig(entryDetail).iterator(); iter.hasNext();) {
- Config config = iter.next();
+ for (Config config : getMatchingConfig(entryDetail)) {
List<String> parameters = new ArrayList<>(3);
String rootFilesFolder = "${tempDirectory}/" + config.toString(".") + '/' + entryDetail[FOLDER]; //$NON-NLS-1$ //$NON-NLS-2$
script.printMkdirTask(rootFilesFolder);
@@ -189,8 +188,7 @@
private void generateUntarRootFiles(String[] entryDetail) {
//Unzip the root files in a "config specific folder" for all the configurations that matched this entry
- for (Iterator<Config> iter = getMatchingConfig(entryDetail).iterator(); iter.hasNext();) {
- Config config = iter.next();
+ for (Config config : getMatchingConfig(entryDetail)) {
List<String> parameters = new ArrayList<>(4);
String rootFilesFolder = "${tempDirectory}/" + config.toString(".") + '/' + entryDetail[FOLDER]; //$NON-NLS-1$ //$NON-NLS-2$
script.printMkdirTask(rootFilesFolder);
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/publisher/compatibility/IncrementalGenerator.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/publisher/compatibility/IncrementalGenerator.java
index 39c81b6..ca5a15f 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/publisher/compatibility/IncrementalGenerator.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/publisher/compatibility/IncrementalGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -43,8 +43,8 @@
if (configs != null)
provider.setConfigurations(configs.toArray(new String[configs.size()]));
if (advice != null) {
- for (Iterator<IPublisherAdvice> iterator = advice.iterator(); iterator.hasNext();) {
- provider.addAdvice(iterator.next());
+ for (IPublisherAdvice iPublisherAdvice : advice) {
+ provider.addAdvice(iPublisherAdvice);
}
}
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeFeature.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeFeature.java
index ecf1341..916f955 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeFeature.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeFeature.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -55,10 +55,10 @@
public FeatureEntry[] getRawIncludedFeatureReferences() {
ArrayList<FeatureEntry> included = new ArrayList<>();
FeatureEntry[] entries = getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].isRequires() || entries[i].isPlugin())
+ for (FeatureEntry entry : entries) {
+ if (entry.isRequires() || entry.isPlugin())
continue;
- included.add(entries[i]);
+ included.add(entry);
}
return included.toArray(new FeatureEntry[included.size()]);
}
@@ -66,12 +66,12 @@
public FeatureEntry[] getIncludedFeatureReferences() {
ArrayList<FeatureEntry> included = new ArrayList<>();
FeatureEntry[] entries = getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].isRequires() || entries[i].isPlugin())
+ for (FeatureEntry entry : entries) {
+ if (entry.isRequires() || entry.isPlugin())
continue;
- if (SiteManager.isValidEnvironment(entries[i])) {
- included.add(entries[i]);
+ if (SiteManager.isValidEnvironment(entry)) {
+ included.add(entry);
}
}
@@ -81,11 +81,11 @@
public FeatureEntry[] getPluginEntries() {
ArrayList<FeatureEntry> plugins = new ArrayList<>();
FeatureEntry[] entries = getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].isRequires() || !entries[i].isPlugin())
+ for (FeatureEntry entry : entries) {
+ if (entry.isRequires() || !entry.isPlugin())
continue;
- if (SiteManager.isValidEnvironment(entries[i])) {
- plugins.add(entries[i]);
+ if (SiteManager.isValidEnvironment(entry)) {
+ plugins.add(entry);
}
}
return plugins.toArray(new FeatureEntry[plugins.size()]);
@@ -94,10 +94,10 @@
public FeatureEntry[] getRawPluginEntries() {
ArrayList<FeatureEntry> plugins = new ArrayList<>();
FeatureEntry[] entries = getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].isRequires() || !entries[i].isPlugin())
+ for (FeatureEntry entry : entries) {
+ if (entry.isRequires() || !entry.isPlugin())
continue;
- plugins.add(entries[i]);
+ plugins.add(entry);
}
return plugins.toArray(new FeatureEntry[plugins.size()]);
}
@@ -105,10 +105,10 @@
public FeatureEntry[] getImports() {
ArrayList<FeatureEntry> imports = new ArrayList<>();
FeatureEntry[] entries = getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (!entries[i].isRequires())
+ for (FeatureEntry entry : entries) {
+ if (!entry.isRequires())
continue;
- imports.add(entries[i]);
+ imports.add(entry);
}
return imports.toArray(new FeatureEntry[imports.size()]);
}
@@ -184,10 +184,10 @@
public FeatureEntry findPluginEntry(String id, String version) {
FeatureEntry[] entries = getEntries();
- for (int i = 0; i < entries.length; i++) {
- if (entries[i].isPlugin() && entries[i].getId().equals(id))
- if (Utils.matchVersions(version, entries[i].getVersion()))
- return entries[i];
+ for (FeatureEntry entry : entries) {
+ if (entry.isPlugin() && entry.getId().equals(id))
+ if (Utils.matchVersions(version, entry.getVersion()))
+ return entry;
}
return null;
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSite.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSite.java
index de001fe..626395c 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSite.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -52,14 +52,10 @@
private List<String> rootPluginsForFiler;
private boolean filter = false;
- private final Comparator<Feature> featureComparator = new Comparator<Feature>() {
- // Sort highest to lowest version, they are assumed to have the same id
- @Override
- public int compare(Feature arg0, Feature arg1) {
- Version v0 = new Version(arg0.getVersion());
- Version v1 = new Version(arg1.getVersion());
- return -1 * v0.compareTo(v1);
- }
+ private final Comparator<Feature> featureComparator = (arg0, arg1) -> {
+ Version v0 = new Version(arg0.getVersion());
+ Version v1 = new Version(arg1.getVersion());
+ return -1 * v0.compareTo(v1);
};
public void setReportResolutionErrors(boolean value) {
@@ -91,8 +87,7 @@
private Collection<File> removeDuplicates(Collection<File> bundles) {
Set<File> result = new LinkedHashSet<>(bundles.size() / 2);
- for (Iterator<File> iterator = bundles.iterator(); iterator.hasNext();) {
- File bundle = iterator.next();
+ for (File bundle : bundles) {
try {
bundle = bundle.getCanonicalFile();
} catch (IOException e) {
@@ -146,18 +141,18 @@
MultiStatus errors = new MultiStatus(IPDEBuildConstants.PI_PDEBUILD, 1, Messages.exception_registryResolution, null);
BundleDescription[] all = state.getState().getBundles();
StateHelper helper = Platform.getPlatformAdmin().getStateHelper();
- for (int i = 0; i < all.length; i++) {
- if (!all[i].isResolved()) {
- ResolverError[] resolutionErrors = state.getState().getResolverErrors(all[i]);
- VersionConstraint[] versionErrors = helper.getUnsatisfiedConstraints(all[i]);
+ for (BundleDescription element : all) {
+ if (!element.isResolved()) {
+ ResolverError[] resolutionErrors = state.getState().getResolverErrors(element);
+ VersionConstraint[] versionErrors = helper.getUnsatisfiedConstraints(element);
//ignore problems when they are caused by bundles not being built for the right config
- if (isConfigError(all[i], resolutionErrors, AbstractScriptGenerator.getConfigInfos()))
+ if (isConfigError(element, resolutionErrors, AbstractScriptGenerator.getConfigInfos()))
continue;
- String errorMessage = "Bundle " + all[i].getSymbolicName() + ":\n" + getResolutionErrorMessage(resolutionErrors); //$NON-NLS-1$ //$NON-NLS-2$
- for (int j = 0; j < versionErrors.length; j++) {
- errorMessage += '\t' + getResolutionFailureMessage(versionErrors[j]) + '\n';
+ String errorMessage = "Bundle " + element.getSymbolicName() + ":\n" + getResolutionErrorMessage(resolutionErrors); //$NON-NLS-1$ //$NON-NLS-2$
+ for (VersionConstraint versionError : versionErrors) {
+ errorMessage += '\t' + getResolutionFailureMessage(versionError) + '\n';
}
errors.add(new Status(IStatus.WARNING, IPDEBuildConstants.PI_PDEBUILD, IStatus.WARNING, errorMessage, null));
}
@@ -199,8 +194,8 @@
if (containingFeature != null)
message = NLS.bind(Messages.includedFromFeature, containingFeature.getId(), message);
message += ":\n" + BuildTimeSite.getResolutionErrorMessage(resolutionErrors); //$NON-NLS-1$
- for (int j = 0; j < versionErrors.length; j++) {
- message += '\t' + BuildTimeSite.getResolutionFailureMessage(versionErrors[j]) + '\n';
+ for (VersionConstraint versionError : versionErrors) {
+ message += '\t' + BuildTimeSite.getResolutionFailureMessage(versionError) + '\n';
}
IStatus status = new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_PLUGIN_MISSING, message, null);
@@ -214,8 +209,7 @@
Dictionary<String, String> environment = new Hashtable<>(3);
Filter bundleFilter = BundleHelper.getDefault().getFilter(bundle);
if (bundleFilter != null && hasPlatformFilterError(errors) != null) {
- for (Iterator<Config> iter = configs.iterator(); iter.hasNext();) {
- Config aConfig = iter.next();
+ for (Config aConfig : configs) {
environment.put("osgi.os", aConfig.getOs()); //$NON-NLS-1$
environment.put("osgi.ws", aConfig.getWs()); //$NON-NLS-1$
environment.put("osgi.arch", aConfig.getArch()); //$NON-NLS-1$
@@ -230,20 +224,20 @@
//Check if the set of errors contain a platform filter
static private ResolverError hasPlatformFilterError(ResolverError[] errors) {
- for (int i = 0; i < errors.length; i++) {
- if ((errors[i].getType() & ResolverError.PLATFORM_FILTER) != 0)
- return errors[i];
- if ((errors[i].getType() & ResolverError.NO_NATIVECODE_MATCH) != 0)
- return errors[i];
+ for (ResolverError error : errors) {
+ if ((error.getType() & ResolverError.PLATFORM_FILTER) != 0)
+ return error;
+ if ((error.getType() & ResolverError.NO_NATIVECODE_MATCH) != 0)
+ return error;
}
return null;
}
static public String getResolutionErrorMessage(ResolverError[] errors) {
String errorMessage = ""; //$NON-NLS-1$
- for (int i = 0; i < errors.length; i++) {
- if ((errors[i].getType() & (ResolverError.SINGLETON_SELECTION | ResolverError.FRAGMENT_CONFLICT | ResolverError.IMPORT_PACKAGE_USES_CONFLICT | ResolverError.REQUIRE_BUNDLE_USES_CONFLICT | ResolverError.MISSING_EXECUTION_ENVIRONMENT)) != 0)
- errorMessage += '\t' + errors[i].toString() + '\n';
+ for (ResolverError error : errors) {
+ if ((error.getType() & (ResolverError.SINGLETON_SELECTION | ResolverError.FRAGMENT_CONFLICT | ResolverError.IMPORT_PACKAGE_USES_CONFLICT | ResolverError.REQUIRE_BUNDLE_USES_CONFLICT | ResolverError.MISSING_EXECUTION_ENVIRONMENT)) != 0)
+ errorMessage += '\t' + error.toString() + '\n';
}
return errorMessage;
}
@@ -285,8 +279,7 @@
if (featureCache.containsKey(featureId)) {
//Set is ordered highest version to lowest, return the first that matches the range
Set<BuildTimeFeature> featureSet = featureCache.get(featureId);
- for (Iterator<BuildTimeFeature> iterator = featureSet.iterator(); iterator.hasNext();) {
- BuildTimeFeature feature = iterator.next();
+ for (BuildTimeFeature feature : featureSet) {
Version featureVersion = new Version(feature.getVersion());
if (range.isIncluded(featureVersion)) {
return feature;
@@ -308,13 +301,13 @@
private void resolveFeatureReferences() {
FeatureReference[] features = getFeatureReferences();
- for (int i = 0; i < features.length; i++) {
+ for (FeatureReference feature2 : features) {
try {
//getting the feature for the first time will result in it being added to featureCache
- features[i].getFeature();
+ feature2.getFeature();
} catch (CoreException e) {
// just log the exception, but do not re-throw it - let other features to be resolved
- String message = NLS.bind(Messages.exception_featureParse, features[i].getURL());
+ String message = NLS.bind(Messages.exception_featureParse, feature2.getURL());
IStatus status = new Status(IStatus.ERROR, PI_PDEBUILD, EXCEPTION_FEATURE_MISSING, message, e);
BundleHelper.getDefault().getLog().log(status);
}
@@ -354,14 +347,14 @@
private SortedSet<ReachablePlugin> findAllReferencedPlugins() throws CoreException {
ArrayList<BuildTimeFeature> rootFeatures = new ArrayList<>();
SortedSet<ReachablePlugin> allPlugins = new TreeSet<>();
- for (Iterator<String> iter = rootFeaturesForFilter.iterator(); iter.hasNext();) {
- BuildTimeFeature correspondingFeature = findFeature(iter.next(), (String) null, true);
+ for (String string : rootFeaturesForFilter) {
+ BuildTimeFeature correspondingFeature = findFeature(string, (String) null, true);
if (correspondingFeature == null)
return null;
rootFeatures.add(correspondingFeature);
}
- for (Iterator<String> iter = rootPluginsForFiler.iterator(); iter.hasNext();) {
- allPlugins.add(new ReachablePlugin(iter.next(), ReachablePlugin.WIDEST_RANGE));
+ for (String string : rootPluginsForFiler) {
+ allPlugins.add(new ReachablePlugin(string, ReachablePlugin.WIDEST_RANGE));
}
int it = 0;
while (it < rootFeatures.size()) {
@@ -406,15 +399,15 @@
}
}
FeatureEntry[] entries = toAnalyse.getPluginEntries();
- for (int i = 0; i < entries.length; i++) {
- allPlugins.add(new ReachablePlugin(entries[i]));
+ for (FeatureEntry entry : entries) {
+ allPlugins.add(new ReachablePlugin(entry));
}
FeatureEntry[] imports = toAnalyse.getImports();
- for (int i = 0; i < imports.length; i++) {
- if (!imports[i].isPlugin()) {
- rootFeatures.add(findFeature(imports[i].getId(), Utils.createVersionRange(imports[i]), true));
+ for (FeatureEntry import1 : imports) {
+ if (!import1.isPlugin()) {
+ rootFeatures.add(findFeature(import1.getId(), Utils.createVersionRange(import1), true));
} else {
- allPlugins.add(new ReachablePlugin(imports[i]));
+ allPlugins.add(new ReachablePlugin(import1));
}
}
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSiteContentProvider.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSiteContentProvider.java
index 42ba093..c7ffcff 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSiteContentProvider.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSiteContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -59,22 +59,22 @@
//For every entry, return all the children of this entry is it is named plugins, otherwise return the entry itself
private Collection<File> findPluginXML(File[] location) {
Collection<File> collectedElements = new ArrayList<>(10);
- for (int i = 0; i < location.length; i++) {
- File f = new File(location[i], DEFAULT_PLUGIN_LOCATION);
+ for (File element : location) {
+ File f = new File(element, DEFAULT_PLUGIN_LOCATION);
if (f.exists()) {
//location was the root of an eclipse install, list everything from the plugins directory
collectedElements.addAll(Arrays.asList(f.listFiles()));
- } else if (new File(location[i], JarFile.MANIFEST_NAME).exists() || new File(location[i], Constants.PLUGIN_FILENAME_DESCRIPTOR).exists() || new File(location[i], Constants.FRAGMENT_FILENAME_DESCRIPTOR).exists()) {
- collectedElements.add(location[i]);
- } else if (location[i].isDirectory()) {
+ } else if (new File(element, JarFile.MANIFEST_NAME).exists() || new File(element, Constants.PLUGIN_FILENAME_DESCRIPTOR).exists() || new File(element, Constants.FRAGMENT_FILENAME_DESCRIPTOR).exists()) {
+ collectedElements.add(element);
+ } else if (element.isDirectory()) {
//at this point Manifest, plugin.xml, feature.xml and fragment.xml don't exist here
//consider a project with "flexible root"
- if (new File(location[i], PDE_CORE_PREFS).exists()) {
+ if (new File(element, PDE_CORE_PREFS).exists()) {
try {
- Properties properties = AbstractScriptGenerator.readProperties(location[i].getAbsolutePath(), PDE_CORE_PREFS, IStatus.OK);
+ Properties properties = AbstractScriptGenerator.readProperties(element.getAbsolutePath(), PDE_CORE_PREFS, IStatus.OK);
String root = properties.getProperty(BUNDLE_ROOT_PATH);
if (root != null) {
- File actualRoot = new File(location[i], root);
+ File actualRoot = new File(element, root);
if (actualRoot.exists())
collectedElements.add(actualRoot);
}
@@ -83,10 +83,10 @@
}
} else {
//a "workspace"
- collectedElements.addAll(Arrays.asList(location[i].listFiles()));
+ collectedElements.addAll(Arrays.asList(element.listFiles()));
}
- } else if (location[i].isFile() && location[i].getName().endsWith(".jar")) {//$NON-NLS-1$
- collectedElements.add(location[i]);
+ } else if (element.isFile() && element.getName().endsWith(".jar")) {//$NON-NLS-1$
+ collectedElements.add(element);
}
}
return collectedElements;
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSiteFactory.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSiteFactory.java
index 2a8f2dc..34021fd 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSiteFactory.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/BuildTimeSiteFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which accompanies this distribution,
@@ -79,8 +79,8 @@
// extract features from platform.xml
File[] featureDirectories = PluginPathFinder.getFeaturePaths(installedBaseURL);
- for (int i = 0; i < featureDirectories.length; i++) {
- File featureXML = new File(featureDirectories[i], Constants.FEATURE_FILENAME_DESCRIPTOR);
+ for (File element : featureDirectories) {
+ File featureXML = new File(element, Constants.FEATURE_FILENAME_DESCRIPTOR);
if (featureXML.exists())
featureXMLs.add(featureXML);
}
@@ -90,8 +90,7 @@
URL featureURL;
FeatureReference featureRef;
- for (Iterator<File> iter = featureXMLs.iterator(); iter.hasNext();) {
- File featureXML = iter.next();
+ for (File featureXML : featureXMLs) {
if (featureXML.exists()) {
// Here we could not use toURL() on currentFeatureDir, because the URL has a slash after the colons (file:/c:/foo) whereas the plugins don't
// have it (file:d:/eclipse/plugins) and this causes problems later to compare URLs... and compute relative paths
@@ -140,8 +139,8 @@
boolean found = true;
while (found && i < sitePaths.length) {
found = false;
- for (int j = 0; j < urls.length; j++) {
- if (sitePaths[i].equals(urls[j])) {
+ for (String url : urls) {
+ if (sitePaths[i].equals(url)) {
found = true;
break;
}
@@ -162,18 +161,18 @@
private Collection<File> findFeatureXMLs() {
Collection<File> features = new ArrayList<>();
Collection<File> foundFeatures = null;
- for (int i = 0; i < sitePaths.length; i++) {
- File file = new File(sitePaths[i], Constants.FEATURE_FILENAME_DESCRIPTOR);
+ for (String sitePath : sitePaths) {
+ File file = new File(sitePath, Constants.FEATURE_FILENAME_DESCRIPTOR);
if (file.exists()) {
//path is a feature itself
features.add(file);
continue;
- } else if (new File(sitePaths[i], DEFAULT_FEATURE_LOCATION).exists()) {
+ } else if (new File(sitePath, DEFAULT_FEATURE_LOCATION).exists()) {
//path is a eclipse root and contains a features subdirectory
- foundFeatures = Utils.findFiles(new File(sitePaths[i]), DEFAULT_FEATURE_LOCATION, Constants.FEATURE_FILENAME_DESCRIPTOR);
+ foundFeatures = Utils.findFiles(new File(sitePath), DEFAULT_FEATURE_LOCATION, Constants.FEATURE_FILENAME_DESCRIPTOR);
} else {
// treat as a flat directory containing features
- foundFeatures = Utils.findFiles(new File(sitePaths[i]), ".", Constants.FEATURE_FILENAME_DESCRIPTOR); //$NON-NLS-1$
+ foundFeatures = Utils.findFiles(new File(sitePath), ".", Constants.FEATURE_FILENAME_DESCRIPTOR); //$NON-NLS-1$
}
if (foundFeatures != null)
features.addAll(foundFeatures);
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/FilteringState.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/FilteringState.java
index 12850c9..c8a42cd 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/FilteringState.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/FilteringState.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others.
+ * Copyright (c) 2007, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,7 +13,6 @@
*******************************************************************************/
package org.eclipse.pde.internal.build.site;
-import java.util.Iterator;
import java.util.SortedSet;
import org.eclipse.osgi.service.resolver.BundleDescription;
@@ -31,8 +30,7 @@
}
SortedSet<ReachablePlugin> includedMatches = allPlugins.subSet(new ReachablePlugin(toAdd.getSymbolicName(), ReachablePlugin.WIDEST_RANGE), new ReachablePlugin(toAdd.getSymbolicName(), ReachablePlugin.NARROWEST_RANGE));
- for (Iterator<ReachablePlugin> iterator = includedMatches.iterator(); iterator.hasNext();) {
- ReachablePlugin constraint = iterator.next();
+ for (ReachablePlugin constraint : includedMatches) {
if (constraint.getRange().isIncluded(toAdd.getVersion()))
return super.addBundleDescription(toAdd);
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/P2Utils.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/P2Utils.java
index 667b35c..9d4da9d 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/P2Utils.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/P2Utils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -109,8 +109,7 @@
Map<String, BundleInfo> userInfos = productFile != null ? productFile.getConfigurationInfo() : null;
- for (Iterator<BundleDescription> iterator = bundles.iterator(); iterator.hasNext();) {
- BundleDescription desc = iterator.next();
+ for (BundleDescription desc : bundles) {
if (desc != null) {
String modelName = desc.getSymbolicName();
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java
index f6b29d7..496658e 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PDEState.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2020 IBM Corporation and others.
+ * Copyright (c) 2004, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -145,10 +145,10 @@
descriptor.setUserObject(properties);
}
- for (int i = 0; i < entries.length; i++) {
- String entry = BundleHelper.getManifestHeader(manifest, entries[i]);
+ for (String entry2 : entries) {
+ String entry = BundleHelper.getManifestHeader(manifest, entry2);
if (entry != null) {
- properties.put(entries[i], entry);
+ properties.put(entry2, entry);
}
}
}
@@ -357,8 +357,7 @@
}
public void addBundles(Collection<File> bundles) {
- for (Iterator<File> iter = bundles.iterator(); iter.hasNext();) {
- File bundle = iter.next();
+ for (File bundle : bundles) {
addBundle(bundle);
}
}
@@ -373,8 +372,7 @@
String systemPackages = null;
String ee = null;
- for (Iterator<Config> iter = configs.iterator(); iter.hasNext();) {
- Config aConfig = iter.next();
+ for (Config aConfig : configs) {
prop = new Hashtable<>();
if (AbstractScriptGenerator.getPropertyAsBoolean(RESOLVER_DEV_MODE))
prop.put(PROPERTY_RESOLVER_MODE, VALUE_DEVELOPMENT);
@@ -485,9 +483,9 @@
return new BundleDescription[0];
ExportPackageDescription[] packages = root.getResolvedImports();
ArrayList<BundleDescription> resolvedImports = new ArrayList<>(packages.length);
- for (int i = 0; i < packages.length; i++)
- if (!root.getLocation().equals(packages[i].getExporter().getLocation()) && !resolvedImports.contains(packages[i].getExporter()))
- resolvedImports.add(packages[i].getExporter());
+ for (ExportPackageDescription package1 : packages)
+ if (!root.getLocation().equals(package1.getExporter().getLocation()) && !resolvedImports.contains(package1.getExporter()))
+ resolvedImports.add(package1.getExporter());
return resolvedImports.toArray(new BundleDescription[resolvedImports.size()]);
}
@@ -539,12 +537,7 @@
*/
private BundleDescription[] sortByVersion(BundleDescription[] bundles) {
if (bundles.length > 1) {
- Arrays.sort(bundles, new Comparator<BundleDescription>() {
- @Override
- public int compare(BundleDescription o1, BundleDescription o2) {
- return o1.getVersion().compareTo(o2.getVersion());
- }
- });
+ Arrays.sort(bundles, (o1, o2) -> o1.getVersion().compareTo(o2.getVersion()));
}
return bundles;
}
@@ -586,10 +579,10 @@
public static BundleDescription[] getImportedByFragments(BundleDescription root) {
BundleDescription[] fragments = root.getFragments();
List<BundleDescription> importedByFragments = new ArrayList<>();
- for (int i = 0; i < fragments.length; i++) {
- if (!fragments[i].isResolved())
+ for (BundleDescription fragment2 : fragments) {
+ if (!fragment2.isResolved())
continue;
- merge(importedByFragments, getImportedBundles(fragments[i]));
+ merge(importedByFragments, getImportedBundles(fragment2));
}
BundleDescription[] result = new BundleDescription[importedByFragments.size()];
return importedByFragments.toArray(result);
@@ -598,19 +591,19 @@
public static BundleDescription[] getRequiredByFragments(BundleDescription root) {
BundleDescription[] fragments = root.getFragments();
List<BundleDescription> importedByFragments = new ArrayList<>();
- for (int i = 0; i < fragments.length; i++) {
- if (!fragments[i].isResolved())
+ for (BundleDescription fragment2 : fragments) {
+ if (!fragment2.isResolved())
continue;
- merge(importedByFragments, getRequiredBundles(fragments[i]));
+ merge(importedByFragments, getRequiredBundles(fragment2));
}
BundleDescription[] result = new BundleDescription[importedByFragments.size()];
return importedByFragments.toArray(result);
}
public static void merge(List<BundleDescription> source, BundleDescription[] toAdd) {
- for (int i = 0; i < toAdd.length; i++) {
- if (!source.contains(toAdd[i]))
- source.add(toAdd[i]);
+ for (BundleDescription element : toAdd) {
+ if (!source.contains(element))
+ source.add(element);
}
}
@@ -647,22 +640,20 @@
if (addedBundle == null && unqualifiedBundles == null)
return;
- for (Iterator<BundleDescription> iter = addedBundle.iterator(); iter.hasNext();) {
- BundleDescription added = iter.next();
+ for (BundleDescription added : addedBundle) {
state.removeBundle(added);
}
addedBundle.clear();
- for (Iterator<BundleDescription> iter = unqualifiedBundles.iterator(); iter.hasNext();) {
- BundleDescription toAddBack = iter.next();
+ for (BundleDescription toAddBack : unqualifiedBundles) {
state.removeBundle(toAddBack.getBundleId());
addBundleDescription(toAddBack);
}
unqualifiedBundles.clear();
BundleDescription[] allBundles = state.getBundles();
- for (int i = 0; i < allBundles.length; i++) {
- allBundles[i].setUserObject(null);
+ for (BundleDescription bundle : allBundles) {
+ bundle.setUserObject(null);
}
state.resolve();
}
@@ -681,9 +672,8 @@
//Replace the version numbers that ends with .qualifier
private void forceQualifiers() {
BundleDescription[] resolvedBundles = state.getResolvedBundles(); //We only get the resolved bundles since, changing the qualifier should not change the resolution state
- for (int i = 0; i < resolvedBundles.length; i++) {
- if (resolvedBundles[i].getVersion().getQualifier().endsWith(PROPERTY_QUALIFIER)) {
- BundleDescription b = resolvedBundles[i];
+ for (BundleDescription b : resolvedBundles) {
+ if (b.getVersion().getQualifier().endsWith(PROPERTY_QUALIFIER)) {
unqualifiedBundles.add(state.removeBundle(b.getBundleId())); //We keep the removed bundle so we can reinsert it in the state when we are done
String newVersion = QualifierReplacer.replaceQualifierInVersion(b.getVersion().toString(), b.getSymbolicName(), getQualifierPropery(b.getLocation()), null);
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PluginPathFinder.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PluginPathFinder.java
index b750155..6b1c52b 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PluginPathFinder.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/PluginPathFinder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2017 IBM Corporation and others.
+ * Copyright (c) 2004, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -74,8 +74,8 @@
File[] linkFiles = new File(platformHome + IPath.SEPARATOR + "links").listFiles(); //$NON-NLS-1$
if (linkFiles != null) {
- for (int i = 0; i < linkFiles.length; i++) {
- String path = getSitePath(platformHome, linkFiles[i], features);
+ for (File linkFile : linkFiles) {
+ String path = getSitePath(platformHome, linkFile, features);
if (path != null) {
sites.add(new File(path));
}
@@ -93,39 +93,39 @@
ArrayList<File> results = new ArrayList<>();
File[] contents = dropins.listFiles();
- for (int i = 0; i < contents.length; i++) {
- if (contents[i].isFile()) {
- if (contents[i].getName().endsWith(LINK)) {
- String path = getSitePath(platformHome, contents[i], features);
+ for (File content : contents) {
+ if (content.isFile()) {
+ if (content.getName().endsWith(LINK)) {
+ String path = getSitePath(platformHome, content, features);
if (path != null)
sites.add(new File(path));
} else {
//bundle
- results.add(contents[i]);
+ results.add(content);
}
} else { //folder
//dropins/features or dropins/plugins
- if (contents[i].isDirectory() && contents[i].getName().equals(features ? IPDEBuildConstants.DEFAULT_FEATURE_LOCATION : IPDEBuildConstants.DEFAULT_PLUGIN_LOCATION)) {
- results.addAll(Arrays.asList(contents[i].listFiles()));
+ if (content.isDirectory() && content.getName().equals(features ? IPDEBuildConstants.DEFAULT_FEATURE_LOCATION : IPDEBuildConstants.DEFAULT_PLUGIN_LOCATION)) {
+ results.addAll(Arrays.asList(content.listFiles()));
continue;
}
//dropins/*/features or dropins/*/plugins
- File temp = new File(contents[i], features ? IPDEBuildConstants.DEFAULT_FEATURE_LOCATION : IPDEBuildConstants.DEFAULT_PLUGIN_LOCATION);
+ File temp = new File(content, features ? IPDEBuildConstants.DEFAULT_FEATURE_LOCATION : IPDEBuildConstants.DEFAULT_PLUGIN_LOCATION);
if (temp.isDirectory()) {
sites.add(temp);
continue;
}
//dropins/*/eclipse/features or dropins/*/eclipse/plugins
- temp = new File(contents[i], ECLIPSE + File.separator + (features ? IPDEBuildConstants.DEFAULT_FEATURE_LOCATION : IPDEBuildConstants.DEFAULT_PLUGIN_LOCATION));
+ temp = new File(content, ECLIPSE + File.separator + (features ? IPDEBuildConstants.DEFAULT_FEATURE_LOCATION : IPDEBuildConstants.DEFAULT_PLUGIN_LOCATION));
if (temp.isDirectory()) {
sites.add(temp);
continue;
}
//else treat as a bundle/feature
- results.add(contents[i]);
+ results.add(content);
}
}
@@ -166,10 +166,10 @@
*/
private static List<File> scanLocations(File[] sites) {
ArrayList<File> result = new ArrayList<>();
- for (int i = 0; i < sites.length; i++) {
- if (sites[i] == null || !sites[i].exists())
+ for (File site : sites) {
+ if (site == null || !site.exists())
continue;
- File[] children = sites[i].listFiles();
+ File[] children = site.listFiles();
if (children != null)
result.addAll(Arrays.asList(children));
}
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/ProfileManager.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/ProfileManager.java
index 090db43..71bbbcf 100644
--- a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/ProfileManager.java
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/site/ProfileManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2019 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which accompanies this distribution,
@@ -55,10 +55,10 @@
public void copyEEProfileProperties(Dictionary<String, Object> source, Properties target) {
String[] profiles = getJavaProfiles();
- for (int i = 0; i < profiles.length; i++) {
- Object value = source.get(profiles[i]);
+ for (String profile : profiles) {
+ Object value = source.get(profile);
if (value != null && value instanceof String) {
- target.put(profiles[i], value);
+ target.put(profile, value);
}
}
}
@@ -98,26 +98,23 @@
}
protected String[] sortProfiles(String[] profiles) {
- Arrays.sort(profiles, new Comparator<String>() {
- @Override
- public int compare(String profile1, String profile2) {
- // need to make sure JavaSE, J2SE profiles are sorted ahead of all other profiles
- String p1 = profile1;
- String p2 = profile2;
- if (p1.startsWith("JavaSE-") && !p2.startsWith("JavaSE-")) //$NON-NLS-1$ //$NON-NLS-2$
- return -1;
- if (!p1.startsWith("JavaSE-") && p2.startsWith("JavaSE-")) //$NON-NLS-1$ //$NON-NLS-2$
- return 1;
- if (p1.startsWith("J2SE-") && !p2.startsWith("J2SE-")) //$NON-NLS-1$ //$NON-NLS-2$
- return -1;
- if (!p1.startsWith("J2SE-") && p2.startsWith("J2SE-")) //$NON-NLS-1$ //$NON-NLS-2$
- return 1;
- if (p1.startsWith("JavaSE/compact") && !p2.startsWith("JavaSE/compact")) //$NON-NLS-1$ //$NON-NLS-2$
- return -1;
- if (!p1.startsWith("JavaSE/compact") && p2.startsWith("JavaSE/compact")) //$NON-NLS-1$ //$NON-NLS-2$
- return 1;
- return -p1.compareTo(p2);
- }
+ Arrays.sort(profiles, (profile1, profile2) -> {
+ // need to make sure JavaSE, J2SE profiles are sorted ahead of all other profiles
+ String p1 = profile1;
+ String p2 = profile2;
+ if (p1.startsWith("JavaSE-") && !p2.startsWith("JavaSE-")) //$NON-NLS-1$ //$NON-NLS-2$
+ return -1;
+ if (!p1.startsWith("JavaSE-") && p2.startsWith("JavaSE-")) //$NON-NLS-1$ //$NON-NLS-2$
+ return 1;
+ if (p1.startsWith("J2SE-") && !p2.startsWith("J2SE-")) //$NON-NLS-1$ //$NON-NLS-2$
+ return -1;
+ if (!p1.startsWith("J2SE-") && p2.startsWith("J2SE-")) //$NON-NLS-1$ //$NON-NLS-2$
+ return 1;
+ if (p1.startsWith("JavaSE/compact") && !p2.startsWith("JavaSE/compact")) //$NON-NLS-1$ //$NON-NLS-2$
+ return -1;
+ if (!p1.startsWith("JavaSE/compact") && p2.startsWith("JavaSE/compact")) //$NON-NLS-1$ //$NON-NLS-2$
+ return 1;
+ return -p1.compareTo(p2);
});
return profiles;
}
@@ -127,8 +124,8 @@
loadRuntimeJavaProfiles();
}
if (profileSources != null) {
- for (int i = 0; i < profileSources.length; i++) {
- File source = new File(profileSources[i]);
+ for (String element : profileSources) {
+ File source = new File(element);
if (source.isDirectory()) {
loadJavaProfiles(source);
} else {
@@ -203,12 +200,7 @@
if (profiles != null) {
return Utils.getArrayEnumerator(profiles);
} else if (container instanceof File) {
- File[] files = ((File) container).listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.endsWith(PROFILE_EXTENSION);
- }
- });
+ File[] files = ((File) container).listFiles((FilenameFilter) (dir, name) -> name.endsWith(PROFILE_EXTENSION));
return Utils.getArrayEnumerator(files);
} else if (container instanceof ZipFile) {
return ((ZipFile) container).entries();
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/AbstractPublisherTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/AbstractPublisherTask.java
index 5e437ed..1587c74 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/AbstractPublisherTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/AbstractPublisherTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -116,15 +116,15 @@
}
buildProperties = new Properties();
- for (Iterator<Object> iterator = properties.keySet().iterator(); iterator.hasNext();) {
- String key = (String) iterator.next();
+ for (Object object : properties.keySet()) {
+ String key = (String) object;
String value = properties.getProperty(key);
buildProperties.put(key, getProject().replaceProperties(value));
}
if (overrideProperties != null) {
- for (Iterator<Object> iterator = overrideProperties.keySet().iterator(); iterator.hasNext();) {
- String key = (String) iterator.next();
+ for (Object object : overrideProperties.keySet()) {
+ String key = (String) object;
String value = overrideProperties.getProperty(key);
buildProperties.put(key, getProject().replaceProperties(value));
}
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/BrandP2Task.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/BrandP2Task.java
index bac6bd5..74332f7 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/BrandP2Task.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/BrandP2Task.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 IBM Corporation and others.
+ * Copyright (c) 2009, 2021 IBM Corporation and others.
*
* This
* program and the accompanying materials are made available under the terms of
@@ -222,8 +222,8 @@
newIUDescription.setFilter(originalIU.getFilter());
List<ITouchpointData> data = brandTouchpointData(originalIU.getTouchpointData());
- for (int i = 0; i < data.size(); i++) {
- newIUDescription.addTouchpointData(data.get(i));
+ for (ITouchpointData element : data) {
+ newIUDescription.addTouchpointData(element);
}
IArtifactKey key = artifactRepo.createArtifactKey(PublisherHelper.BINARY_ARTIFACT_CLASSIFIER, newIUDescription.getId(), newIUDescription.getVersion());
@@ -289,8 +289,8 @@
Map<String, ITouchpointInstruction> instructions = new HashMap<>(td.getInstructions());
String[] phases = new String[] {INSTALL, CONFIGURE};
- for (int phase = 0; phase < phases.length; phase++) {
- ITouchpointInstruction instruction = td.getInstruction(phases[phase]);
+ for (String element : phases) {
+ ITouchpointInstruction instruction = td.getInstruction(element);
if (instruction == null)
continue;
@@ -319,7 +319,7 @@
}
if (phaseChanged) {
TouchpointInstruction newInstruction = new TouchpointInstruction(toString(actions, ";"), instruction.getImportAttribute()); //$NON-NLS-1$
- instructions.put(phases[phase], newInstruction);
+ instructions.put(element, newInstruction);
}
}
@@ -387,9 +387,9 @@
int close = action.lastIndexOf(')');
String parameterString = action.substring(open + 1, close);
String[] parameters = Utils.getArrayFromString(parameterString, ","); //$NON-NLS-1$
- for (int i = 0; i < parameters.length; i++) {
- int colon = parameters[i].indexOf(':');
- result.put(parameters[i].substring(0, colon).trim(), parameters[i].substring(colon + 1).trim());
+ for (String parameter : parameters) {
+ int colon = parameter.indexOf(':');
+ result.put(parameter.substring(0, colon).trim(), parameter.substring(colon + 1).trim());
}
return result;
}
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/FeaturesAndBundlesTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/FeaturesAndBundlesTask.java
index f4cb672..243740d 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/FeaturesAndBundlesTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/FeaturesAndBundlesTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2017 IBM Corporation and others.
+ * Copyright (c) 2009, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -67,9 +67,7 @@
private File[] getLocations(List<FileSet> collection) {
ArrayList<File> results = new ArrayList<>();
- for (Iterator<FileSet> iterator = collection.iterator(); iterator.hasNext();) {
- FileSet set = iterator.next();
-
+ for (FileSet set : collection) {
DirectoryScanner scanner = set.getDirectoryScanner(getProject());
String[][] elements = new String[][] {scanner.getIncludedDirectories(), scanner.getIncludedFiles()};
for (int i = 0; i < 2; i++) {
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/GatherBundleTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/GatherBundleTask.java
index 9729e76..69828c7 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/GatherBundleTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/GatherBundleTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
*
* This
* program and the accompanying materials are made available under the terms of
@@ -116,8 +116,7 @@
fileSet.setProject(getProject());
fileSet.setDir(new File(baseDirectory));
- for (int i = 0; i < splitIncludes.length; i++) {
- String entry = splitIncludes[i];
+ for (String entry : splitIncludes) {
if (entry.equals(ModelBuildScriptGenerator.DOT))
continue;
@@ -138,9 +137,9 @@
}
String[] splitExcludes = Utils.getArrayFromString(exclude != null ? exclude + "," + extraExcludes : extraExcludes); //$NON-NLS-1$
- for (int i = 0; i < splitExcludes.length; i++) {
+ for (String splitExclude : splitExcludes) {
NameEntry fileExclude = fileSet.createExclude();
- fileExclude.setName(splitExcludes[i]);
+ fileExclude.setName(splitExclude);
}
List<String> includedFiles = Arrays.asList(fileSet.getDirectoryScanner().getIncludedFiles());
@@ -174,19 +173,19 @@
fileSet = new FileSet();
fileSet.setProject(getProject());
fileSet.setDir(new File(buildResultFolder));
- for (int i = 0; i < entries.length; i++) {
- String name = entries[i].getName(false);
+ for (CompiledEntry entry : entries) {
+ String name = entry.getName(false);
if (name.equals(ModelBuildScriptGenerator.DOT)) {
dotIncluded = true;
continue;
}
- if (sourceMap.containsKey(name) && entries[i].getType() == CompiledEntry.FOLDER) {
+ if (sourceMap.containsKey(name) && entry.getType() == CompiledEntry.FOLDER) {
Set<OutputFileSet> folders = sourceMap.get(name);
processOutputFolders(folders, name, computer);
} else {
NameEntry fileInclude = fileSet.createInclude();
- fileInclude.setName(name + ((entries[i].getType() == CompiledEntry.FOLDER) ? "/" : "")); //$NON-NLS-1$ //$NON-NLS-2$
+ fileInclude.setName(name + ((entry.getType() == CompiledEntry.FOLDER) ? "/" : "")); //$NON-NLS-1$ //$NON-NLS-2$
haveEntries = true;
}
}
@@ -208,9 +207,9 @@
fileInclude.setName("**"); //$NON-NLS-1$
if (exclude != null) {
String[] splitExcludes = Utils.getArrayFromString(exclude);
- for (int i = 0; i < splitExcludes.length; i++) {
+ for (String splitExclude : splitExcludes) {
NameEntry fileExclude = fileSet.createExclude();
- fileExclude.setName(splitExcludes[i]);
+ fileExclude.setName(splitExclude);
}
}
@@ -235,8 +234,7 @@
private void processOutputFolders(Set<OutputFileSet> folders, String key, GatheringComputer computer) {
boolean dot = key.equals(ModelBuildScriptGenerator.DOT);
- for (Iterator<OutputFileSet> iterator = folders.iterator(); iterator.hasNext();) {
- OutputFileSet outputFiles = iterator.next();
+ for (OutputFileSet outputFiles : folders) {
File baseDir = outputFiles.getDir();
String[] includes = outputFiles.mergeIncludes(getProject());
//handling more than one include here would involve correlating the includes files
@@ -245,10 +243,10 @@
IPath prefix = new Path(includes[0]).removeLastSegments(1);
int count = prefix.segmentCount();
String[] files = outputFiles.getDirectoryScanner().getIncludedFiles();
- for (int i = 0; i < files.length; i++) {
- IPath suffix = new Path(files[i]).removeFirstSegments(count);
+ for (String file : files) {
+ IPath suffix = new Path(file).removeFirstSegments(count);
String computerPath = dot ? suffix.toString() : key + '/' + suffix.toString();
- computer.addFile(computerPath, new File(baseDir, files[i]));
+ computer.addFile(computerPath, new File(baseDir, file));
}
}
}
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/GatherFeatureTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/GatherFeatureTask.java
index 2da8410..cfc79d2 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/GatherFeatureTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/publisher/GatherFeatureTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 IBM Corporation and others.
+ * Copyright (c) 2008, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -129,8 +129,7 @@
fileSet.setProject(getProject());
fileSet.setDir(new File(folder));
String[] splitIncludes = Utils.getArrayFromString(includes);
- for (int i = 0; i < splitIncludes.length; i++) {
- String entry = splitIncludes[i];
+ for (String entry : splitIncludes) {
if (entry.equals(ModelBuildScriptGenerator.DOT))
continue;
@@ -139,9 +138,9 @@
}
String[] splitExcludes = Utils.getArrayFromString(excludes);
- for (int i = 0; i < splitExcludes.length; i++) {
+ for (String splitExclude : splitExcludes) {
NameEntry fileExclude = fileSet.createExclude();
- fileExclude.setName(splitExcludes[i]);
+ fileExclude.setName(splitExclude);
}
return fileSet;
}
@@ -155,8 +154,7 @@
FeatureRootAdvice advice = new FeatureRootAdvice();
Map<String, Map<String, String>> configMap = Utils.processRootProperties(getBuildProperties(), true);
- for (Iterator<String> iterator = configMap.keySet().iterator(); iterator.hasNext();) {
- String config = iterator.next();
+ for (String config : configMap.keySet()) {
Map<String, String> rootMap = configMap.get(config);
if (config.equals(Utils.ROOT_COMMON))
config = ""; //$NON-NLS-1$
@@ -165,8 +163,7 @@
GatheringComputer computer = new GatheringComputer();
Map<FileSet, String> configFileSets = new HashMap<>();
ArrayList<String> permissionsKeys = new ArrayList<>();
- for (Iterator<String> rootEntries = rootMap.keySet().iterator(); rootEntries.hasNext();) {
- String key = rootEntries.next();
+ for (String key : rootMap.keySet()) {
if (key.startsWith(Utils.ROOT_PERMISSIONS)) {
permissionsKeys.add(key);
continue;
@@ -177,8 +174,8 @@
//files!
String fileList = rootMap.get(key);
String[] files = Utils.getArrayFromString(fileList, ","); //$NON-NLS-1$
- for (int i = 0; i < files.length; i++) {
- String file = files[i];
+ for (String file2 : files) {
+ String file = file2;
String fromDir = baseDirectory;
File base = null;
if (file.startsWith("absolute:")) { //$NON-NLS-1$
@@ -208,11 +205,11 @@
include.setName(file);
String[] found = fileset.getDirectoryScanner().getIncludedFiles();
- for (int k = 0; k < found.length; k++) {
+ for (String element : found) {
if (key.length() > 0)
- computer.addFile(key + "/" + found[k], new File(base, found[k])); //$NON-NLS-1$
+ computer.addFile(key + "/" + element, new File(base, element)); //$NON-NLS-1$
else
- computer.addFile(base.getAbsolutePath(), found[k]);
+ computer.addFile(base.getAbsolutePath(), element);
}
configFileSets.put(fileset, key);
}
@@ -223,21 +220,19 @@
advice.addRootfiles(config, computer);
//do permissions, out of the configFileSets, select the files to change permissions on.
- for (Iterator<String> p = permissionsKeys.iterator(); p.hasNext();) {
- String permissionKey = p.next();
+ for (String permissionKey : permissionsKeys) {
String permissionString = rootMap.get(permissionKey);
String[] names = Utils.getArrayFromString(permissionString);
OrSelector orSelector = new OrSelector();
orSelector.setProject(getProject());
- for (int i = 0; i < names.length; i++) {
+ for (String name : names) {
FilenameSelector nameSelector = new FilenameSelector();
nameSelector.setProject(getProject());
- nameSelector.setName(names[i]);
+ nameSelector.setName(name);
orSelector.addFilename(nameSelector);
}
- for (Iterator<FileSet> s = configFileSets.keySet().iterator(); s.hasNext();) {
- FileSet fileset = s.next();
+ for (FileSet fileset : configFileSets.keySet()) {
String finalFolder = configFileSets.get(fileset);
String[] found = selectFiles(orSelector, finalFolder, fileset.getDirectoryScanner().getIncludedFiles());
if (found.length > 0)
@@ -258,8 +253,8 @@
String prefix = (folder.length() > 0) ? folder + '/' : ""; //$NON-NLS-1$
ArrayList<String> result = new ArrayList<>();
- for (int i = 0; i < files.length; i++) {
- String finalLocation = prefix + files[i];
+ for (String file : files) {
+ String finalLocation = prefix + file;
//FilenameSelector is checking based on File.separatorChar, so normalize
finalLocation = finalLocation.replace('/', File.separatorChar).replace('\\', File.separatorChar);
//FilenameSelector objects only care about the filename and not the other arguments
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/AntScriptRunner.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/AntScriptRunner.java
index 23b52ce..1e0ea7e 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/AntScriptRunner.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/AntScriptRunner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * Copyright (c) 2009, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,7 +15,7 @@
package org.eclipse.pde.internal.build.tasks;
import java.io.File;
-import java.util.*;
+import java.util.Map;
import java.util.Map.Entry;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Ant;
@@ -36,8 +36,7 @@
task.setProject(parentTask.getProject());
task.init();
- for (Iterator<Entry<String, String>> iterator = properties.entrySet().iterator(); iterator.hasNext();) {
- Map.Entry<String, String> entry = iterator.next();
+ for (Entry<String, String> entry : properties.entrySet()) {
Property antProperty = task.createProperty();
antProperty.setName(entry.getKey());
antProperty.setValue(entry.getValue());
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/BuildManifestTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/BuildManifestTask.java
index 864e609..91c77e0 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/BuildManifestTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/BuildManifestTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -53,8 +53,8 @@
readDirectory();
try (PrintWriter output = new PrintWriter(new BufferedOutputStream(new FileOutputStream(destination)))) {
List<String> entries = new ArrayList<>(20);
- for (int i = 0; i < elements.length; i++)
- collectEntries(entries, elements[i]);
+ for (String element : elements)
+ collectEntries(entries, element);
generatePrologue(output);
generateEntries(output, entries);
}
@@ -129,8 +129,7 @@
*/
protected void generateEntries(PrintWriter output, List<String> entries) {
Collections.sort(entries);
- for (Iterator<String> iterator = entries.iterator(); iterator.hasNext();) {
- String entry = iterator.next();
+ for (String entry : entries) {
output.println(entry);
}
}
@@ -170,9 +169,9 @@
*/
protected void collectChildrenEntries(List<String> entries, BuildTimeFeature feature) throws CoreException {
FeatureEntry[] pluginEntries = feature.getPluginEntries();
- for (int i = 0; i < pluginEntries.length; i++) {
- String elementId = pluginEntries[i].getId();
- if (pluginEntries[i].isFragment())
+ for (FeatureEntry pluginEntry : pluginEntries) {
+ String elementId = pluginEntry.getId();
+ if (pluginEntry.isFragment())
collectEntries(entries, "fragment@" + elementId); //$NON-NLS-1$
else
collectEntries(entries, "plugin@" + elementId); //$NON-NLS-1$
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/BuildScriptGeneratorTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/BuildScriptGeneratorTask.java
index ff1bb11..6581030 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/BuildScriptGeneratorTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/BuildScriptGeneratorTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -328,8 +328,8 @@
public void setContextRepository(String contexts) {
String[] locations = Utils.getArrayFromString(contexts, ","); //$NON-NLS-1$
ArrayList<URI> uris = new ArrayList<>();
- for (int i = 0; i < locations.length; i++) {
- String context = locations[i];
+ for (String location2 : locations) {
+ String context = location2;
if (context == null || context.startsWith("${") || context.length() == 0) //$NON-NLS-1$
continue;
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/IdReplaceTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/IdReplaceTask.java
index bd90788..67500d5 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/IdReplaceTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/IdReplaceTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -321,9 +321,8 @@
private int scan(StringBuffer buf, int start, String[] targets, boolean wholeWord) {
for (int i = start; i < buf.length(); i++) {
- for (int j = 0; j < targets.length; j++) {
- if (i < buf.length() - targets[j].length()) {
- String candidate = targets[j];
+ for (String candidate : targets) {
+ if (i < buf.length() - candidate.length()) {
String match = buf.substring(i, i + candidate.length());
if (candidate.equalsIgnoreCase(match)) {
if (!wholeWord || Character.isWhitespace(buf.charAt(i + candidate.length())))
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/JNLPGenerator.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/JNLPGenerator.java
index e019722..800a229 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/JNLPGenerator.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/JNLPGenerator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -156,16 +156,16 @@
Map<String, File> validEntries = new HashMap<>();
File[] files = root.listFiles();
- for (int i = 0; i < files.length; i++) {
- String filename = files[i].getName();
+ for (File file : files) {
+ String filename = file.getName();
if (filename.endsWith(appendix)) {
- validEntries.put(filename, files[i]);
+ validEntries.put(filename, file);
}
}
InputStream stream = null;
if (validEntries.size() > 0) {
- for (int i = 0; i < potentials.length; i++) {
- File file = validEntries.get(potentials[i]);
+ for (String potential : potentials) {
+ File file = validEntries.get(potential);
if (file != null) {
try {
stream = new BufferedInputStream(new FileInputStream(file));
@@ -207,8 +207,8 @@
}
InputStream stream = null;
if (validEntries.size() > 0) {
- for (int i = 0; i < potentials.length; i++) {
- ZipEntry entry = validEntries.get(potentials[i]);
+ for (String potential : potentials) {
+ ZipEntry entry = validEntries.get(potential);
if (entry != null) {
try {
stream = featureArchive.getInputStream(entry);
@@ -477,8 +477,8 @@
private boolean isValidEnvironment(String os, String ws, String arch) {
if (configs.length == 0)
return true;
- for (int i = 0; i < configs.length; i++) {
- if (isMatching(os, configs[i].getOs()) && isMatching(ws, configs[i].getWs()) && isMatching(arch, configs[i].getArch()))
+ for (Config config : configs) {
+ if (isMatching(os, config.getOs()) && isMatching(ws, config.getWs()) && isMatching(arch, config.getArch()))
return true;
}
return false;
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/LicenseReplaceTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/LicenseReplaceTask.java
index ea5df2d..440ee80 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/LicenseReplaceTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/LicenseReplaceTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -255,9 +255,8 @@
private int scan(StringBuffer buf, int start, String[] targets, boolean wholeWord) {
for (int i = start; i < buf.length(); i++) {
- for (int j = 0; j < targets.length; j++) {
- if (i < buf.length() - targets[j].length()) {
- String candidate = targets[j];
+ for (String candidate : targets) {
+ if (i < buf.length() - candidate.length()) {
String match = buf.substring(i, i + candidate.length());
if (candidate.equalsIgnoreCase(match)) {
if (!wholeWord || Character.isWhitespace(buf.charAt(i + candidate.length())))
@@ -317,9 +316,7 @@
String[] propertyFiles = fileSet.getDirectoryScanner().getIncludedFiles();
- for (int i = 0; i < propertyFiles.length; i++) {
- String propertyFile = propertyFiles[i];
-
+ for (String propertyFile : propertyFiles) {
File featurePropertyFile = new File(filePath, propertyFile);
File licensePropertyFile = new File(licensePath, propertyFile);
FileInputStream fis = null;
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/ManifestModifier.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/ManifestModifier.java
index 1f2496d..d0c224e 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/ManifestModifier.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/ManifestModifier.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -73,8 +73,7 @@
}
private void applyChanges() {
- for (Iterator<Entry<String, String>> iter = newValues.entrySet().iterator(); iter.hasNext();) {
- Map.Entry<String, String> entry = iter.next();
+ for (Entry<String, String> entry : newValues.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (value == null) {
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/PluginVersionReplaceTask.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/PluginVersionReplaceTask.java
index 97848f8..d6df87b 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/PluginVersionReplaceTask.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/PluginVersionReplaceTask.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -131,10 +131,10 @@
private int scan(StringBuffer buf, int start, String[] targets) {
for (int i = start; i < buf.length(); i++) {
- for (int j = 0; j < targets.length; j++) {
- if (i < buf.length() - targets[j].length()) {
- String match = buf.substring(i, i + targets[j].length());
- if (targets[j].equalsIgnoreCase(match))
+ for (String target2 : targets) {
+ if (i < buf.length() - target2.length()) {
+ String match = buf.substring(i, i + target2.length());
+ if (target2.equalsIgnoreCase(match))
return i;
}
}
diff --git a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/TaskHelper.java b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/TaskHelper.java
index 5403829..843d9bc 100644
--- a/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/TaskHelper.java
+++ b/org.eclipse.pde.build/src_ant/org/eclipse/pde/internal/build/tasks/TaskHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
+ * Copyright (c) 2006, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -21,9 +21,9 @@
if (b == null)
b = new StringBuffer();
b.append(status.getMessage());
- for (int i = 0; i < nestedStatus.length; i++) {
+ for (IStatus element : nestedStatus) {
b.append('\n');
- b.append(statusToString(nestedStatus[i], b));
+ b.append(statusToString(element, b));
}
return b;
}