Skip to content

Commit

Permalink
Fix eclipse-tycho#117 tycho-p2-extras-plugin:publish-features-and-bun…
Browse files Browse the repository at this point in the history
…dles - (eclipse-tycho#119)

Unresolved requirement: Import-Package: org.eclipse.tycho

Signed-off-by: Christoph Läubrich <laeubi@laeubi-soft.de>
  • Loading branch information
laeubi committed May 5, 2021
1 parent 79aec69 commit 75ded10
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 33 deletions.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2011 Sonatype Inc. and others.
* Copyright (c) 2008, 2021 Sonatype Inc. and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -36,6 +36,11 @@ public static interface EquinoxRuntimeDescription {
}

// TODO do we need more specific exception type here?
public void locateRuntime(EquinoxRuntimeDescription description) throws Exception;

default void locateRuntime(EquinoxRuntimeDescription description) throws Exception {
locateRuntime(description, false);
}

public void locateRuntime(EquinoxRuntimeDescription description, boolean forked) throws Exception;

}
Expand Up @@ -115,7 +115,7 @@ public void addBundle(File location) {
public void addBundleStartLevel(String id, int level, boolean autostart) {
description.addBundleStartLevel(new BundleStartLevel(id, level, autostart));
}
});
}, true);

EquinoxInstallation installation = installationFactory.createInstallation(description,
installationFolder);
Expand Down
Expand Up @@ -26,6 +26,9 @@
<plugin id="biz.aQute.bndlib"/>
<plugin id="org.apache.commons.codec"/>
<plugin id="org.apache.commons.logging"/>
<plugin id="org.apache.felix.gogo.command"/>
<plugin id="org.apache.felix.gogo.runtime"/>
<plugin id="org.apache.felix.gogo.shell"/>
<plugin id="org.apache.felix.scr"/>
<plugin id="org.apache.httpcomponents.httpclient"/>
<plugin id="org.apache.httpcomponents.httpcore"/>
Expand All @@ -43,6 +46,7 @@
<plugin id="org.eclipse.equinox.app"/>
<plugin id="org.eclipse.equinox.common"/>
<plugin id="org.eclipse.equinox.concurrent"/>
<plugin id="org.eclipse.equinox.console"/>
<plugin id="org.eclipse.equinox.frameworkadmin"/>
<plugin id="org.eclipse.equinox.frameworkadmin.equinox"/>
<plugin id="org.eclipse.equinox.launcher"/>
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2012 Sonatype Inc. and others.
* Copyright (c) 2008, 2021 Sonatype Inc. 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
Expand All @@ -22,6 +22,11 @@ public interface TychoOsgiRuntimeArtifacts {
*/
public static final String HINT_FRAMEWORK = "framework";

/**
* tycho shared runtime artifact
*/
public static final String HINT_SHARED = "shared";

/**
* Bundle manifest attribute name, if set, bundle is not intended for use when Tycho is embedded
* in another Equinox-based application. The only currently known use case is the Equinox secure
Expand All @@ -37,4 +42,13 @@ public interface TychoOsgiRuntimeArtifacts {
* the runtime as is.
*/
public List<Dependency> getRuntimeArtifacts();

static Dependency newDependency(String groupId, String artifactId, String version, String type) {
Dependency d = new Dependency();
d.setGroupId(groupId);
d.setArtifactId(artifactId);
d.setVersion(version);
d.setType(type);
return d;
}
}
Expand Up @@ -95,34 +95,42 @@ public class TychoOsgiRuntimeLocator implements EquinoxRuntimeLocator {
private DevWorkspaceResolver workspaceState;

@Override
public void locateRuntime(EquinoxRuntimeDescription description) throws MavenExecutionException {
public void locateRuntime(EquinoxRuntimeDescription description, boolean forked) throws MavenExecutionException {
WorkspaceTychoOsgiRuntimeLocator workspaceLocator = WorkspaceTychoOsgiRuntimeLocator
.getResolver(this.workspaceState);

MavenSession session = buildContext.getSession();

addRuntimeArtifacts(workspaceLocator, session, description);

for (String systemPackage : SYSTEM_PACKAGES_EXTRA) {
description.addExtraSystemPackage(systemPackage);
TychoOsgiRuntimeArtifacts framework = runtimeArtifacts.get(TychoOsgiRuntimeArtifacts.HINT_FRAMEWORK);
if (framework != null) {
addRuntimeArtifacts(workspaceLocator, description, session, framework);
}

if (forked) {
TychoOsgiRuntimeArtifacts shared = runtimeArtifacts.get(TychoOsgiRuntimeArtifacts.HINT_SHARED);
if (framework != null) {
addRuntimeArtifacts(workspaceLocator, description, session, shared);
}
} else {
for (String systemPackage : SYSTEM_PACKAGES_EXTRA) {
description.addExtraSystemPackage(systemPackage);
}
}
addAdditionalRuntimeArtifacts(workspaceLocator, session, description);
if (workspaceLocator != null) {
workspaceLocator.addPlatformProperties(description);
}
}

public void addRuntimeArtifacts(WorkspaceTychoOsgiRuntimeLocator workspaceLocator, MavenSession session,
public void addAdditionalRuntimeArtifacts(WorkspaceTychoOsgiRuntimeLocator workspaceLocator, MavenSession session,
EquinoxRuntimeDescription description) throws MavenExecutionException {
TychoOsgiRuntimeArtifacts framework = runtimeArtifacts.get(TychoOsgiRuntimeArtifacts.HINT_FRAMEWORK);
if (framework != null) {
addRuntimeArtifacts(workspaceLocator, description, session, framework);
}

for (Map.Entry<String, TychoOsgiRuntimeArtifacts> entry : runtimeArtifacts.entrySet()) {
if (!TychoOsgiRuntimeArtifacts.HINT_FRAMEWORK.equals(entry.getKey())) {
addRuntimeArtifacts(workspaceLocator, description, session, entry.getValue());
if (TychoOsgiRuntimeArtifacts.HINT_FRAMEWORK.equals(entry.getKey())) {
continue;
}
if (TychoOsgiRuntimeArtifacts.HINT_SHARED.equals(entry.getKey())) {
continue;
}
addRuntimeArtifacts(workspaceLocator, description, session, entry.getValue());
}
}

Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2012 Sonatype Inc. and others.
* Copyright (c) 2008, 2021 Sonatype Inc. 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
Expand All @@ -26,24 +26,15 @@ public class TychoOsgiRuntimeMainArtifacts implements TychoOsgiRuntimeArtifacts

String tychoVersion = TychoVersion.getTychoVersion();

ARTIFACTS.add(newDependency("org.eclipse.tycho", "tycho-bundles-external", tychoVersion, "zip"));
ARTIFACTS.add(newDependency("org.eclipse.tycho", "org.eclipse.tycho.p2.resolver.impl", tychoVersion, "jar"));
ARTIFACTS.add(newDependency("org.eclipse.tycho", "org.eclipse.tycho.p2.maven.repository", tychoVersion, "jar"));
ARTIFACTS.add(newDependency("org.eclipse.tycho", "org.eclipse.tycho.p2.tools.impl", tychoVersion, "jar"));
ARTIFACTS.add(TychoOsgiRuntimeArtifacts.newDependency("org.eclipse.tycho", "tycho-bundles-external", tychoVersion, "zip"));
ARTIFACTS.add(TychoOsgiRuntimeArtifacts.newDependency("org.eclipse.tycho", "org.eclipse.tycho.p2.resolver.impl", tychoVersion, "jar"));
ARTIFACTS.add(TychoOsgiRuntimeArtifacts.newDependency("org.eclipse.tycho", "org.eclipse.tycho.p2.maven.repository", tychoVersion, "jar"));
ARTIFACTS.add(TychoOsgiRuntimeArtifacts.newDependency("org.eclipse.tycho", "org.eclipse.tycho.p2.tools.impl", tychoVersion, "jar"));
}

@Override
public List<Dependency> getRuntimeArtifacts() {
return ARTIFACTS;
}

private static Dependency newDependency(String groupId, String artifactId, String version, String type) {
Dependency d = new Dependency();
d.setGroupId(groupId);
d.setArtifactId(artifactId);
d.setVersion(version);
d.setType(type);
return d;
}

}
@@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2021 Christoph Läubrich 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:
* Christoph Läubrich - initial API and implementation
*******************************************************************************/
package org.eclipse.tycho.osgi.runtime;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.maven.model.Dependency;
import org.codehaus.plexus.component.annotations.Component;
import org.eclipse.tycho.core.utils.TychoVersion;

@Component(role = TychoOsgiRuntimeArtifacts.class, hint = TychoOsgiRuntimeArtifacts.HINT_SHARED)
public class TychoOsgiSharedArtifacts implements TychoOsgiRuntimeArtifacts {
private static final List<Dependency> ARTIFACTS;

static {
ARTIFACTS = new ArrayList<>();

String tychoVersion = TychoVersion.getTychoVersion();

ARTIFACTS.add(TychoOsgiRuntimeArtifacts.newDependency("org.eclipse.tycho", "org.eclipse.tycho.core.shared",
tychoVersion, "jar"));
ARTIFACTS.add(TychoOsgiRuntimeArtifacts.newDependency("org.eclipse.tycho", "org.eclipse.tycho.embedder.shared",
tychoVersion, "jar"));
ARTIFACTS.add(TychoOsgiRuntimeArtifacts.newDependency("org.eclipse.tycho",
"org.eclipse.tycho.p2.resolver.shared", tychoVersion, "jar"));
ARTIFACTS.add(TychoOsgiRuntimeArtifacts.newDependency("org.eclipse.tycho", "org.eclipse.tycho.p2.tools.shared",
tychoVersion, "jar"));
}

@Override
public List<Dependency> getRuntimeArtifacts() {
return Collections.unmodifiableList(ARTIFACTS);
}

}
Expand Up @@ -18,7 +18,7 @@
@Component(role = EquinoxRuntimeLocator.class, hint = "stub")
public class StubEquinoxRuntimeLocator implements EquinoxRuntimeLocator {
@Override
public void locateRuntime(EquinoxRuntimeDescription description) throws Exception {
public void locateRuntime(EquinoxRuntimeDescription description, boolean forked) throws Exception {
throw new UnsupportedOperationException();
}
}

0 comments on commit 75ded10

Please sign in to comment.