List of usage examples for org.eclipse.jdt.core IClasspathEntry getExtraAttributes
IClasspathAttribute[] getExtraAttributes();
From source file:org.talend.designer.codegen.config.TalendJetEmitter.java
License:Open Source License
/** * DOC ycbai Comment method "getClasspathFromEntry". * <p>/*from w w w. ja v a 2s . c o m*/ * Get the absolute classpath. * * @param entry * @return */ private String getClasspathFromEntry(IClasspathEntry entry) { if (entry == null) { return null; } IClasspathAttribute[] extraAttributes = entry.getExtraAttributes(); if (extraAttributes.length > 0) { for (IClasspathAttribute ca : extraAttributes) { if ("plugin_id".equals(ca.getName())) { //$NON-NLS-1$ String pluginId = ca.getValue(); if (pluginId != null) { File plugin = new File(ComponentBundleToPath.getPathFromBundle(pluginId)); String pluginPath = plugin.getAbsolutePath(); if (Platform.inDevelopmentMode() && plugin.isDirectory()) { String output; try { output = getIdeOutputSubDir(Platform.getBundle(pluginId)); if (output != null) { pluginPath = pluginPath + File.separator + output; } } catch (IOException e) { // for dev only so just keep a print stacktrace e.printStackTrace(); } } return pluginPath; } } } } return null; }
From source file:org.talend.designer.maven.project.CreateMavenCodeProject.java
License:Open Source License
private void changeClasspath(IProgressMonitor monitor, IProject p) { try {/*w w w .jav a 2 s .c o m*/ IJavaProject javaProject = JavaCore.create(p); IClasspathEntry[] rawClasspathEntries = javaProject.getRawClasspath(); boolean changed = false; for (int index = 0; index < rawClasspathEntries.length; index++) { IClasspathEntry entry = rawClasspathEntries[index]; IClasspathEntry newEntry = null; if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath path = entry.getPath(); if (p.getFullPath().isPrefixOf(path)) { path = path.removeFirstSegments(1); } // src/main/resources, in order to removing the 'excluding="**"'. if (MavenSystemFolders.RESOURCES.getPath().equals(path.toString())) { newEntry = JavaCore.newSourceEntry(entry.getPath(), new IPath[0], new IPath[0], // entry.getOutputLocation(), entry.getExtraAttributes()); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { // remove the special version of jre in container. IPath defaultJREContainerPath = JavaRuntime.newDefaultJREContainerPath(); if (defaultJREContainerPath.isPrefixOf(entry.getPath())) { // JavaRuntime.getDefaultJREContainerEntry(); //missing properties // newEntry = JavaCore.newContainerEntry(defaultJREContainerPath, entry.getAccessRules(), // entry.getExtraAttributes(), entry.isExported()); } } if (newEntry != null) { rawClasspathEntries[index] = newEntry; changed = true; } } if (changed) { javaProject.setRawClasspath(rawClasspathEntries, monitor); } } catch (CoreException e) { ExceptionHandler.process(e); } }
From source file:org.talend.designer.maven.tools.creator.CreateMavenCodeProject.java
License:Open Source License
public static void changeClasspath(IProgressMonitor monitor, IProject p) { try {//from w w w . j a v a2s .co m IJavaProject javaProject = JavaCore.create(p); IClasspathEntry[] rawClasspathEntries = javaProject.getRawClasspath(); boolean changed = false; for (int index = 0; index < rawClasspathEntries.length; index++) { IClasspathEntry entry = rawClasspathEntries[index]; IClasspathEntry newEntry = null; if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath path = entry.getPath(); if (p.getFullPath().isPrefixOf(path)) { path = path.removeFirstSegments(1); } // src/main/resources, in order to removing the 'excluding="**"'. if (MavenSystemFolders.RESOURCES.getPath().equals(path.toString())) { newEntry = JavaCore.newSourceEntry(entry.getPath(), new IPath[0], new IPath[0], // entry.getOutputLocation(), entry.getExtraAttributes()); } // src/test/resources, in order to removing the 'excluding="**"'. if (MavenSystemFolders.RESOURCES_TEST.getPath().equals(path.toString())) { newEntry = JavaCore.newSourceEntry(entry.getPath(), new IPath[0], new IPath[0], // entry.getOutputLocation(), entry.getExtraAttributes()); } } else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { // remove the special version of jre in container. IPath defaultJREContainerPath = JavaRuntime.newDefaultJREContainerPath(); if (defaultJREContainerPath.isPrefixOf(entry.getPath())) { // JavaRuntime.getDefaultJREContainerEntry(); //missing properties newEntry = JavaCore.newContainerEntry(defaultJREContainerPath, entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); } } if (newEntry != null) { rawClasspathEntries[index] = newEntry; changed = true; } } if (changed) { javaProject.setRawClasspath(rawClasspathEntries, monitor); } } catch (CoreException e) { ExceptionHandler.process(e); } }