Search in sources :

Example 16 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class AbstractDependenciesAction method getVersionRange.

/**
 * @see org.eclipse.tycho.artifacts.DependencyArtifacts.getArtifact(String, String, String)
 */
protected VersionRange getVersionRange(Version version) {
    if (version == null || OSGi_versionMin.equals(version)) {
        return VersionRange.emptyRange;
    }
    org.osgi.framework.Version osgiVersion = PublisherHelper.toOSGiVersion(version);
    String qualifier = osgiVersion.getQualifier();
    if (qualifier == null || "".equals(qualifier) || ANY_QUALIFIER.equals(qualifier)) {
        Version from = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(), osgiVersion.getMicro());
        Version to = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor(), osgiVersion.getMicro() + 1);
        return new VersionRange(from, true, to, false);
    }
    return new VersionRange(version, true, version, true);
}
Also used : Version(org.eclipse.equinox.p2.metadata.Version) VersionRange(org.eclipse.equinox.p2.metadata.VersionRange)

Example 17 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class ArtifactMatcher method getRangeOfEquivalentVersions.

/**
 * Returns a version range which includes "equivalent" versions, i.e. versions with the same
 * major, minor, and micro version.
 */
private static VersionRange getRangeOfEquivalentVersions(Version version) {
    Integer major = (Integer) version.getSegment(0);
    Integer minor = (Integer) version.getSegment(1);
    Integer micro = (Integer) version.getSegment(2);
    VersionRange range = new VersionRange(Version.createOSGi(major, minor, micro), true, Version.createOSGi(major, minor, micro + 1), false);
    return range;
}
Also used : VersionRange(org.eclipse.equinox.p2.metadata.VersionRange)

Example 18 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class TargetPlatformBundlePublisherTest method testPomDependencyOnOtherType.

@Test
public void testPomDependencyOnOtherType() throws Exception {
    File otherFile = resourceFile("platformbuilder/pom-dependencies/other-type.xml");
    IArtifactFacade otherArtifact = new ArtifactMock(otherFile, GROUP_ID, ARTIFACT_ID, VERSION, "pom");
    IInstallableUnit unit = subject.attemptToPublishBundle(otherArtifact);
    assertNull(unit);
}
Also used : IArtifactFacade(org.eclipse.tycho.p2.metadata.IArtifactFacade) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ResourceUtil.resourceFile(org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile) File(java.io.File) Test(org.junit.Test)

Example 19 with Version

use of org.eclipse.equinox.p2.metadata.Version in project tycho by eclipse.

the class SourcesBundleDependencyMetadataGenerator method getPublisherActions.

@Override
protected List<IPublisherAction> getPublisherActions(IArtifactFacade artifact, List<TargetEnvironment> environments, OptionalResolutionAction optionalAction) {
    ArrayList<IPublisherAction> actions = new ArrayList<>();
    String id = artifact.getArtifactId();
    String version = toCanonicalVersion(artifact.getVersion());
    try {
        // generated source bundle is not available at this point in filesystem yet, need to create
        // in-memory BundleDescription instead
        Dictionary<String, String> manifest = new Hashtable<>();
        manifest.put("Manifest-Version", "1.0");
        manifest.put("Bundle-ManifestVersion", "2");
        String sourceBundleSymbolicName = id + ".source";
        manifest.put("Bundle-SymbolicName", sourceBundleSymbolicName);
        manifest.put("Bundle-Version", version);
        manifest.put("Eclipse-SourceBundle", id + ";version=" + version + ";roots:=\".\"");
        StateObjectFactory factory = StateObjectFactory.defaultFactory;
        BundleDescription bundleDescription = factory.createBundleDescription(factory.createState(false), manifest, artifact.getLocation().getAbsolutePath(), createId(sourceBundleSymbolicName, version));
        bundleDescription.setUserObject(manifest);
        actions.add(new BundlesAction(new BundleDescription[] { bundleDescription }) {

            @Override
            protected void createAdviceFileAdvice(BundleDescription bundleDescription, IPublisherInfo publisherInfo) {
            // 367255 p2.inf is not applicable to sources bundles
            }
        });
    } catch (BundleException e) {
        throw new RuntimeException(e);
    }
    return actions;
}
Also used : IPublisherAction(org.eclipse.equinox.p2.publisher.IPublisherAction) BundlesAction(org.eclipse.equinox.p2.publisher.eclipse.BundlesAction) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ArrayList(java.util.ArrayList) IPublisherInfo(org.eclipse.equinox.p2.publisher.IPublisherInfo) StateObjectFactory(org.eclipse.osgi.service.resolver.StateObjectFactory) BundleException(org.osgi.framework.BundleException)

Example 20 with Version

use of org.eclipse.equinox.p2.metadata.Version in project knime-core by knime.

the class InvokeUpdateAction method openWizard.

@Override
protected void openWizard(final LoadMetadataRepositoryJob job, final ProvisioningUI provUI) {
    final UpdateOperation operation = provUI.getUpdateOperation(null, null);
    // check for updates
    operation.resolveModal(null);
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

        @Override
        public void run() {
            Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
            if (!operation.hasResolved()) {
                MessageDialog.openInformation(shell, "Update KNIME...", "No updates were found");
            } else if (provUI.getPolicy().continueWorkingWithOperation(operation, shell)) {
                if (UpdateSingleIUWizard.validFor(operation)) {
                    // Special case for only updating a single root
                    UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(provUI, operation);
                    WizardDialog dialog = new WizardDialog(shell, wizard);
                    dialog.create();
                    if (dialog.open() == 0) {
                        clearOsgiAreaBeforeRestart();
                    }
                } else {
                    // Open the normal version of the update wizard
                    if (provUI.openUpdateWizard(false, operation, job) == 0) {
                        clearOsgiAreaBeforeRestart();
                    }
                }
            }
        }
    });
}
Also used : Shell(org.eclipse.swt.widgets.Shell) UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) UpdateSingleIUWizard(org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)25 Version (org.eclipse.equinox.p2.metadata.Version)15 Test (org.junit.Test)15 File (java.io.File)12 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)12 ArrayList (java.util.ArrayList)8 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)7 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)7 IStatus (org.eclipse.core.runtime.IStatus)5 IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)5 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)5 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 CoreException (org.eclipse.core.runtime.CoreException)3 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)3 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2