List of usage examples for org.eclipse.jdt.core JavaCore newLibraryEntry
public static IClasspathEntry newLibraryEntry(IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, boolean isExported)
CPE_LIBRARY
for the JAR or folder identified by the given absolute path. From source file:ch.mlutz.plugins.t4e.container.T4eClasspathContainerInitializer.java
License:Open Source License
public void initialize(IPath containerPath, final IJavaProject project) { if (isT4eClasspathContainer(containerPath)) { IClasspathContainer container;/*from w ww . ja v a 2 s .c o m*/ final Activator plugin = Activator.getDefault(); try { container = JavaCore.getClasspathContainer(containerPath, project); } catch (JavaModelException e) { log.error("Unable to get container for " + containerPath.toString(), e); return; } // plugin.getMavenModelManager().initModels(new NullProgressMonitor()); T4eClasspathContainer t4eContainer; if (container == null) { // parse the pom.xml IProject resourceProject = project.getProject(); PomParser pomParser = new PomParser(); IFile pomFile = resourceProject.getFile("pom.xml"); List<Dependency> dependencies; if (pomFile.exists()) { try { pomParser.parse(pomFile.getContents()); } catch (UnsupportedEncodingException e) { log.warn("Unsupported encoding in pom.xml: " + e); } catch (CoreException e) { log.warn("CoreException when getting contents of pom.xml: " + e); } dependencies = pomParser.getDependencyManagement(); log.info("DependencyManagement dependencies count: " + String.valueOf(dependencies.size())); dependencies = pomParser.getDependencies(); log.info("Dependencies count: " + String.valueOf(dependencies.size())); } else { log.warn("pom.xml doesn't seem to exist."); } // add dependency management entries to T4eClasspathContainer7 List<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>(); String mavenRepositoryBasePath = MavenTools.getMavenLocalRepoPath().replaceAll("\\\\", "/"); dependencies = pomParser.getDependencyManagement(); for (Dependency dependency : dependencies) { Path path = new Path( mavenRepositoryBasePath + "/" + dependency.getGroupId().replaceAll("\\.", "/") + "/" + dependency.getArtifactId() + "/" + dependency.getVersion() + "/" + dependency.getArtifactId() + "-" + dependency.getVersion() + ".jar"); entryList.add(JavaCore.newLibraryEntry(path, null, null, true)); } t4eContainer = new T4eClasspathContainer(new Path(Constants.CONTAINER_ID), (IClasspathEntry[]) entryList.toArray(new IClasspathEntry[0])); } else { t4eContainer = new T4eClasspathContainer(containerPath, container.getClasspathEntries()); } try { JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { t4eContainer }, new NullProgressMonitor()); } catch (JavaModelException e) { log.warn("Unable to set container for " + containerPath.toString(), e); return; } if (container != null) { return; } /* plugin.getBuildpathManager().scheduleUpdateClasspathContainer(project.getProject()); */ } }
From source file:com.android.ide.eclipse.adt.internal.project.LibraryClasspathContainerInitializer.java
License:Open Source License
private static IClasspathContainer allocateDependencyContainer(IJavaProject javaProject) { final IProject iProject = javaProject.getProject(); final List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); final Set<File> jarFiles = new HashSet<File>(); final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); AdtPlugin plugin = AdtPlugin.getDefault(); if (plugin == null) { // This is totally weird, but I've seen it happen! return null; }// www .j a v a2 s . co m synchronized (Sdk.getLock()) { boolean sdkIsLoaded = plugin.getSdkLoadStatus() == LoadStatus.LOADED; // check if the project has a valid target. final ProjectState state = Sdk.getProjectState(iProject); if (state == null) { // getProjectState should already have logged an error. Just bail out. return null; } // annotations support for older version of android if (state.getTarget() != null && state.getTarget().getVersion().getApiLevel() <= 15) { File annotationsJar = new File(Sdk.getCurrent().getSdkOsLocation(), SdkConstants.FD_TOOLS + File.separator + SdkConstants.FD_SUPPORT + File.separator + SdkConstants.FN_ANNOTATIONS_JAR); jarFiles.add(annotationsJar); } if (state.getRenderScriptSupportMode()) { if (!sdkIsLoaded) { return null; } BuildToolInfo buildToolInfo = state.getBuildToolInfo(); if (buildToolInfo == null) { buildToolInfo = Sdk.getCurrent().getLatestBuildTool(); if (buildToolInfo == null) { return null; } } File renderScriptSupportJar = RenderScriptProcessor .getSupportJar(buildToolInfo.getLocation().getAbsolutePath()); jarFiles.add(renderScriptSupportJar); } // process all the libraries List<IProject> libProjects = state.getFullLibraryProjects(); for (IProject libProject : libProjects) { // get the project output IFolder outputFolder = BaseProjectHelper.getAndroidOutputFolder(libProject); if (outputFolder != null) { // can happen when closing/deleting a library) IFile jarIFile = outputFolder .getFile(libProject.getName().toLowerCase() + SdkConstants.DOT_JAR); // get the source folder for the library project List<IPath> srcs = BaseProjectHelper.getSourceClasspaths(libProject); // find the first non-derived source folder. IPath sourceFolder = null; for (IPath src : srcs) { IFolder srcFolder = workspaceRoot.getFolder(src); if (srcFolder.isDerived() == false) { sourceFolder = src; break; } } // we can directly add a CPE for this jar as there's no risk of a duplicate. IClasspathEntry entry = JavaCore.newLibraryEntry(jarIFile.getLocation(), sourceFolder, // source attachment path null, // default source attachment root path. true /*isExported*/); entries.add(entry); } } entries.addAll(convertJarsToClasspathEntries(iProject, jarFiles)); return allocateContainer(javaProject, entries, new Path(CONTAINER_DEPENDENCIES), "Android Dependencies"); } }
From source file:com.android.ide.eclipse.auidt.internal.project.LibraryClasspathContainerInitializer.java
License:Open Source License
private static IClasspathContainer allocateLibraryContainer(IJavaProject javaProject) { final IProject iProject = javaProject.getProject(); AdtPlugin plugin = AdtPlugin.getDefault(); if (plugin == null) { // This is totally weird, but I've seen it happen! return null; }//ww w . j a va 2 s . c om // First check that the project has a library-type container. try { IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); IClasspathEntry[] oldRawClasspath = rawClasspath; boolean foundLibrariesContainer = false; for (IClasspathEntry entry : rawClasspath) { // get the entry and kind int kind = entry.getEntryKind(); if (kind == IClasspathEntry.CPE_CONTAINER) { String path = entry.getPath().toString(); if (AdtConstants.CONTAINER_LIBRARIES.equals(path)) { foundLibrariesContainer = true; break; } } } // if there isn't any, add it. if (foundLibrariesContainer == false) { // add the android container to the array rawClasspath = ProjectHelper.addEntryToClasspath(rawClasspath, JavaCore .newContainerEntry(new Path(AdtConstants.CONTAINER_LIBRARIES), true /*isExported*/)); } // set the new list of entries to the project if (rawClasspath != oldRawClasspath) { javaProject.setRawClasspath(rawClasspath, new NullProgressMonitor()); } } catch (JavaModelException e) { // This really shouldn't happen, but if it does, simply return null (the calling // method will fails as well) return null; } // check if the project has a valid target. ProjectState state = Sdk.getProjectState(iProject); if (state == null) { // getProjectState should already have logged an error. Just bail out. return null; } /* * At this point we're going to gather a list of all that need to go in the * dependency container. * - Library project outputs (direct and indirect) * - Java project output (those can be indirectly referenced through library projects * or other other Java projects) * - Jar files: * + inside this project's libs/ * + inside the library projects' libs/ * + inside the referenced Java projects' classpath */ List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); // list of java project dependencies and jar files that will be built while // going through the library projects. Set<File> jarFiles = new HashSet<File>(); Set<IProject> refProjects = new HashSet<IProject>(); // process all the libraries List<IProject> libProjects = state.getFullLibraryProjects(); for (IProject libProject : libProjects) { // get the project output IFolder outputFolder = BaseProjectHelper.getAndroidOutputFolder(libProject); if (outputFolder != null) { // can happen when closing/deleting a library) IFile jarIFile = outputFolder.getFile(libProject.getName().toLowerCase() + AdtConstants.DOT_JAR); // get the source folder for the library project List<IPath> srcs = BaseProjectHelper.getSourceClasspaths(libProject); // find the first non-derived source folder. IPath sourceFolder = null; for (IPath src : srcs) { IFolder srcFolder = workspaceRoot.getFolder(src); if (srcFolder.isDerived() == false) { sourceFolder = src; break; } } // we can directly add a CPE for this jar as there's no risk of a duplicate. IClasspathEntry entry = JavaCore.newLibraryEntry(jarIFile.getLocation(), sourceFolder, // source attachment path null, // default source attachment root path. true /*isExported*/); entries.add(entry); // process all of the library project's dependencies getDependencyListFromClasspath(libProject, refProjects, jarFiles, true); // and the content of its libs folder. getJarListFromLibsFolder(libProject, jarFiles); } } // now process this projects' referenced projects only. processReferencedProjects(iProject, refProjects, jarFiles); // and the content of its libs folder getJarListFromLibsFolder(iProject, jarFiles); // annotations support for older version of android if (state.getTarget() != null && state.getTarget().getVersion().getApiLevel() <= 15) { File annotationsJar = new File(Sdk.getCurrent().getSdkLocation(), SdkConstants.FD_TOOLS + File.separator + SdkConstants.FD_SUPPORT + File.separator + SdkConstants.FN_ANNOTATIONS_JAR); jarFiles.add(annotationsJar); } // now add a classpath entry for each Java project (this is a set so dups are already // removed) for (IProject p : refProjects) { entries.add(JavaCore.newProjectEntry(p.getFullPath(), true /*isExported*/)); } // and process the jar files list, but first sanitize it to remove dups. JarListSanitizer sanitizer = new JarListSanitizer( iProject.getFolder(SdkConstants.FD_OUTPUT).getLocation().toFile(), new AndroidPrintStream(iProject, null /*prefix*/, AdtPlugin.getOutStream())); String errorMessage = null; try { List<File> sanitizedList = sanitizer.sanitize(jarFiles); for (File jarFile : sanitizedList) { if (jarFile instanceof CPEFile) { CPEFile cpeFile = (CPEFile) jarFile; IClasspathEntry e = cpeFile.getClasspathEntry(); entries.add(JavaCore.newLibraryEntry(e.getPath(), e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(), e.getAccessRules(), e.getExtraAttributes(), true /*isExported*/)); } else { String jarPath = jarFile.getAbsolutePath(); IPath sourceAttachmentPath = null; IClasspathAttribute javaDocAttribute = null; File jarProperties = new File(jarPath + DOT_PROPERTIES); if (jarProperties.isFile()) { Properties p = new Properties(); InputStream is = null; try { p.load(is = new FileInputStream(jarProperties)); String value = p.getProperty(ATTR_SRC); if (value != null) { File srcPath = getFile(jarFile, value); if (srcPath.exists()) { sourceAttachmentPath = new Path(srcPath.getAbsolutePath()); } } value = p.getProperty(ATTR_DOC); if (value != null) { File docPath = getFile(jarFile, value); if (docPath.exists()) { try { javaDocAttribute = JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, docPath.toURI().toURL().toString()); } catch (MalformedURLException e) { AdtPlugin.log(e, "Failed to process 'doc' attribute for %s", jarProperties.getAbsolutePath()); } } } } catch (FileNotFoundException e) { // shouldn't happen since we check upfront } catch (IOException e) { AdtPlugin.log(e, "Failed to read %s", jarProperties.getAbsolutePath()); } finally { if (is != null) { try { is.close(); } catch (IOException e) { // ignore } } } } if (javaDocAttribute != null) { entries.add(JavaCore.newLibraryEntry(new Path(jarPath), sourceAttachmentPath, null /*sourceAttachmentRootPath*/, new IAccessRule[0], new IClasspathAttribute[] { javaDocAttribute }, true /*isExported*/)); } else { entries.add(JavaCore.newLibraryEntry(new Path(jarPath), sourceAttachmentPath, null /*sourceAttachmentRootPath*/, true /*isExported*/)); } } } } catch (DifferentLibException e) { errorMessage = e.getMessage(); AdtPlugin.printErrorToConsole(iProject, (Object[]) e.getDetails()); } catch (Sha1Exception e) { errorMessage = e.getMessage(); } processError(iProject, errorMessage, AdtConstants.MARKER_DEPENDENCY, true /*outputToConsole*/); return new AndroidClasspathContainer(entries.toArray(new IClasspathEntry[entries.size()]), new Path(AdtConstants.CONTAINER_LIBRARIES), "Android Dependencies", IClasspathContainer.K_APPLICATION); }
From source file:com.google.gwt.eclipse.core.compile.GWTCompileRunnerTest.java
License:Open Source License
/** * Create a library entry and add it to the raw classpath. *//* w w w . j av a 2s .co m*/ private static void addAndCreateFolderLibraryEntry(IJavaProject javaProject, String folderName) throws CoreException, UnsupportedEncodingException { IFolder projLibFolder = javaProject.getProject().getFolder(folderName); ResourceUtils.createFolderStructure(javaProject.getProject(), projLibFolder.getProjectRelativePath()); JavaProjectUtilities.addRawClassPathEntry(javaProject, JavaCore.newLibraryEntry(projLibFolder.getFullPath(), null, null, true /* exported */)); }
From source file:com.google.gwt.eclipse.core.compile.GWTCompileRunnerTest.java
License:Open Source License
/** * Create a JAR library entry and add it to the raw classpath. * <p>/*from w w w . ja va2s .c o m*/ * This ensures a file exist at the target library path, but no guarantees on * its contents or its validity as a JAR. */ private static void addAndCreateJarLibraryEntry(IJavaProject javaProject, IPath projectRelativeLibraryPath) throws CoreException, UnsupportedEncodingException { IFile lib = javaProject.getProject().getFile(projectRelativeLibraryPath); // Create the parent dirs and a dummy file for the library ResourceUtils.createFolderStructure(javaProject.getProject(), projectRelativeLibraryPath.removeLastSegments(1)); ResourceUtils.createFile(lib.getFullPath(), ""); JavaProjectUtilities.addRawClassPathEntry(javaProject, JavaCore.newLibraryEntry(lib.getFullPath(), null, null, true /* exported */)); }
From source file:com.ibm.xsp.extlib.designer.relational.utils.ProjectUtils.java
License:Open Source License
public static IProject createPluginProject(final ProjectDef projectDef) throws Exception { IProject project = null;//w w w.j a v a 2 s . co m try { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); project = root.getProject(projectDef.name + "_" + projectDef.version); if (project.exists()) { project.delete(true, true, null); } project.create(null); project.open(null); IProjectDescription description = project.getDescription(); description.setNatureIds(new String[] { "org.eclipse.pde.PluginNature", JavaCore.NATURE_ID }); // $NON-NLS-1$ project.setDescription(description, null); IJavaProject javaProject = JavaCore.create(project); // Contruct the classpath List<IClasspathEntry> classpathList = new ArrayList<IClasspathEntry>(); // Source folders for (String folderName : projectDef.srcFolders) { IFolder folder = project.getFolder(folderName); // Create the src folders in the project if (!folder.exists()) { folder.create(false, true, null); } IClasspathEntry srcClasspathEntry = JavaCore.newSourceEntry(folder.getFullPath()); classpathList.add(srcClasspathEntry); } // Add Lib Classpaths if (!StringUtil.isEmpty(projectDef.libFolder)) { IFolder folder = project.getFolder(projectDef.libFolder); // Create the lib folder in the project if (!folder.exists()) { folder.create(true, true, null); } for (String lib : projectDef.libs) { IClasspathEntry srcClasspathEntry = JavaCore.newLibraryEntry( new Path(folder.getFullPath() + "/" + new File(lib).getName()), null, null, true); classpathList.add(srcClasspathEntry); } } classpathList.add(JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER"))); // $NON-NLS-1$ classpathList.add(JavaCore.newContainerEntry(new Path("org.eclipse.pde.core.requiredPlugins"))); // $NON-NLS-1$ // Set the project classpath javaProject.setRawClasspath(classpathList.toArray(new IClasspathEntry[classpathList.size()]), null); } catch (Exception e) { if (project != null) { closeAndDeleteProject(project, true); } throw new Exception("Error creating temporary Plug-in project in the Workspace", e); // $NLX-ProjectUtils.ErrorcreatingtemporaryPluginproje-1$ } return project; }
From source file:com.iw.plugins.spindle.core.classpath.CoreClasspathContainer.java
License:Mozilla Public License
/** * Computes the Tapestry framework classpath entries associated with the core plugin bundle. * /* w ww . jav a 2s . c o m*/ * @param bundle * the Bundle associated with the plugin object. * @return an array of classpath entries. */ private static IClasspathEntry[] computeClasspathEntries(Bundle bundle) { List entries = new ArrayList(); URL installUrl = bundle.getEntry("/"); try { ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_CLASSPATH, (String) bundle.getHeaders().get(Constants.BUNDLE_CLASSPATH)); for (int i = 0; i < elements.length; i++) { String jarName = elements[i].getValue(); if (jarName.equals("core.jar")) continue; if (jarName.endsWith("javax.servlet.jar")) continue; if (jarName.equals("dtdparser.jar")) continue; if (jarName.indexOf("commons-lang") > 0) continue; IPath tempPath = new Path(jarName); String trueJarName = tempPath.lastSegment(); try { IPath sourceAttachmentPath = null; IPath sourceAttachmentRootPath = null; if (trueJarName.startsWith("tapestry-3")) { sourceAttachmentPath = getSourceAttachmentPath(installUrl, "tapestry-src.jar"); } else if (trueJarName.startsWith("tapestry-contrib")) { sourceAttachmentPath = getSourceAttachmentPath(installUrl, "tapestry-contrib-src.jar"); } else { int index = trueJarName.lastIndexOf('-'); String attachment = trueJarName.substring(0, index) + "-src.jar"; sourceAttachmentPath = getSourceAttachmentPath(installUrl, attachment); } if (sourceAttachmentPath != null) sourceAttachmentRootPath = new Path("/"); URL libUrl = new URL(installUrl, jarName); libUrl = Platform.resolve(libUrl); entries.add(JavaCore.newLibraryEntry(new Path(libUrl.getFile()), sourceAttachmentPath, sourceAttachmentRootPath, false)); } catch (MalformedURLException e) { TapestryCore.log(e); } catch (IOException e) { TapestryCore.log(e); } } //FIXING Bug [ 1144151 ] Spindle 3.1.16 using commons-lang-cvs-HEAD.jar?? try { URL commonsLang = new URL(installUrl, "lib/ext/commons-lang-1.0.jar"); commonsLang = Platform.resolve(commonsLang); entries.add(JavaCore.newLibraryEntry(new Path(commonsLang.getFile()), null, null, false)); } catch (MalformedURLException e1) { TapestryCore.log(e1); } catch (IOException e1) { TapestryCore.log(e1); } } catch (BundleException e) { // TODO Auto-generated catch block e.printStackTrace(); } return (IClasspathEntry[]) entries.toArray(new IClasspathEntry[entries.size()]); }
From source file:com.jaspersoft.studio.wizards.dataadapter.PluginHelper.java
License:Open Source License
/** * Create a plugin project in the workspace. Project will contains * the folder libs and images included also into the build file, to * allow to easily add images and libraries * //from w w w . j a v a 2s .co m * @param adapterInfo the information of the plugin * @param srcFolders the source folders of the project * @param requiredBundles the bundles required by the project * @param requiredLibs the jar libraries required by the project * @param progressMonitor a progress monitor * @return the generated project */ public static IProject createPluginProject(AdapterInfo adapterInfo, List<String> srcFolders, List<String> requiredBundles, List<File> requiredLibs, IProgressMonitor progressMonitor) { IProject project = null; try { final IWorkspace workspace = ResourcesPlugin.getWorkspace(); project = workspace.getRoot().getProject(adapterInfo.getProjectName()); final IJavaProject javaProject = JavaCore.create(project); final IProjectDescription projectDescription = ResourcesPlugin.getWorkspace() .newProjectDescription(adapterInfo.getProjectName()); projectDescription.setLocation(null); project.create(projectDescription, progressMonitor); final List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>(); projectDescription.setNatureIds(new String[] { JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature" }); final ICommand java = projectDescription.newCommand(); java.setBuilderName(JavaCore.BUILDER_ID); final ICommand manifest = projectDescription.newCommand(); manifest.setBuilderName("org.eclipse.pde.ManifestBuilder"); final ICommand schema = projectDescription.newCommand(); schema.setBuilderName("org.eclipse.pde.SchemaBuilder"); final ICommand oaw = projectDescription.newCommand(); projectDescription.setBuildSpec(new ICommand[] { java, manifest, schema, oaw }); project.open(progressMonitor); project.setDescription(projectDescription, progressMonitor); Collections.reverse(srcFolders); for (final String src : srcFolders) { final IFolder srcContainer = project.getFolder(src); if (!srcContainer.exists()) { srcContainer.create(false, true, progressMonitor); } final IClasspathEntry srcClasspathEntry = JavaCore.newSourceEntry(srcContainer.getFullPath()); classpathEntries.add(0, srcClasspathEntry); } //Add the jar libraries to the project IFolder libsFolder = project.getFolder("libs"); libsFolder.create(false, true, progressMonitor); List<IFile> externalLibs = new ArrayList<IFile>(); for (File libFile : requiredLibs) { if (libFile != null && libFile.exists()) { InputStream resourceAsStream = new FileInputStream(libFile); PluginHelper.createFile(libFile.getName(), libsFolder, resourceAsStream, progressMonitor); IFile file = libsFolder.getFile(libFile.getName()); IPath path = file.getFullPath(); classpathEntries.add(JavaCore.newLibraryEntry(path, path, null, true)); externalLibs.add(file); } } classpathEntries.add(JavaCore.newContainerEntry(new Path( "org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"))); classpathEntries.add(JavaCore.newContainerEntry(new Path("org.eclipse.pde.core.requiredPlugins"))); javaProject.setRawClasspath(classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]), progressMonitor); javaProject.setOutputLocation(new Path("/" + adapterInfo.getProjectName() + "/bin"), progressMonitor); ProjectUtil.createJRClasspathContainer(progressMonitor, javaProject); IFolder imagesFolder = project.getFolder("images"); imagesFolder.create(false, true, progressMonitor); createManifest(adapterInfo, requiredBundles, externalLibs, progressMonitor, project); createBuildProps(progressMonitor, project, srcFolders); } catch (final Exception exception) { exception.printStackTrace(); JaspersoftStudioPlugin.getInstance().logError(exception); } return project; }
From source file:com.legstar.eclipse.plugin.common.AbstractClasspathInitializer.java
License:Open Source License
/** * Collects all jar files from installation folder and creates a set of * classpath entries.//w ww .j a v a 2s . co m * In case classpath entries cannot be created this logs an exception * but let it slip. User should still be able to setup the classpath * manually. * @return an array of classpath entries or null if none is built */ private IClasspathEntry[] getLegStarClassPath() { try { java.util.List<IClasspathEntry> pathEntries = new ArrayList<IClasspathEntry>(); File libraryFolder = new File(Activator.getPluginInstallLocation(mPluginId) + "/lib"); File[] files = libraryFolder.listFiles(new JarFilter()); /* Locate the LegStar source bundle if any */ Path sourcesPath = null; for (File file : files) { String path = file.getAbsolutePath(); if (path.contains("Legstar") && path.endsWith("-sources.jar")) { sourcesPath = new Path(path); } } /* Add all jar files to classpath */ for (File file : files) { String path = file.getAbsolutePath(); Path sourceAttachmentPath = (path.contains("legstar")) ? sourcesPath : null; pathEntries.add(JavaCore.newLibraryEntry(new Path(path), sourceAttachmentPath, null, false)); } return (IClasspathEntry[]) pathEntries.toArray(new IClasspathEntry[pathEntries.size()]); } catch (InvocationTargetException e) { Activator.logCoreException(e.getTargetException(), mPluginId); return null; } }
From source file:com.mg.merp.wb.badi.library.Container.java
License:Open Source License
/** * ? jar ?? ? {@link Container#includedLibs} * thirdpart/*from w w w . j av a 2 s. c om*/ */ private void computeClasspathEntries() { createIncludedLibs(); classpathEntries = new IClasspathEntry[includedLibs.size() + BadiLibraryPlugin.getThirdLibs().size()]; int i = 0; for (String nm : includedLibs) { LibInfo jarLoc = BadiLibraryPlugin.getLibs().get(nm); if (jarLoc.srcPath != null) classpathEntries[i] = JavaCore.newLibraryEntry(new Path(jarLoc.jarPath), new Path(jarLoc.srcPath), new Path(SRC_ARCH_ROOT), true); else classpathEntries[i] = JavaCore.newLibraryEntry(new Path(jarLoc.jarPath), null, null); i++; } for (String nm : BadiLibraryPlugin.getThirdLibs()) { classpathEntries[i] = JavaCore.newLibraryEntry(new Path(nm), null, null); i++; } }