Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using a hosted eclipse platform as target #1624

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %name
Bundle-SymbolicName: org.eclipse.pde.core; singleton:=true
Bundle-Version: 3.20.100.qualifier
Bundle-Version: 3.21.0.qualifier
Bundle-Activator: org.eclipse.pde.internal.core.PDECore
Bundle-Vendor: %provider-name
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,39 @@ public interface IBuildEntry extends IWritable {
/**
* A property name for changes to the 'name' field.
*/
public static final String P_NAME = "name"; //$NON-NLS-1$
String P_NAME = "name"; //$NON-NLS-1$
/**
* The prefix for any key denoting the source folders that
* should be compiled into a JAR. The suffix will
* be the name of the JAR.
*/
public static final String JAR_PREFIX = "source."; //$NON-NLS-1$
String JAR_PREFIX = "source."; //$NON-NLS-1$
/**
* The prefix for any key denoting output folders for a particular
* JAR. The suffix will be the name of the JAR.
*/
public static final String OUTPUT_PREFIX = "output."; //$NON-NLS-1$
String OUTPUT_PREFIX = "output."; //$NON-NLS-1$
/**
* The name of the key that lists all the folders and files
* to be included in the binary build.
*/
public static final String BIN_INCLUDES = "bin.includes"; //$NON-NLS-1$
String BIN_INCLUDES = "bin.includes"; //$NON-NLS-1$
/**
* The name of the key that lists all the folders and files
* to be included in the source build.
*/
public static final String SRC_INCLUDES = "src.includes"; //$NON-NLS-1$
String SRC_INCLUDES = "src.includes"; //$NON-NLS-1$
/**
* The name of the key that declares extra library entries to be added
* to the class path at build time only..
*/
public static final String JARS_EXTRA_CLASSPATH = "jars.extra.classpath"; //$NON-NLS-1$
String JARS_EXTRA_CLASSPATH = "jars.extra.classpath"; //$NON-NLS-1$
/**
* The name of the key that declares additional plug-in dependencies to augment development classpath
*
* @since 3.2
*/
public static final String SECONDARY_DEPENDENCIES = "additional.bundles"; //$NON-NLS-1$
String SECONDARY_DEPENDENCIES = "additional.bundles"; //$NON-NLS-1$

/**
* Adds the token to the list of token for this entry.
Expand Down Expand Up @@ -89,6 +89,19 @@ public interface IBuildEntry extends IWritable {
*/
String[] getTokens();

/**
* Returns the first token for this entry
*
* @since 3.21
*/
default String getFirstToken() {
String[] tokens = getTokens();
if (tokens == null || tokens.length == 0) {
return null;
}
return tokens[0];
}

/**
* Returns true if the provided token exists in this entry.
* @param token the string token to look for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;
Expand Down Expand Up @@ -101,9 +102,14 @@ public static Stream<IClasspathEntry> classpathEntriesForBundle(String id) {
}
boolean isJarShape = new File(location).isFile();
IPluginLibrary[] libraries = model.getPluginBase().getLibraries();
if (isJarShape || libraries.length == 0) {
if (isJarShape) {
return Stream.of(getEntryForPath(IPath.fromOSString(location)));
}
if (libraries.length == 0) {
List<IClasspathEntry> entries = new ArrayList<>();
PDEClasspathContainer.addExternalPlugin(model, null, entries);
return entries.stream();
}
return Arrays.stream(libraries).filter(library -> !IPluginLibrary.RESOURCE.equals(library.getType()))
.map(library -> {
String name = library.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginLibrary;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.internal.core.build.ExternalBuildModel;
import org.osgi.resource.Resource;

public class PDEClasspathContainer {
Expand Down Expand Up @@ -78,7 +82,8 @@ public static IClasspathEntry[] getExternalEntries(IPluginModelBase model) {
}

protected static void addExternalPlugin(IPluginModelBase model, List<Rule> rules, List<IClasspathEntry> entries) {
boolean isJarShape = new File(model.getInstallLocation()).isFile();
File file = new File(model.getInstallLocation());
boolean isJarShape = file.isFile();
if (isJarShape) {
IPath srcPath = ClasspathUtilCore.getSourceAnnotation(model, ".", isJarShape); //$NON-NLS-1$
if (srcPath == null) {
Expand All @@ -93,14 +98,19 @@ protected static void addExternalPlugin(IPluginModelBase model, List<Rule> rules
addLibraryEntry(path, path, rules, getClasspathAttributes(model), entries);
}
} else {
IPluginLibrary[] libraries = model.getPluginBase().getLibraries();
IPluginBase pluginBase = model.getPluginBase();
IPluginLibrary[] libraries = pluginBase.getLibraries();
if (libraries.length == 0) {
// If there are no libraries, assume the root of the plug-in is the library '.'
IPath srcPath = ClasspathUtilCore.getSourceAnnotation(model, ".", isJarShape); //$NON-NLS-1$
if (srcPath == null) {
srcPath = IPath.fromOSString(model.getInstallLocation());
if (!addEntriesFromHostEclipse(model, rules, entries, file)) {
// If there are no libraries, assume the root of the plug-in
// is the library '.'
IPath srcPath = ClasspathUtilCore.getSourceAnnotation(model, ".", isJarShape); //$NON-NLS-1$
if (srcPath == null) {
srcPath = IPath.fromOSString(model.getInstallLocation());
}
addLibraryEntry(IPath.fromOSString(model.getInstallLocation()), srcPath, rules,
getClasspathAttributes(model), entries);
}
addLibraryEntry(IPath.fromOSString(model.getInstallLocation()), srcPath, rules, getClasspathAttributes(model), entries);
} else {
for (IPluginLibrary library : libraries) {
if (IPluginLibrary.RESOURCE.equals(library.getType())) {
Expand All @@ -125,6 +135,41 @@ protected static void addExternalPlugin(IPluginModelBase model, List<Rule> rules
}
}

protected static boolean addEntriesFromHostEclipse(IPluginModelBase model, List<Rule> rules,
List<IClasspathEntry> entries, File file) {
boolean hasBuildEntries = false;
// if build properties exits in folder than this is a local
// project from an Eclipse started from a workspace
if (new File(file, ICoreConstants.BUILD_FILENAME_DESCRIPTOR).isFile()) {
IBuild build = new ExternalBuildModel(model.getInstallLocation()).getBuild();
IBuildEntry[] buildEntries = build.getBuildEntries();
for (IBuildEntry entry : buildEntries) {
String name = entry.getName();
if (name.startsWith(IBuildEntry.OUTPUT_PREFIX)) {
String folder = entry.getFirstToken();
if (folder != null) {
File outputFolder = new File(file, folder);
if (outputFolder.isDirectory()) {
hasBuildEntries = true;
IBuildEntry sourceEntry = build.getEntry(IBuildEntry.JAR_PREFIX
+ name.substring(IBuildEntry.OUTPUT_PREFIX.length()));
IPath srcPath = null;
if (sourceEntry != null) {
String firstToken = sourceEntry.getFirstToken();
if (firstToken != null) {
srcPath = IPath.fromOSString(new File(file, firstToken).getAbsolutePath());
}
}
addLibraryEntry(IPath.fromOSString(outputFolder.getAbsolutePath()), srcPath, rules,
getClasspathAttributes(model), entries);
}
}
}
}
}
return hasBuildEntries;
}

protected static void addLibraryEntry(IPath path, IPath srcPath, List<Rule> rules, IClasspathAttribute[] attributes,
List<IClasspathEntry> entries) {
IClasspathEntry entry = null;
Expand Down
Loading