*** empty log message ***
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java
index c464097..7e82dbb 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathComputer.java
@@ -10,12 +10,18 @@
*******************************************************************************/
package org.eclipse.pde.internal.core;
-import java.util.Vector;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.zip.ZipFile;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaModelStatus;
import org.eclipse.jdt.core.IJavaProject;
@@ -23,105 +29,179 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildEntry;
+import org.eclipse.pde.core.build.IBuildModel;
import org.eclipse.pde.core.plugin.IPluginLibrary;
import org.eclipse.pde.core.plugin.IPluginModelBase;
+import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
+import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
import org.eclipse.pde.internal.core.util.CoreUtility;
public class ClasspathComputer {
+
+ public static void setClasspath(IProject project, IPluginModelBase model) throws CoreException {
+ IClasspathEntry[] entries = getClasspath(project, model, true);
+ JavaCore.create(project).setRawClasspath(entries, null);
+ }
+
+ public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase model, boolean clear) throws CoreException {
- public static void setClasspath(IPluginModelBase model,
- IProgressMonitor monitor) throws CoreException {
-
- Vector result = new Vector();
- monitor.beginTask("", 3); //$NON-NLS-1$
-
+ ArrayList result = new ArrayList();
+
// add own libraries/source
- addSourceAndLibraries(model, result);
- monitor.worked(1);
-
+ addSourceAndLibraries(project, model, clear, result);
+
+ // add pde container
result.add(ClasspathUtilCore.createContainerEntry());
- monitor.worked(1);
// add JRE
result.add(ClasspathUtilCore.createJREEntry());
- monitor.worked(1);
IClasspathEntry[] entries = (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]);
-
- IJavaProject javaProject = JavaCore.create(model.getUnderlyingResource().getProject());
- IJavaModelStatus validation = JavaConventions.validateClasspath(
- javaProject, entries, javaProject.getOutputLocation());
+ IJavaProject javaProject = JavaCore.create(project);
+ IJavaModelStatus validation =
+ JavaConventions.validateClasspath(
+ javaProject,
+ entries,
+ javaProject.getOutputLocation());
if (!validation.isOK()) {
PDECore.logErrorMessage(validation.getMessage());
throw new CoreException(validation);
}
- javaProject.setRawClasspath(entries, monitor);
- monitor.done();
+ return (IClasspathEntry[])result.toArray(new IClasspathEntry[result.size()]);
}
- private static void addSourceAndLibraries(IPluginModelBase model,
- Vector result) throws CoreException {
+ private static void addSourceAndLibraries(IProject project, IPluginModelBase model, boolean clear,
+ ArrayList result) throws CoreException {
+
+ HashSet paths = new HashSet();
- IProject project = model.getUnderlyingResource().getProject();
-
- IPluginLibrary[] libraries = model.getPluginBase().getLibraries();
- IBuild build = ClasspathUtilCore.getBuild(model);
- for (int i = 0; i < libraries.length; i++) {
- IPluginLibrary library = libraries[i];
- if (IPluginLibrary.RESOURCE.equals(library.getType()))
- continue;
- IBuildEntry buildEntry = build == null ? null : build
- .getEntry("source." + library.getName()); //$NON-NLS-1$
- if (buildEntry != null) {
- String[] folders = buildEntry.getTokens();
- for (int k = 0; k < folders.length; k++) {
- IPath path = project.getFullPath().append(folders[k]);
- if (project.findMember(folders[k]) != null) {
- IClasspathEntry entry = JavaCore.newSourceEntry(path);
- if (!result.contains(entry))
- result.add(entry);
- } else {
- addSourceFolder(folders[k], project, result);
- }
- }
- } else {
- IClasspathEntry entry = ClasspathUtilCore.createLibraryEntry(library, library
- .isExported(), false);
- if (entry != null && !result.contains(entry))
- result.add(entry);
- }
- }
-
- // keep existing source folders if they don't nest with new folders
- IClasspathEntry[] entries = JavaCore.create(project).getRawClasspath();
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
- if (!result.contains(entry)) {
- boolean doAdd = true;
- for (int j = 0; j < result.size(); j++) {
- IPath path = ((IClasspathEntry) result.get(j))
- .getPath();
- if (path.isPrefixOf(entry.getPath())
- || entry.getPath().isPrefixOf(path)) {
- doAdd = false;
- break;
- }
- }
- if (doAdd)
+ // keep existing source folders
+ if (!clear) {
+ IClasspathEntry[] entries = JavaCore.create(project).getRawClasspath();
+ for (int i = 0; i < entries.length; i++) {
+ IClasspathEntry entry = entries[i];
+ if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().segmentCount() > 1) {
+ if (paths.add(entry.getPath()))
result.add(entry);
}
}
}
+
+ IBuild build = getBuild(project);
+ IPluginLibrary[] libraries = model.getPluginBase().getLibraries();
+ for (int i = 0; i < libraries.length; i++) {
+ IBuildEntry buildEntry = build == null ? null : build.getEntry("source." + libraries[i].getName()); //$NON-NLS-1$
+ if (buildEntry != null) {
+ addSourceFolder(buildEntry, project, paths, result);
+ } else {
+ if (libraries[i].getName().equals(".")) //$NON-NLS-1$
+ addJARdPlugin(project, getFilename(model), result);
+ else
+ addLibraryEntry(project, libraries[i], libraries[i].isExported(), result);
+ }
+ }
+ if (libraries.length == 0) {
+ if (build != null) {
+ IBuildEntry buildEntry = build == null ? null : build.getEntry("source.."); //$NON-NLS-1$
+ if (buildEntry != null) {
+ addSourceFolder(buildEntry, project, paths, result);
+ }
+ } else if (isBundle(model)) {
+ addJARdPlugin(project, getFilename(model), result);
+ }
+ }
+ }
+
+ private static void addSourceFolder(IBuildEntry buildEntry, IProject project, HashSet paths, ArrayList result) throws CoreException {
+ String[] folders = buildEntry.getTokens();
+ for (int j = 0; j < folders.length; j++) {
+ String folder = folders[j];
+ IPath path = project.getFullPath().append(folder);
+ if (paths.add(path)) {
+ if (project.findMember(folder) == null)
+ CoreUtility.createFolder(project.getFolder(folder));
+ result.add(JavaCore.newSourceEntry(path));
+ }
+ }
+ }
+
+ public static String getFilename(IPluginModelBase model) {
+ StringBuffer buffer = new StringBuffer();
+ String id = model.getPluginBase().getId();
+ if (id != null)
+ buffer.append(id);
+ buffer.append("_"); //$NON-NLS-1$
+ String version = model.getPluginBase().getVersion();
+ if (version != null)
+ buffer.append(version);
+ buffer.append(".jar"); //$NON-NLS-1$
+ return buffer.toString();
}
- protected static void addSourceFolder(String name, IProject project,
- Vector result) throws CoreException {
- CoreUtility.createFolder(project.getFolder(name));
- IClasspathEntry entry = JavaCore.newSourceEntry(project.getFullPath()
- .append(name));
- if (!result.contains(entry))
- result.add(entry);
+ protected static IBuild getBuild(IProject project) throws CoreException {
+ IFile buildFile = project.getFile("build.properties"); //$NON-NLS-1$
+ IBuildModel buildModel = null;
+ if (buildFile.exists()) {
+ buildModel = new WorkspaceBuildModel(buildFile);
+ buildModel.load();
+ }
+ return (buildModel != null) ? buildModel.getBuild() : null;
}
+
+ private static void addLibraryEntry(IProject project, IPluginLibrary library, boolean exported, ArrayList result) {
+ String name = ClasspathUtilCore.expandLibraryName(library.getName());
+ IResource jarFile = project.findMember(name);
+ if (jarFile != null) {
+ IResource resource = project.findMember(getSourceZipName(name));
+ if (resource == null)
+ resource = project.findMember(new Path(getSourceZipName(name)).lastSegment());
+ IPath srcAttachment = resource != null ? resource.getFullPath() : null;
+ IClasspathEntry entry = JavaCore.newLibraryEntry(jarFile.getFullPath(), srcAttachment, null, exported);
+ if (!result.contains(entry))
+ result.add(entry);
+ }
+ }
+
+ private static void addJARdPlugin(IProject project, String filename, ArrayList result) {
+ String name = ClasspathUtilCore.expandLibraryName(filename);
+ IResource jarFile = project.findMember(name);
+ if (jarFile != null) {
+ IResource resource = project.findMember(getSourceZipName(name));
+ IPath srcAttachment = resource != null ? resource.getFullPath() : jarFile.getFullPath();
+ IClasspathEntry entry =
+ JavaCore.newLibraryEntry(jarFile.getFullPath(), srcAttachment, null, true);
+ if (!result.contains(entry))
+ result.add(entry);
+ }
+ }
+
+ public static String getSourceZipName(String libraryName) {
+ int dot = libraryName.lastIndexOf('.');
+ return (dot != -1) ? libraryName.substring(0, dot) + "src.zip" : libraryName; //$NON-NLS-1$
+ }
+
+ public static boolean isBundle(IPluginModelBase model) {
+ if (model instanceof IBundlePluginModelBase)
+ return true;
+ if (model.getUnderlyingResource() == null) {
+ File file = new File(model.getInstallLocation());
+ if (file.isDirectory())
+ return new File(file, "META-INF/MANIFEST.MF").exists(); //$NON-NLS-1$
+ ZipFile jarFile = null;
+ try {
+ jarFile = new ZipFile(file, ZipFile.OPEN_READ);
+ return jarFile.getEntry("META-INF/MANIFEST.MF") != null; //$NON-NLS-1$
+ } catch (IOException e) {
+ } finally {
+ try {
+ if (jarFile != null)
+ jarFile.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ return false;
+ }
+
}
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathUtil.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathUtil.java
deleted file mode 100644
index 0be0f49..0000000
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ClasspathUtil.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- *******************************************************************************/
-package org.eclipse.pde.internal.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.zip.ZipFile;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaModelStatus;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaConventions;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.pde.core.build.IBuild;
-import org.eclipse.pde.core.build.IBuildEntry;
-import org.eclipse.pde.core.build.IBuildModel;
-import org.eclipse.pde.core.plugin.IPluginLibrary;
-import org.eclipse.pde.core.plugin.IPluginModelBase;
-import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
-import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
-import org.eclipse.pde.internal.core.util.CoreUtility;
-
-public class ClasspathUtil {
-
- public static IClasspathEntry[] getClasspath(IProject project, IPluginModelBase model, boolean clear) throws CoreException {
-
- ArrayList result = new ArrayList();
-
- // add own libraries/source
- addSourceAndLibraries(project, model, clear, result);
-
- // add pde container
- result.add(ClasspathUtilCore.createContainerEntry());
-
- // add JRE
- result.add(ClasspathUtilCore.createJREEntry());
-
- IClasspathEntry[] entries = (IClasspathEntry[]) result.toArray(new IClasspathEntry[result.size()]);
- IJavaProject javaProject = JavaCore.create(project);
- IJavaModelStatus validation =
- JavaConventions.validateClasspath(
- javaProject,
- entries,
- javaProject.getOutputLocation());
- if (!validation.isOK()) {
- PDECore.logErrorMessage(validation.getMessage());
- throw new CoreException(validation);
- }
- return (IClasspathEntry[])result.toArray(new IClasspathEntry[result.size()]);
- }
-
- private static void addSourceAndLibraries(IProject project, IPluginModelBase model, boolean clear,
- ArrayList result) throws CoreException {
-
- HashSet paths = new HashSet();
-
- // keep existing source folders
- if (!clear) {
- IClasspathEntry[] entries = JavaCore.create(project).getRawClasspath();
- for (int i = 0; i < entries.length; i++) {
- IClasspathEntry entry = entries[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().segmentCount() > 1) {
- if (paths.add(entry.getPath()))
- result.add(entry);
- }
- }
- }
-
- IBuild build = getBuild(project);
- IPluginLibrary[] libraries = model.getPluginBase().getLibraries();
- for (int i = 0; i < libraries.length; i++) {
- IBuildEntry buildEntry = build == null ? null : build.getEntry("source." + libraries[i].getName()); //$NON-NLS-1$
- if (buildEntry != null) {
- String[] folders = buildEntry.getTokens();
- for (int j = 0; j < folders.length; j++) {
- String folder = folders[j];
- IPath path = project.getFullPath().append(folder);
- if (paths.add(path)) {
- if (project.findMember(folder) == null)
- CoreUtility.createFolder(project.getFolder(folder));
- result.add(JavaCore.newSourceEntry(path));
- }
- }
- } else {
- if (libraries[i].getName().equals(".")) //$NON-NLS-1$
- addJARdPlugin(project, getFilename(model), result);
- else
- addLibraryEntry(project, libraries[i], libraries[i].isExported(), result);
- }
- }
- if (libraries.length == 0 && isBundle(model))
- addJARdPlugin(project, getFilename(model), result);
- }
-
- public static String getFilename(IPluginModelBase model) {
- StringBuffer buffer = new StringBuffer();
- String id = model.getPluginBase().getId();
- if (id != null)
- buffer.append(id);
- buffer.append("_"); //$NON-NLS-1$
- String version = model.getPluginBase().getVersion();
- if (version != null)
- buffer.append(version);
- buffer.append(".jar"); //$NON-NLS-1$
- return buffer.toString();
- }
-
- protected static IBuild getBuild(IProject project) throws CoreException {
- IFile buildFile = project.getFile("build.properties"); //$NON-NLS-1$
- IBuildModel buildModel = null;
- if (buildFile.exists()) {
- buildModel = new WorkspaceBuildModel(buildFile);
- buildModel.load();
- }
- return (buildModel != null) ? buildModel.getBuild() : null;
- }
-
- private static void addLibraryEntry(IProject project, IPluginLibrary library, boolean exported, ArrayList result) {
- String name = ClasspathUtilCore.expandLibraryName(library.getName());
- IResource jarFile = project.findMember(name);
- if (jarFile != null) {
- IResource resource = project.findMember(getSourceZipName(name));
- if (resource == null)
- resource = project.findMember(new Path(getSourceZipName(name)).lastSegment());
- IPath srcAttachment = resource != null ? resource.getFullPath() : null;
- IClasspathEntry entry = JavaCore.newLibraryEntry(jarFile.getFullPath(), srcAttachment, null, exported);
- if (!result.contains(entry))
- result.add(entry);
- }
- }
-
- private static void addJARdPlugin(IProject project, String filename, ArrayList result) {
- String name = ClasspathUtilCore.expandLibraryName(filename);
- IResource jarFile = project.findMember(name);
- if (jarFile != null) {
- IResource resource = project.findMember(getSourceZipName(name));
- IPath srcAttachment = resource != null ? resource.getFullPath() : jarFile.getFullPath();
- IClasspathEntry entry =
- JavaCore.newLibraryEntry(jarFile.getFullPath(), srcAttachment, null, true);
- if (!result.contains(entry))
- result.add(entry);
- }
- }
-
- public static String getSourceZipName(String libraryName) {
- int dot = libraryName.lastIndexOf('.');
- return (dot != -1) ? libraryName.substring(0, dot) + "src.zip" : libraryName; //$NON-NLS-1$
- }
-
- public static boolean isBundle(IPluginModelBase model) {
- if (model instanceof IBundlePluginModelBase)
- return true;
- if (model.getUnderlyingResource() == null) {
- File file = new File(model.getInstallLocation());
- if (file.isDirectory())
- return new File(file, "META-INF/MANIFEST.MF").exists(); //$NON-NLS-1$
- ZipFile jarFile = null;
- try {
- jarFile = new ZipFile(file, ZipFile.OPEN_READ);
- return jarFile.getEntry("META-INF/MANIFEST.MF") != null; //$NON-NLS-1$
- } catch (IOException e) {
- } finally {
- try {
- if (jarFile != null)
- jarFile.close();
- } catch (IOException e) {
- }
- }
- }
- return false;
- }
-
-
-}
diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPluginConverter.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPluginConverter.java
index 84ace97..e75d10f 100644
--- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPluginConverter.java
+++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPluginConverter.java
@@ -57,7 +57,7 @@
String classpath = prop.getProperty(Constants.BUNDLE_CLASSPATH);
if (classpath == null) {
prop.put(Constants.BUNDLE_CLASSPATH,
- ClasspathUtil.getFilename(model));
+ ClasspathComputer.getFilename(model));
} else {
ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, classpath);
StringBuffer buffer = new StringBuffer();
@@ -67,7 +67,7 @@
buffer.append(", "); //$NON-NLS-1$
}
if (elements[i].getValue().equals(".")) //$NON-NLS-1$
- buffer.append(ClasspathUtil.getFilename(model));
+ buffer.append(ClasspathComputer.getFilename(model));
else
buffer.append(elements[i].getValue());
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/JarImportOperation.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/JarImportOperation.java
index df7a554..746ea85 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/JarImportOperation.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/JarImportOperation.java
@@ -256,4 +256,21 @@
return false;
}
+ protected boolean containsCode(File file) {
+ ZipFile zipFile = null;
+ try {
+ zipFile = new ZipFile(file);
+ return containsCode(new ZipFileStructureProvider(zipFile));
+ } catch (IOException e) {
+ } finally {
+ if (zipFile != null) {
+ try {
+ zipFile.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ return true;
+ }
+
}
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java
index 9a5e6f9..08e1a70 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/imports/PluginImportOperation.java
@@ -22,7 +22,6 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -43,12 +42,13 @@
import org.eclipse.osgi.service.resolver.BundleSpecification;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.core.build.IBuild;
+import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.plugin.IFragment;
import org.eclipse.pde.core.plugin.IFragmentModel;
import org.eclipse.pde.core.plugin.IPluginLibrary;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.PDE;
-import org.eclipse.pde.internal.core.ClasspathUtil;
+import org.eclipse.pde.internal.core.ClasspathComputer;
import org.eclipse.pde.internal.core.ClasspathUtilCore;
import org.eclipse.pde.internal.core.ModelEntry;
import org.eclipse.pde.internal.core.PDECore;
@@ -76,8 +76,6 @@
private IReplaceQuery fReplaceQuery;
- private boolean fTurnAutobuild;
-
private Hashtable fProjectClasspaths = new Hashtable();
public interface IReplaceQuery {
@@ -96,11 +94,6 @@
fReplaceQuery = replaceQuery;
}
- public PluginImportOperation(IPluginModelBase[] models, int importType, boolean turnAutoBuild, IReplaceQuery replaceQuery) {
- this(models, importType, replaceQuery);
- fTurnAutobuild = turnAutoBuild;
- }
-
/*
* @see IWorkspaceRunnable#run(IProgressMonitor)
*/
@@ -110,10 +103,9 @@
monitor = new NullProgressMonitor();
}
monitor.beginTask(PDEUIMessages.ImportWizard_operation_creating, fModels.length + 1);
- boolean isAutobuilding = PDEPlugin.getWorkspace().isAutoBuilding();
try {
- if (isAutobuilding)
- toggleAutobuild(false);
+ //if (isAutobuilding)
+ //toggleAutobuild(false);
MultiStatus multiStatus = new MultiStatus(PDEPlugin.getPluginId(),
IStatus.OK,
@@ -140,18 +132,18 @@
} catch (OperationCanceledException e) {
} catch (InterruptedException e) {
}
- if (isAutobuilding || fTurnAutobuild)
- toggleAutobuild(true);
+ //if (isAutobuilding || fTurnAutobuild)
+ //toggleAutobuild(true);
monitor.done();
}
}
- private void toggleAutobuild(boolean on) throws CoreException {
+ /*private void toggleAutobuild(boolean on) throws CoreException {
IWorkspaceDescription desc = PDEPlugin.getWorkspace().getDescription();
desc.setAutoBuilding(on);
PDEPlugin.getWorkspace().setDescription(desc);
- }
+ }*/
private void setClasspaths(IProgressMonitor monitor) throws JavaModelException {
monitor.beginTask("Setting classpath...", fProjectClasspaths.size());
@@ -202,7 +194,7 @@
setProjectDescription(project, model);
if (project.hasNature(JavaCore.NATURE_ID) && project.findMember(".classpath") == null) //$NON-NLS-1$
- fProjectClasspaths .put(project, ClasspathUtil.getClasspath(project, model, true));
+ fProjectClasspaths .put(project, ClasspathComputer.getClasspath(project, model, true));
} catch (CoreException e) {
} finally {
monitor.done();
@@ -276,42 +268,50 @@
importAsBinary(project, model, false, new SubProgressMonitor(monitor, 2));
WorkspaceBuildModel buildModel = new WorkspaceBuildModel(project.getFile("build.properties"));
- IBuild build = buildModel.getBuild(true);
-
- String[] libraries = getLibraryNames(model, false);
- for (int i = 0; i < libraries.length; i++) {
- if (ClasspathUtilCore.containsVariables(libraries[i]))
- continue;
- String name = libraries[i];
- if (name.equals(".") && isJARd(model)) {
- if (project.getFolder("src").exists()) {
- if (build.getEntry("source..") == null)
+ if (!isJARd(model) || containsCode(new File(model.getInstallLocation()))) {
+ String[] libraries = getLibraryNames(model, false);
+ for (int i = 0; i < libraries.length; i++) {
+ if (ClasspathUtilCore.containsVariables(libraries[i]))
continue;
- }
- name = new File(model.getInstallLocation()).getName();
- }
- name = ClasspathUtilCore.expandLibraryName(name);
- IPath libraryPath = new Path(name);
- IResource jarFile = project.findMember(libraryPath);
- if (jarFile != null) {
- IResource srcZip = jarFile.getProject().findMember(ClasspathUtilCore.getSourceZipName(name));
- if (srcZip != null) {
- String jarName = libraries[i].equals(".") ? "" : libraryPath.removeFileExtension().lastSegment();
- IFolder dest = jarFile.getProject().getFolder("src" + (jarName.length() == 0 ? "" : "-" + jarName)); //$NON-NLS-1$
- if (!dest.exists()) {
- dest.create(true, true, null);
+ String name = ClasspathUtilCore.expandLibraryName(libraries[i]);
+ IPath libraryPath = (name.equals(".") && isJARd(model))
+ ? new Path(new File(model.getInstallLocation()).getName())
+ : new Path(name);
+ IResource jarFile = project.findMember(libraryPath);
+ if (jarFile != null) {
+ IResource srcZip = jarFile.getProject().findMember(ClasspathUtilCore.getSourceZipName(jarFile.getName()));
+ if (srcZip != null) {
+ String jarName = libraries[i].equals(".") ? "" : libraryPath.removeFileExtension().lastSegment();
+ String folder = addBuildEntry(buildModel, "source." + libraries[i], "src" + (jarName.length() == 0 ? "/" : "-" + jarName + "/"));
+ IFolder dest = jarFile.getProject().getFolder(folder); //$NON-NLS-1$
+ if (!dest.exists()) {
+ dest.create(true, true, null);
+ }
+ extractZipFile(srcZip.getLocation().toFile(), dest.getFullPath(), monitor);
+ if (isJARd(model)) {
+ extractJavaResources(jarFile.getLocation().toFile(), dest, monitor);
+ } else {
+ extractResources(jarFile.getLocation().toFile(), dest, monitor);
+ }
+ srcZip.delete(true, null);
+ jarFile.delete(true, null);
}
- extractZipFile(srcZip.getLocation().toFile(), dest.getFullPath(), monitor);
- if (isJARd(model)) {
- extractJavaResources(jarFile.getLocation().toFile(), dest, monitor);
- } else {
- extractResources(jarFile.getLocation().toFile(), dest, monitor);
- }
- srcZip.delete(true, null);
- jarFile.delete(true, null);
}
- }
- }
+ }
+ }
+ buildModel.save();
+ }
+
+ private String addBuildEntry(WorkspaceBuildModel model, String key, String value) throws CoreException {
+ IBuild build = model.getBuild(true);
+ IBuildEntry entry = build.getEntry(key);
+ if (entry == null) {
+ entry = model.getFactory().createEntry(key);
+ entry.addToken(value);
+ build.add(entry);
+ }
+ String[] tokens = entry.getTokens();
+ return (tokens.length > 0) ? tokens[0] : "src/";
}
private void linkSourceArchives(IProject project, IPluginModelBase model,
@@ -499,7 +499,8 @@
String id = model.getPluginBase().getId();
if ("org.apache.ant".equals(id)
|| "org.eclipse.osgi.util".equals(id)
- || "org.eclipse.osgi.services".equals(id))
+ || "org.eclipse.osgi.services".equals(id)
+ || "org.eclipse.team.cvs.ssh2".equals(id))
return true;
if ("org.eclipse.swt".equals(id) && !isJARd(model))
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/ConvertedProjectsPage.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/ConvertedProjectsPage.java
index 1c58d47..c390030 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/ConvertedProjectsPage.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/ConvertedProjectsPage.java
@@ -181,7 +181,7 @@
if (!model.isLoaded())
return;
- ClasspathComputer.setClasspath(model, monitor); // error occurs here on initial
+ ClasspathComputer.setClasspath(project, model);
}
public static void convertProject(
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/UpdateClasspathJob.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/UpdateClasspathJob.java
index 0c3f6f9..9653804 100644
--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/UpdateClasspathJob.java
+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/UpdateClasspathJob.java
@@ -16,7 +16,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.pde.core.plugin.IPluginModelBase;
@@ -53,8 +52,8 @@
monitor.worked(1);
continue;
}
- ClasspathComputer.setClasspath(model, new SubProgressMonitor(
- monitor, 1));
+ ClasspathComputer.setClasspath(project, model);
+ monitor.worked(1);
if (monitor.isCanceled())
return false;
}