You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2010/10/11 10:21:40 UTC
svn commit: r1021277 - in
/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse:
./ cpcontainer/
Author: hibou
Date: Mon Oct 11 08:21:40 2010
New Revision: 1021277
URL: http://svn.apache.org/viewvc?rev=1021277&view=rev
Log:
IVYDE-259 : re-enable ".classpath rewriting" in the classpath initializer, and make the IvyDERuntimeClasspathEntryResolver support containers not configured on a project
Modified:
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java?rev=1021277&r1=1021276&r2=1021277&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/IvyDERuntimeClasspathEntryResolver.java Mon Oct 11 08:21:40 2010
@@ -49,55 +49,52 @@ public class IvyDERuntimeClasspathEntryR
public IRuntimeClasspathEntry[] resolveRuntimeClasspathEntry(IRuntimeClasspathEntry entry,
ILaunchConfiguration configuration) throws CoreException {
+ if (entry == null) {
+ // cannot resolve without entry or project context
+ return new IRuntimeClasspathEntry[0];
+ }
+
+ IvyClasspathContainer ivycp;
+
IJavaProject project = entry.getJavaProject();
if (project == null) {
project = JavaRuntime.getJavaProject(configuration);
+ ivycp = new IvyClasspathContainer(FakeProjectManager.createPlaceholderProject(),
+ entry.getPath(), null, null);
+ } else {
+ IClasspathContainer container = JavaCore
+ .getClasspathContainer(entry.getPath(), project);
+ if (container == null) {
+ String message = "Could not resolve classpath container: "
+ + entry.getPath().toString();
+ throw new CoreException(new Status(IStatus.ERROR, IvyPlugin.ID,
+ IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, null));
+ // execution will not reach here - exception will be thrown
+ }
+ ivycp = (IvyClasspathContainer) container;
}
- return computeDefaultContainerEntries(entry, project);
+
+ return computeDefaultContainerEntries(ivycp, entry, project);
}
private static IRuntimeClasspathEntry[] computeDefaultContainerEntries(
- IRuntimeClasspathEntry entry, IJavaProject project) throws CoreException {
- if (project == null || entry == null) {
- // cannot resolve without entry or project context
- return new IRuntimeClasspathEntry[0];
- }
- IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project);
- if (container == null) {
- String message = "Could not resolve classpath container: " + entry.getPath().toString();
- throw new CoreException(new Status(IStatus.ERROR, IvyPlugin.ID,
- IJavaLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, null));
- // execution will not reach here - exception will be thrown
- }
- IvyClasspathContainer ivycp = (IvyClasspathContainer) container;
- if (ivycp.getConf().isInheritedResolveBeforeLaunch()) {
+ IvyClasspathContainer ivycp, IRuntimeClasspathEntry entry, IJavaProject project)
+ throws CoreException {
+ if (ivycp.getClasspathEntries() == null
+ || ivycp.getConf().isInheritedResolveBeforeLaunch()) {
IStatus status = ivycp.launchResolve(false, new NullProgressMonitor());
if (status.getCode() != IStatus.OK) {
throw new CoreException(status);
}
}
- IClasspathEntry[] cpes = container.getClasspathEntries();
- int property;
- switch (container.getKind()) {
- case IClasspathContainer.K_APPLICATION:
- property = IRuntimeClasspathEntry.USER_CLASSES;
- break;
- case IClasspathContainer.K_DEFAULT_SYSTEM:
- property = IRuntimeClasspathEntry.STANDARD_CLASSES;
- break;
- case IClasspathContainer.K_SYSTEM:
- property = IRuntimeClasspathEntry.BOOTSTRAP_CLASSES;
- break;
- default:
- property = -1;
- }
+ IClasspathEntry[] cpes = ivycp.getClasspathEntries();
List resolved = new ArrayList(cpes.length);
List projects = new ArrayList();
for (int i = 0; i < cpes.length; i++) {
IClasspathEntry cpe = cpes[i];
if (cpe.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
- IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(
- cpe.getPath().segment(0));
+ IProject p = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(cpe.getPath().segment(0));
IJavaProject jp = JavaCore.create(p);
if (!projects.contains(jp)) {
projects.add(jp);
@@ -124,7 +121,7 @@ public class IvyDERuntimeClasspathEntryR
IRuntimeClasspathEntry[] result = new IRuntimeClasspathEntry[resolved.size()];
for (int i = 0; i < result.length; i++) {
result[i] = (IRuntimeClasspathEntry) resolved.get(i);
- result[i].setClasspathProperty(property);
+ result[i].setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
}
return result;
}
@@ -134,7 +131,7 @@ public class IvyDERuntimeClasspathEntryR
if (!(entry instanceof IRuntimeClasspathEntry2)) {
return new IRuntimeClasspathEntry[] {entry};
}
-
+
IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry;
IRuntimeClasspathEntry[] entries = entry2.getRuntimeClasspathEntries(null);
List resolved = new ArrayList();
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java?rev=1021277&r1=1021276&r2=1021277&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainer.java Mon Oct 11 08:21:40 2010
@@ -140,7 +140,7 @@ public class IvyClasspathContainer imple
}
private void setClasspathEntries(final IClasspathEntry[] entries) {
- Display.getDefault().asyncExec(new Runnable() {
+ Display.getDefault().syncExec(new Runnable() {
public void run() {
if (conf.isInheritedAlphaOrder()) {
Arrays.sort(entries, new Comparator() {
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java?rev=1021277&r1=1021276&r2=1021277&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java Mon Oct 11 08:21:40 2010
@@ -64,8 +64,10 @@ public final class IvyClasspathContainer
}
conf.setAttributes(attributes);
- // ensure that the project has the Ivy nature
- IvyNature.addNature(conf.getJavaProject().getProject());
+ if (!FakeProjectManager.isFake(conf.getJavaProject())) {
+ // ensure that the project has the Ivy nature
+ IvyNature.addNature(conf.getJavaProject().getProject());
+ }
}
/**
Modified: ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java
URL: http://svn.apache.org/viewvc/ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java?rev=1021277&r1=1021276&r2=1021277&view=diff
==============================================================================
--- ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java (original)
+++ ant/ivy/ivyde/trunk/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/IvyClasspathInitializer.java Mon Oct 11 08:21:40 2010
@@ -92,16 +92,12 @@ public class IvyClasspathInitializer ext
}
}
- // FIXME : this breaks the java launcher. IvyDERuntimeClasspathEntryResolver gets an
- // unconfigured container. The culprit may be the resolver which doesn't handle properly
- // project less container.
-
// recompute the path as it may have been "upgraded"
- // IPath updatedPath = IvyClasspathContainerConfAdapter.getPath(ivycp.getConf());
- // if (!updatedPath.equals(containerPath)) {
- // updateIvyDEContainerPath(project, entry, attributes, exported, updatedPath);
- // return;
- // }
+ IPath updatedPath = IvyClasspathContainerConfAdapter.getPath(ivycp.getConf());
+ if (!updatedPath.equals(containerPath)) {
+ updateIvyDEContainerPath(project, entry, attributes, exported, updatedPath);
+ return;
+ }
JavaCore.setClasspathContainer(containerPath, new IJavaProject[] {project},
new IClasspathContainer[] {ivycp}, null);
@@ -123,8 +119,7 @@ public class IvyClasspathInitializer ext
}
private void updateIvyDEContainerPath(final IJavaProject project, final IClasspathEntry entry,
- final IClasspathAttribute[] attributes, final boolean exported,
- final IPath updatedPath) {
+ final IClasspathAttribute[] attributes, final boolean exported, final IPath updatedPath) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {