Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oberlies2012-09-23 13:04:16 +0000
committerTobias Oberlies2012-09-24 14:57:19 +0000
commit1ab5536d572eec552f3105d08e1deef1f3f5aea7 (patch)
treec5951e05f8a5c5da94cefc9f92cb96f59252d376 /bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox
parentb1df469a2938fd2d98cba299ca8d9a88cbdaf0f9 (diff)
downloadrt.equinox.p2-1ab5536d572eec552f3105d08e1deef1f3f5aea7.tar.gz
rt.equinox.p2-1ab5536d572eec552f3105d08e1deef1f3f5aea7.tar.xz
rt.equinox.p2-1ab5536d572eec552f3105d08e1deef1f3f5aea7.zip
388566 Refactorings in JREAction(Test)
- Extract methods in JREAction. - In JREActionTest, split verify method for metadata and config IU. - Dropped config IU tests where config IU is empty anyway. Bug: 388566 JREAction: Publish osgi.ee capabilities in 'a.jre' IUs
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox')
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java46
1 files changed, 24 insertions, 22 deletions
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java
index b0436475c..dae3d059a 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/JREAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Code 9 and others. All rights reserved. This
+ * Copyright (c) 2008, 2012 Code 9 and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -13,8 +13,7 @@ package org.eclipse.equinox.p2.publisher.actions;
import java.io.*;
import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
@@ -110,29 +109,32 @@ public class JREAction extends AbstractPublisherAction {
return PublisherHelper.createArtifactDescriptor(info, key, jreLocation);
}
- private IProvidedCapability[] generateJRECapability(String id, Version version) {
+ private List<IProvidedCapability> generateJRECapability(String id, Version version) {
if (profileProperties == null)
- return new IProvidedCapability[0];
+ return Collections.emptyList();
+ List<IProvidedCapability> result = new ArrayList<IProvidedCapability>();
+ result.add(PublisherHelper.createSelfCapability(id, version));
+ generateProvidedPackages(result);
+ return result;
+ }
+
+ private void generateProvidedPackages(List<IProvidedCapability> result) {
String packages = profileProperties.get(PROFILE_SYSTEM_PACKAGES);
- if (packages == null || (packages.trim().length() == 0))
- return new IProvidedCapability[] {PublisherHelper.createSelfCapability(id, version)};
+ if (packages != null && (packages.trim().length() > 0)) {
- try {
- ManifestElement[] jrePackages = ManifestElement.parseHeader(PROFILE_SYSTEM_PACKAGES, packages);
- IProvidedCapability[] exportedPackageAsCapabilities = new IProvidedCapability[jrePackages.length + 1];
- exportedPackageAsCapabilities[0] = PublisherHelper.createSelfCapability(id, version);
- for (int i = 1; i <= jrePackages.length; i++) {
- String packageName = jrePackages[i - 1].getValue();
- Version packageVersion = Version.create(jrePackages[i - 1].getAttribute("version")); //$NON-NLS-1$
- exportedPackageAsCapabilities[i] = MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, packageName, packageVersion);
+ try {
+ ManifestElement[] jrePackages = ManifestElement.parseHeader(PROFILE_SYSTEM_PACKAGES, packages);
+ for (int i = 0; i < jrePackages.length; i++) {
+ String packageName = jrePackages[i].getValue();
+ Version packageVersion = Version.create(jrePackages[i].getAttribute("version")); //$NON-NLS-1$
+ result.add(MetadataFactory.createProvidedCapability(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, packageName, packageVersion));
+ }
+ } catch (BundleException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- return exportedPackageAsCapabilities;
- } catch (BundleException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
- return new IProvidedCapability[0];
}
private void generateJREIUData(InstallableUnitDescription iu) {
@@ -173,8 +175,8 @@ public class JREAction extends AbstractPublisherAction {
profileName = profileName.replace('_', '.');
iu.setId("a.jre." + profileName.toLowerCase()); //$NON-NLS-1$
- IProvidedCapability[] capabilities = generateJRECapability(iu.getId(), iu.getVersion());
- iu.setCapabilities(capabilities);
+ List<IProvidedCapability> capabilities = generateJRECapability(iu.getId(), iu.getVersion());
+ iu.addProvidedCapabilities(capabilities);
}
private void initialize(IPublisherInfo publisherInfo) {

Back to the top