Skip to content

Commit 33efe8c

Browse files
committed
Clean-up and modernize target-platform loading classes
1 parent ebb82cf commit 33efe8c

13 files changed

+282
-495
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/TargetPlatformHelper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2023 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -292,7 +292,7 @@ public static ITargetDefinition getUnresolvedRepositoryBasedWorkspaceTarget() th
292292
private static boolean containsNotEmptyIULocation(ITargetLocation[] locations) {
293293
return locations != null && Arrays.stream(locations) //
294294
.filter(IUBundleContainer.class::isInstance).map(IUBundleContainer.class::cast)
295-
.map(IUBundleContainer::getRepositories).anyMatch(uri -> uri != null && uri.length > 0);
295+
.map(IUBundleContainer::getRepositories).anyMatch(uri -> !uri.isEmpty());
296296
}
297297

298298
public static Set<String> getApplicationNameSet() {

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java

+88-148
Large diffs are not rendered by default.

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IULocationFactory.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ public ITargetLocation getTargetLocation(String type, String serializedXML) thro
8989
}
9090
}
9191
}
92-
String[] iuIDs = ids.toArray(new String[ids.size()]);
93-
String[] iuVer = versions.toArray(new String[versions.size()]);
94-
URI[] uris = repos.toArray(new URI[repos.size()]);
9592

9693
int flags = IUBundleContainer.INCLUDE_REQUIRED;
9794
if (includeMode != null && includeMode.trim().length() > 0) {
@@ -109,8 +106,8 @@ public ITargetLocation getTargetLocation(String type, String serializedXML) thro
109106
} else {
110107
flags |= Boolean.parseBoolean(followRepositoryReferences) ? IUBundleContainer.FOLLOW_REPOSITORY_REFERENCES : 0;
111108
}
112-
return TargetPlatformService.getDefault().newIULocation(iuIDs, iuVer, uris,
113-
flags);
109+
return TargetPlatformService.getDefault().newIULocation( //
110+
ids.toArray(String[]::new), versions.toArray(String[]::new), repos.toArray(URI[]::new), flags);
114111
}
115112
return null;
116113
}

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/InstallableUnitGenerator.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Arrays;
2424
import java.util.Map.Entry;
2525
import java.util.Set;
26+
import java.util.function.Consumer;
2627
import java.util.jar.Attributes;
2728
import java.util.jar.Manifest;
2829
import java.util.stream.Stream;
@@ -57,14 +58,14 @@ public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle[] b
5758
return Stream.concat(generateInstallableUnits(bundles), generateInstallableUnits(features));
5859
}
5960

60-
public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle[] bundles) {
61+
private static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle[] bundles) {
6162
if (bundles == null || bundles.length == 0) {
6263
return Stream.empty();
6364
}
64-
return Arrays.stream(bundles).flatMap(InstallableUnitGenerator::generateInstallableUnits);
65+
return Arrays.stream(bundles).mapMulti(InstallableUnitGenerator::generateInstallableUnits);
6566
}
6667

67-
public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle targetBundle) {
68+
private static void generateInstallableUnits(TargetBundle targetBundle, Consumer<IInstallableUnit> downStream) {
6869
BundleInfo bundleInfo = targetBundle.getBundleInfo();
6970
if (bundleInfo != null) {
7071
String manifest = bundleInfo.getManifest();
@@ -87,24 +88,23 @@ public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle tar
8788
BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(),
8889
bundleDescription.getVersion().toString()),
8990
publisherInfo);
90-
return Stream.of(iu);
91+
downStream.accept(iu);
9192
}
9293
} catch (IOException e) {
9394
// can't use it then...
9495
}
9596
}
9697
}
97-
return Stream.empty();
9898
}
9999

100-
public static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature[] features) {
100+
private static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature[] features) {
101101
if (features == null || features.length == 0) {
102102
return Stream.empty();
103103
}
104104
return Arrays.stream(features).flatMap(InstallableUnitGenerator::generateInstallableUnits);
105105
}
106106

107-
public static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature targetFeature) {
107+
private static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature targetFeature) {
108108
String location = targetFeature.getLocation();
109109
if (location != null) {
110110
Feature feature = new FeatureParser().parse(new File(location));

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.java

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ public class Messages extends NLS {
1919
private static final String BUNDLE_NAME = "org.eclipse.pde.internal.core.target.Messages"; //$NON-NLS-1$
2020
public static String AbstractBundleContainer_1;
2121
public static String AbstractBundleContainer_3;
22-
public static String AbstractTargetHandle_0;
2322
public static String DirectoryBundleContainer_0;
2423
public static String DirectoryBundleContainer_1;
2524
public static String FeatureBundleContainer_0;

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/Messages.properties

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
AbstractBundleContainer_3=Required plug-in could not be found: {0}
1616
AbstractBundleContainer_1=Required plug-in with version {0} not found: {1}
17-
AbstractTargetHandle_0=Profile registry service not found
1817
DirectoryBundleContainer_0=Reading bundles...
1918
DirectoryBundleContainer_1=Directory does not exist: {0}
2019
FeatureBundleContainer_0=Directory does not exist: {0}

0 commit comments

Comments
 (0)