blob: 881a709270bfc04852f5ceada26300f3233bbbbf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*******************************************************************************
* Copyright (c) 2009 IBM Corporation 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
*
* Contributors:
* IBM Corporation - initial API and implementation
* EclipseSource - ongoing development
*******************************************************************************/
package org.eclipse.equinox.internal.p2.touchpoint.eclipse;
import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
import java.io.File;
import org.eclipse.core.runtime.Path;
import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.publisher.eclipse.*;
import org.eclipse.osgi.service.resolver.BundleDescription;
public class PublisherUtil {
/**
* Returns an IU corresponding to the given artifact key and bundle, or <code>null</code>
* if an IU could not be created.
*/
public static IInstallableUnit createBundleIU(IArtifactKey artifactKey, File bundleFile) {
BundleDescription bundleDescription = BundlesAction.createBundleDescription(bundleFile);
if (bundleDescription == null)
return null;
PublisherInfo info = new PublisherInfo();
Version version = new Version(bundleDescription.getVersion().toString());
AdviceFileAdvice advice = new AdviceFileAdvice(bundleDescription.getSymbolicName(), version, new Path(bundleFile.getAbsolutePath()), AdviceFileAdvice.BUNDLE_ADVICE_FILE);
if (advice.containsAdvice())
info.addAdvice(advice);
String shape = bundleFile.isDirectory() ? IBundleShapeAdvice.DIR : IBundleShapeAdvice.JAR;
info.addAdvice(new BundleShapeAdvice(bundleDescription.getSymbolicName(), version, shape));
return BundlesAction.createBundleIU(bundleDescription, artifactKey, info);
}
}
|