List of usage examples for org.eclipse.jdt.internal.core ClasspathEntry NO_ACCESS_RULES
IAccessRule[] NO_ACCESS_RULES
To view the source code for org.eclipse.jdt.internal.core ClasspathEntry NO_ACCESS_RULES.
Click Source Link
From source file:com.google.gdt.eclipse.managedapis.impl.ClasspathEntryPrototype.java
License:Open Source License
/** * Produce a ClasspathEntry from this prototype. * // www .j a va 2 s . c o m * @param projectRoot The project root, used to determine relative paths. * @return The classpath entry or null if no class archive is defined. */ public IClasspathEntry createClasspathEntry(IPath projectRoot) { IPath libRelativePath = (classArchive == null) ? null : makeRelative(classArchive.getFullPath(), projectRoot); IPath srcPath = (sourceArchive == null) ? null : makeRelative(sourceArchive.getFullPath(), projectRoot); IPath javadocPath = (javadocArchive == null) ? null : makeRelative(javadocArchive.getFullPath(), projectRoot); IClasspathAttribute[] extraAttributes = (null == javadocPath) ? ClasspathEntry.NO_EXTRA_ATTRIBUTES : new IClasspathAttribute[] { new ClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, "jar:platform:/resource" + javadocPath.toString() + "!/") }; // create a new CPE_LIBRARY type of cp entry with an attached source // archive if it exists return (libRelativePath == null) ? null : JavaCore.newLibraryEntry(libRelativePath, srcPath, srcPath == null ? null : new Path("/"), ClasspathEntry.NO_ACCESS_RULES, extraAttributes, false); }
From source file:com.windowtester.codegen.util.BuildPathUtil.java
License:Open Source License
public static IClasspathEntry getEntry(String bundleName, String jarName, boolean hasJavadoc) { // check if bundle is a workspace project and if it is then use the project entry // from workspace or otherwise resolve path from the bundle location IProject wsJavaProject = ResourcesPlugin.getWorkspace().getRoot().getProject(bundleName); if (wsJavaProject.exists()) return JavaCore.newProjectEntry(wsJavaProject.getFullPath()); // get the bundle Bundle bundle = Platform.getBundle(bundleName); if (bundle == null) return null; String path;//from ww w.j av a 2 s .com try { // get the bundle location URL location = bundle.getEntry(jarName); // there is no jar in bundle location URL jarLocation = null; if (location == null) { // assume bundle location is jared archive location = bundle.getEntry("/"); jarLocation = Platform.resolve(location); // test if bundle is jared if (!jarLocation.getFile().endsWith(".jar!/")) { // return null if it is not jar return null; } else { // remove jar: protocol from URL at this step jarLocation = new URL(jarLocation.getPath()); } } else { jarLocation = Platform.resolve(location); } // normalize path path = jarLocation.getFile(); if (path.endsWith(".jar!/")) { path = path.substring(0, path.length() - 2); } } catch (IOException e) { Logger.log(e); return null; } /* $codepro.preprocessor.if version < 3.1 $ return JavaCore.newLibraryEntry(new Path(path), null, null); $codepro.preprocessor.elseif version >= 3.1 $ */ org.eclipse.jdt.core.IClasspathAttribute[] attributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; if (hasJavadoc) { Bundle docBundle = Platform.getBundle(WINTEST_JAVADOC_PLUGIN_ID); if (docBundle != null) { URL location = bundle.getEntry(WINTEST_JAVADOC_RELATIVE_PATH); if (location != null) { attributes = new org.eclipse.jdt.core.IClasspathAttribute[] { JavaCore.newClasspathAttribute( org.eclipse.jdt.core.IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, location.toExternalForm()) }; } } } return JavaCore.newLibraryEntry(new Path(path), null, null, ClasspathEntry.NO_ACCESS_RULES, attributes, false); /* $codepro.preprocessor.endif $ */ }
From source file:org.codehaus.groovy.eclipse.core.model.GroovyRuntime.java
License:Apache License
/** * Adds a library/folder that already exists in the project to the * classpath. Only added if it is not already on the classpath. * * @param javaProject/*from ww w. j a va 2 s . c o m*/ * The project to add add the classpath entry to. * @param libraryPath * The path to add to the classpath. * @param isExported TODO * @throws JavaModelException */ public static void addLibraryToClasspath(final IJavaProject javaProject, final IPath libraryPath, boolean isExported) throws JavaModelException { boolean alreadyExists = includesClasspathEntry(javaProject, libraryPath.lastSegment()); if (alreadyExists) { return; } addClassPathEntry(javaProject, new ClasspathEntry(IPackageFragmentRoot.K_BINARY, IClasspathEntry.CPE_CONTAINER, libraryPath, ClasspathEntry.INCLUDE_ALL, // inclusion patterns ClasspathEntry.EXCLUDE_NONE, // exclusion patterns null, null, null, // specific output folder true, // exported ClasspathEntry.NO_ACCESS_RULES, false, // no access rules to // combine ClasspathEntry.NO_EXTRA_ATTRIBUTES)); }
From source file:org.objectstyle.wolips.jdt.classpath.model.EclipsePathFramework.java
License:Open Source License
public synchronized IClasspathEntry[] getClasspathEntries() { List<IClasspathEntry> classpathEntries; if (cachedClasspathEntries == null) { classpathEntries = new LinkedList<IClasspathEntry>(); for (FrameworkLibrary library : getFrameworkLibraries()) { IPath jarPath = new Path(library.getLibraryFile().getAbsolutePath()); IPath sourceJarPath = null;/*from w ww . ja va2 s .co m*/ File sourceJar = library.getSourceJar(); if (sourceJar != null) { sourceJarPath = new Path(library.getSourceJar().getAbsolutePath()); } String sourcePathStr = library.getSourcePath(); IPath sourcePath = null; if (sourcePathStr != null) { sourcePath = new Path(sourcePathStr); } String docPathStr = library.getDocPath(); IClasspathAttribute[] attributes = ClasspathEntry.NO_EXTRA_ATTRIBUTES; if (docPathStr != null || getName().startsWith("Java")) { if (docPathStr == null) { docPathStr = VariablesPlugin.getDefault().getGlobalVariables() .getReferenceApiAsJavaDocCompatibleString(); } if (docPathStr != null) { IClasspathAttribute javadoc = JavaCore.newClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, docPathStr); attributes = new IClasspathAttribute[] { javadoc }; } } IClasspathEntry classpathEntry = JavaCore.newLibraryEntry(jarPath, sourceJarPath, sourcePath, ClasspathEntry.NO_ACCESS_RULES, attributes, false); classpathEntries.add(classpathEntry); } cachedClasspathEntries = classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]); } return cachedClasspathEntries.clone(); }
From source file:org.springsource.ide.eclipse.gradle.core.classpathcontainer.GradleDependencyComputer.java
License:Open Source License
private void addJarEntry(IPath jarPath, ExternalDependency gEntry, boolean export) { // Get the location of a source jar, if any. IPath sourceJarPath = null;/*from w w w. j a va 2s. co m*/ File sourceJarFile = gEntry.getSource(); if (sourceJarFile != null) { sourceJarPath = new Path(sourceJarFile.getAbsolutePath()); } //Get the location of Java doc attachement, if any List<IClasspathAttribute> extraAttributes = new ArrayList<IClasspathAttribute>(); File javaDoc = gEntry.getJavadoc(); if (javaDoc != null) { //Example of what it looks like in the eclipse .classpath file: //<attributes> // <attribute name="javadoc_location" value="jar:file:/tmp/workspace/repos/test-with-jdoc-1.0-javadoc.jar!/"/> //</attributes> String jdoc = javaDoc.toURI().toString(); if (!javaDoc.isDirectory()) { //Assume its a jar or zip containing the docs jdoc = "jar:" + jdoc + "!/"; } IClasspathAttribute javaDocAttribute = new ClasspathAttribute( IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, jdoc); extraAttributes.add(javaDocAttribute); } WTPUtil.excludeFromDeployment(project.getJavaProject(), jarPath, extraAttributes); //Create classpath entry with all this info IClasspathEntry newLibraryEntry = JavaCore.newLibraryEntry(jarPath, sourceJarPath, null, ClasspathEntry.NO_ACCESS_RULES, extraAttributes.toArray(new IClasspathAttribute[extraAttributes.size()]), export); classpath.add(newLibraryEntry); if (newLibraryEntry.toString().contains("unresolved dependency")) { debug("entry: " + newLibraryEntry); } }