本文整理汇总了Java中org.eclipse.jdt.internal.core.ClasspathEntry.NO_EXTRA_ATTRIBUTES属性的典型用法代码示例。如果您正苦于以下问题:Java ClasspathEntry.NO_EXTRA_ATTRIBUTES属性的具体用法?Java ClasspathEntry.NO_EXTRA_ATTRIBUTES怎么用?Java ClasspathEntry.NO_EXTRA_ATTRIBUTES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.internal.core.ClasspathEntry
的用法示例。
在下文中一共展示了ClasspathEntry.NO_EXTRA_ATTRIBUTES属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureProjectClasspath
private static void configureProjectClasspath(IJavaProject jProject) throws CoreException, JavaModelException, IOException, URISyntaxException {
// create bin folder
try {
IFolder binFolder = jProject.getProject().getFolder(BINARY_DIRECTORY);
binFolder.create(false, true, null);
jProject.setOutputLocation(binFolder.getFullPath(), null);
} catch (Exception e){
Log.warning("Could not created bin folder.", e);
}
// create a set of classpath entries
List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
// adds classpath entry of: <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
String path = org.eclipse.jdt.launching.JavaRuntime.JRE_CONTAINER + "/" + org.eclipse.jdt.internal.launching.StandardVMType.ID_STANDARD_VM_TYPE + "/" + "JavaSE-1.8";
entries.add(JavaCore.newContainerEntry(new Path(path)));
// add the jreframeworker annotations jar
addProjectAnnotationsLibrary(jProject);
// have to create this manually instead of using JavaCore.newLibraryEntry because JavaCore insists the path be absolute
IClasspathEntry relativeAnnotationsLibraryEntry = new ClasspathEntry(IPackageFragmentRoot.K_BINARY,
IClasspathEntry.CPE_LIBRARY, new Path(JREF_PROJECT_RESOURCE_DIRECTORY + "/" + JRE_FRAMEWORKER_ANNOTATIONS_JAR), ClasspathEntry.INCLUDE_ALL, // inclusion patterns
ClasspathEntry.EXCLUDE_NONE, // exclusion patterns
null, null, null, // specific output folder
false, // exported
ClasspathEntry.NO_ACCESS_RULES, false, // no access rules to combine
ClasspathEntry.NO_EXTRA_ATTRIBUTES);
entries.add(relativeAnnotationsLibraryEntry);
// create source folder and add it to the classpath
IFolder sourceFolder = jProject.getProject().getFolder(SOURCE_DIRECTORY);
sourceFolder.create(false, true, null);
IPackageFragmentRoot sourceFolderRoot = jProject.getPackageFragmentRoot(sourceFolder);
entries.add(JavaCore.newSourceEntry(sourceFolderRoot.getPath()));
// set the class path
jProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
if(JReFrameworkerPreferences.isVerboseLoggingEnabled()) Log.info("Successfully created JReFrameworker project: " + jProject.getProject().getName());
}
示例2: addProjectLibrary
/**
* Copies a jar into the project at the specified relative path and updates the classpath
* @param jProject
* @param libraryToAdd
* @param relativeDirectoryPath
* @throws IOException
* @throws URISyntaxException
* @throws MalformedURLException
* @throws CoreException
*/
private static String addProjectLibrary(IJavaProject jProject, File libraryToAdd, String relativeDirectoryPath) throws IOException, URISyntaxException, MalformedURLException, CoreException {
// only add the project library to the classpath if its not already there
for(IClasspathEntry entry : jProject.getRawClasspath()){
if(entry.getPath().toFile().getName().endsWith(libraryToAdd.getName())){
return entry.getPath().toString();
}
}
// copy the jar file into the project (if its not already there)
InputStream libraryInputStream = new BufferedInputStream(new FileInputStream(libraryToAdd));
File libDirectory;
if(relativeDirectoryPath == null || relativeDirectoryPath.equals("")){
libDirectory = new File(jProject.getProject().getLocation().toFile().getCanonicalPath());
} else {
relativeDirectoryPath = relativeDirectoryPath.replace("/", File.separator).replace("\\", File.separator);
libDirectory = new File(jProject.getProject().getLocation().toFile().getCanonicalPath() + File.separator + relativeDirectoryPath);
}
libDirectory.mkdirs();
File library = new File(libDirectory.getCanonicalPath() + File.separatorChar + libraryToAdd.getName());
if(!library.exists()){
Files.copy(libraryInputStream, library.toPath());
}
// refresh project
jProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
// create a classpath entry for the library
IClasspathEntry relativeLibraryEntry;
if(relativeDirectoryPath != null){
relativeDirectoryPath = relativeDirectoryPath.replace(File.separator, "/");
// library is at some path relative to project root
relativeLibraryEntry = new org.eclipse.jdt.internal.core.ClasspathEntry(
IPackageFragmentRoot.K_BINARY,
IClasspathEntry.CPE_LIBRARY, jProject.getProject().getFile(relativeDirectoryPath + "/" + library.getName()).getLocation(),
ClasspathEntry.INCLUDE_ALL, // inclusion patterns
ClasspathEntry.EXCLUDE_NONE, // exclusion patterns
null, null, null, // specific output folder
false, // exported
ClasspathEntry.NO_ACCESS_RULES, false, // no access rules to combine
ClasspathEntry.NO_EXTRA_ATTRIBUTES);
} else {
// library placed at project root
relativeLibraryEntry = new org.eclipse.jdt.internal.core.ClasspathEntry(
IPackageFragmentRoot.K_BINARY,
IClasspathEntry.CPE_LIBRARY, jProject.getProject().getFile(library.getName()).getLocation(),
ClasspathEntry.INCLUDE_ALL, // inclusion patterns
ClasspathEntry.EXCLUDE_NONE, // exclusion patterns
null, null, null, // specific output folder
false, // exported
ClasspathEntry.NO_ACCESS_RULES, false, // no access rules to combine
ClasspathEntry.NO_EXTRA_ATTRIBUTES);
}
// add the new classpath entry to the project's existing entries
IClasspathEntry[] oldEntries = jProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
newEntries[oldEntries.length] = relativeLibraryEntry;
jProject.setRawClasspath(newEntries, null);
// refresh project
jProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
return relativeLibraryEntry.getPath().toString();
}