Skip to content

Commit

Permalink
Clean-up and modernize target-platform loading classes
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Sep 10, 2024
1 parent ebb82cf commit 33efe8c
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 495 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2023 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -292,7 +292,7 @@ public static ITargetDefinition getUnresolvedRepositoryBasedWorkspaceTarget() th
private static boolean containsNotEmptyIULocation(ITargetLocation[] locations) {
return locations != null && Arrays.stream(locations) //
.filter(IUBundleContainer.class::isInstance).map(IUBundleContainer.class::cast)
.map(IUBundleContainer::getRepositories).anyMatch(uri -> uri != null && uri.length > 0);
.map(IUBundleContainer::getRepositories).anyMatch(uri -> !uri.isEmpty());
}

public static Set<String> getApplicationNameSet() {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ public ITargetLocation getTargetLocation(String type, String serializedXML) thro
}
}
}
String[] iuIDs = ids.toArray(new String[ids.size()]);
String[] iuVer = versions.toArray(new String[versions.size()]);
URI[] uris = repos.toArray(new URI[repos.size()]);

int flags = IUBundleContainer.INCLUDE_REQUIRED;
if (includeMode != null && includeMode.trim().length() > 0) {
Expand All @@ -109,8 +106,8 @@ public ITargetLocation getTargetLocation(String type, String serializedXML) thro
} else {
flags |= Boolean.parseBoolean(followRepositoryReferences) ? IUBundleContainer.FOLLOW_REPOSITORY_REFERENCES : 0;
}
return TargetPlatformService.getDefault().newIULocation(iuIDs, iuVer, uris,
flags);
return TargetPlatformService.getDefault().newIULocation( //
ids.toArray(String[]::new), versions.toArray(String[]::new), repos.toArray(URI[]::new), flags);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Arrays;
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Consumer;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.stream.Stream;
Expand Down Expand Up @@ -57,14 +58,14 @@ public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle[] b
return Stream.concat(generateInstallableUnits(bundles), generateInstallableUnits(features));
}

public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle[] bundles) {
private static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle[] bundles) {
if (bundles == null || bundles.length == 0) {
return Stream.empty();
}
return Arrays.stream(bundles).flatMap(InstallableUnitGenerator::generateInstallableUnits);
return Arrays.stream(bundles).mapMulti(InstallableUnitGenerator::generateInstallableUnits);
}

public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle targetBundle) {
private static void generateInstallableUnits(TargetBundle targetBundle, Consumer<IInstallableUnit> downStream) {
BundleInfo bundleInfo = targetBundle.getBundleInfo();
if (bundleInfo != null) {
String manifest = bundleInfo.getManifest();
Expand All @@ -87,24 +88,23 @@ public static Stream<IInstallableUnit> generateInstallableUnits(TargetBundle tar
BundlesAction.createBundleArtifactKey(bundleDescription.getSymbolicName(),
bundleDescription.getVersion().toString()),
publisherInfo);
return Stream.of(iu);
downStream.accept(iu);
}
} catch (IOException e) {
// can't use it then...
}
}
}
return Stream.empty();
}

public static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature[] features) {
private static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature[] features) {
if (features == null || features.length == 0) {
return Stream.empty();
}
return Arrays.stream(features).flatMap(InstallableUnitGenerator::generateInstallableUnits);
}

public static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature targetFeature) {
private static Stream<IInstallableUnit> generateInstallableUnits(TargetFeature targetFeature) {
String location = targetFeature.getLocation();
if (location != null) {
Feature feature = new FeatureParser().parse(new File(location));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.pde.internal.core.target.Messages"; //$NON-NLS-1$
public static String AbstractBundleContainer_1;
public static String AbstractBundleContainer_3;
public static String AbstractTargetHandle_0;
public static String DirectoryBundleContainer_0;
public static String DirectoryBundleContainer_1;
public static String FeatureBundleContainer_0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

AbstractBundleContainer_3=Required plug-in could not be found: {0}
AbstractBundleContainer_1=Required plug-in with version {0} not found: {1}
AbstractTargetHandle_0=Profile registry service not found
DirectoryBundleContainer_0=Reading bundles...
DirectoryBundleContainer_1=Directory does not exist: {0}
FeatureBundleContainer_0=Directory does not exist: {0}
Expand Down
Loading

0 comments on commit 33efe8c

Please sign in to comment.