Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortle2008-08-20 17:40:15 -0400
committertle2008-08-20 17:40:15 -0400
commit70f5fd613d6ddf6c94b006a4ca5d3fecfe7ca66a (patch)
treedbce070a9ef64d88aa10eebe6b71ddeb9d116270
parent8b806783cdd9c081227619894a97bb22671cbd04 (diff)
downloadwebtools.dali-70f5fd613d6ddf6c94b006a4ca5d3fecfe7ca66a.tar.gz
webtools.dali-70f5fd613d6ddf6c94b006a4ca5d3fecfe7ca66a.tar.xz
webtools.dali-70f5fd613d6ddf6c94b006a4ca5d3fecfe7ca66a.zip
Refactored the method for appending a classpath entry to the project classpath
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java42
1 files changed, 18 insertions, 24 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java
index 2639d530fb..cb8512d0ce 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetInstallDelegate.java
@@ -92,22 +92,11 @@ public class JpaFacetInstallDelegate
IClasspathAttribute[] attributes = this.buildClasspathAttributes(javaProject.getProject());
IClasspathEntry jpaLibraryEntry =
JavaCore.newContainerEntry(
- new Path(JavaCore.USER_LIBRARY_CONTAINER_ID + "/" + jpaLibrary),
+ new Path(JavaCore.USER_LIBRARY_CONTAINER_ID + "/" + jpaLibrary), //$NON-NLS-1$
null, attributes, true
);
- // if the JPA library is already there, do nothing
- IClasspathEntry[] classpath = javaProject.getRawClasspath();
- if (CollectionTools.contains(classpath, jpaLibraryEntry)) {
- return;
- }
-
- // add the JPA library to the classpath
- int len = classpath.length;
- IClasspathEntry[] newClasspath = new IClasspathEntry[len + 1];
- System.arraycopy(classpath, 0, newClasspath, 0, len);
- newClasspath[len] = jpaLibraryEntry;
- javaProject.setRawClasspath(newClasspath, monitor);
+ this.addClasspathEntryToProject(jpaLibraryEntry, javaProject, monitor);
}
private void addDbDriverLibraryToClasspath(IJavaProject javaProject, IDataModel dataModel, IProgressMonitor monitor) throws CoreException {
@@ -119,27 +108,32 @@ public class JpaFacetInstallDelegate
return;
}
- // build the Driver library to be added to the classpath
- IClasspathEntry driverJarEntry =
- JavaCore.newLibraryEntry(
- new Path(driverJars), null, null, true
- );
+ String[] driverJarArray = driverJars.split(","); //$NON-NLS-1$
+ for(String driverJar : driverJarArray) {
+ IClasspathEntry driverJarEntry =
+ JavaCore.newLibraryEntry(
+ new Path(driverJar), null, null, true
+ );
+ this.addClasspathEntryToProject(driverJarEntry, javaProject, monitor);
+ }
+ }
+
+ private void addClasspathEntryToProject(IClasspathEntry classpathEntry, IJavaProject javaProject, IProgressMonitor monitor) throws CoreException {
- // if the Driver jar is already there, do nothing
+ // if the classpathEntry is already there, do nothing
IClasspathEntry[] classpath = javaProject.getRawClasspath();
- if (CollectionTools.contains(classpath, driverJarEntry)) {
+ if (CollectionTools.contains(classpath, classpathEntry)) {
return;
}
- // add the Driver jar to the classpath
+ // add the given classpathEntry to the project classpath
int len = classpath.length;
IClasspathEntry[] newClasspath = new IClasspathEntry[len + 1];
System.arraycopy(classpath, 0, newClasspath, 0, len);
- newClasspath[len] = driverJarEntry;
+ newClasspath[len] = classpathEntry;
javaProject.setRawClasspath(newClasspath, monitor);
}
-
-
+
private static final IClasspathAttribute[] EMPTY_CLASSPATH_ATTRIBUTES = new IClasspathAttribute[0];
private IClasspathAttribute[] buildClasspathAttributes(IProject project) {

Back to the top