本文整理汇总了Java中org.eclipse.jdt.core.IClasspathAttribute类的典型用法代码示例。如果您正苦于以下问题:Java IClasspathAttribute类的具体用法?Java IClasspathAttribute怎么用?Java IClasspathAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IClasspathAttribute类属于org.eclipse.jdt.core包,在下文中一共展示了IClasspathAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDependenciesToClasspath
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
private void addDependenciesToClasspath(IProject project, IFolder folder,
IProgressMonitor monitor) throws CoreException {
List<IClasspathEntry> newEntries = new ArrayList<>();
IClasspathAttribute[] nonDependencyAttribute =
new IClasspathAttribute[] {UpdateClasspathAttributeUtil.createNonDependencyAttribute()};
// Add all the jars under lib folder to the classpath
File libFolder = folder.getLocation().toFile();
for (File file : libFolder.listFiles()) {
IPath path = Path.fromOSString(file.toPath().toString());
newEntries.add(JavaCore.newLibraryEntry(path, null, null, new IAccessRule[0],
nonDependencyAttribute, false /* isExported */));
}
ClasspathUtil.addClasspathEntries(project, newEntries, monitor);
}
示例2: testCreateClasspathAttributesWithClassifier
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
@Test
public void testCreateClasspathAttributesWithClassifier() {
MavenCoordinates mavenCoordinates = builder.setClassifier("classifier").build();
List<IClasspathAttribute> classpathAttributes =
MavenCoordinatesHelper.createClasspathAttributes(mavenCoordinates, "1.0.0");
assertAttribute(classpathAttributes,
"com.google.cloud.tools.eclipse.appengine.libraries.repository", "testRepo");
assertAttribute(classpathAttributes,
"com.google.cloud.tools.eclipse.appengine.libraries.groupid", "groupId");
assertAttribute(classpathAttributes,
"com.google.cloud.tools.eclipse.appengine.libraries.artifactId", "artifactId");
assertAttribute(classpathAttributes,
"com.google.cloud.tools.eclipse.appengine.libraries.type", "war");
assertAttribute(classpathAttributes,
"com.google.cloud.tools.eclipse.appengine.libraries.version", "1.0.0");
assertAttribute(classpathAttributes,
"com.google.cloud.tools.eclipse.appengine.libraries.classifier", "classifier");
}
示例3: getClasspathAttributes
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
private static IClasspathAttribute[] getClasspathAttributes(LibraryFile libraryFile,
Artifact artifact)
throws CoreException {
List<IClasspathAttribute> attributes =
MavenCoordinatesHelper.createClasspathAttributes(libraryFile.getMavenCoordinates(),
artifact.getVersion());
if (libraryFile.isExport()) {
attributes.add(UpdateClasspathAttributeUtil.createDependencyAttribute(true /* isWebApp */));
} else {
attributes.add(UpdateClasspathAttributeUtil.createNonDependencyAttribute());
}
if (libraryFile.getSourceUri() != null) {
addUriAttribute(attributes, CLASSPATH_ATTRIBUTE_SOURCE_URL, libraryFile.getSourceUri());
}
if (libraryFile.getJavadocUri() != null) {
addUriAttribute(attributes, IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
libraryFile.getJavadocUri());
}
return attributes.toArray(new IClasspathAttribute[0]);
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:21,代码来源:LibraryClasspathContainerResolverService.java
示例4: createClasspathAttributes
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
public static List<IClasspathAttribute> createClasspathAttributes(MavenCoordinates mavenCoordinates,
String actualVersion) {
List<IClasspathAttribute> attributes = Lists.newArrayList(
JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_REPOSITORY,
mavenCoordinates.getRepository()),
JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_GROUP_ID,
mavenCoordinates.getGroupId()),
JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_ARTIFACT_ID,
mavenCoordinates.getArtifactId()),
JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_TYPE,
mavenCoordinates.getType()),
JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_VERSION,
actualVersion)
);
if (mavenCoordinates.getClassifier() != null) {
attributes.add(JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_CLASSIFIER,
mavenCoordinates.getClassifier()));
}
return attributes;
}
示例5: decodeExtraAttributes
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
static IClasspathAttribute[] decodeExtraAttributes(NodeList attributes) {
if (attributes == null) return NO_EXTRA_ATTRIBUTES;
int length = attributes.getLength();
if (length == 0) return NO_EXTRA_ATTRIBUTES;
IClasspathAttribute[] result = new IClasspathAttribute[length];
int index = 0;
for (int i = 0; i < length; ++i) {
Node node = attributes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element attribute = (Element) node;
String name = attribute.getAttribute(TAG_ATTRIBUTE_NAME);
if (name == null) continue;
String value = attribute.getAttribute(TAG_ATTRIBUTE_VALUE);
if (value == null) continue;
result[index++] = new ClasspathAttribute(name, value);
}
}
if (index != length)
System.arraycopy(result, 0, result = new IClasspathAttribute[index], 0, index);
return result;
}
示例6: getLibraryIndexLocation
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
/**
* This function computes the URL of the index location for this classpath entry. It returns null
* if the URL is invalid.
*/
public URL getLibraryIndexLocation() {
switch (getEntryKind()) {
case IClasspathEntry.CPE_LIBRARY:
case IClasspathEntry.CPE_VARIABLE:
break;
default:
return null;
}
if (this.extraAttributes == null) return null;
for (int i = 0; i < this.extraAttributes.length; i++) {
IClasspathAttribute attrib = this.extraAttributes[i];
if (IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
String value = attrib.getValue();
try {
return new URL(value);
} catch (MalformedURLException e) {
return null;
}
}
}
return null;
}
示例7: getLibraryJavadocLocation
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
public static URL getLibraryJavadocLocation(IClasspathEntry entry) {
if (entry == null) {
throw new IllegalArgumentException("Entry must not be null"); // $NON-NLS-1$
}
int kind = entry.getEntryKind();
if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) {
throw new IllegalArgumentException(
"Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); // $NON-NLS-1$
}
IClasspathAttribute[] extraAttributes = entry.getExtraAttributes();
for (int i = 0; i < extraAttributes.length; i++) {
IClasspathAttribute attrib = extraAttributes[i];
if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
return parseURL(attrib.getValue());
}
}
return null;
}
示例8: getSourceAttachmentEncoding
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
private static String getSourceAttachmentEncoding(IPackageFragmentRoot root)
throws JavaModelException {
String encoding = ResourcesPlugin.getEncoding();
IClasspathEntry entry = root.getRawClasspathEntry();
if (entry != null) {
int kind = entry.getEntryKind();
if (kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE) {
IClasspathAttribute[] extraAttributes = entry.getExtraAttributes();
for (int i = 0; i < extraAttributes.length; i++) {
IClasspathAttribute attrib = extraAttributes[i];
if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) {
return attrib.getValue();
}
}
}
}
return encoding;
}
示例9: buildClasspathAttributes
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
private static IClasspathAttribute[] buildClasspathAttributes(
final IVMInstallType vm, final LibraryLocation lib, final boolean overrideJavaDoc) {
List<IClasspathAttribute> classpathAttributes = new LinkedList<IClasspathAttribute>();
// process the javadoc location
URL javadocLocation = lib.getJavadocLocation();
if (overrideJavaDoc && javadocLocation == null) {
javadocLocation = null; // vm.getJavadocLocation();
}
if (javadocLocation != null) {
IClasspathAttribute javadocCPAttribute =
JavaCore.newClasspathAttribute(
IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
javadocLocation.toExternalForm());
classpathAttributes.add(javadocCPAttribute);
}
// process the index location
URL indexLocation = lib.getIndexLocation();
if (indexLocation != null) {
IClasspathAttribute indexCPLocation =
JavaCore.newClasspathAttribute(
IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, indexLocation.toExternalForm());
classpathAttributes.add(indexCPLocation);
}
return classpathAttributes.toArray(new IClasspathAttribute[classpathAttributes.size()]);
}
示例10: getArtifactKey
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
private MavenArtifactKey getArtifactKey(IClasspathEntry classpathEntry) {
IClasspathAttribute[] attributes = classpathEntry.getExtraAttributes();
String groupId = null;
String artifactId = null;
String version = null;
String packaging = null;
String classifier = null;
for (IClasspathAttribute attribute : attributes) {
if (ClasspathManager.GROUP_ID_ATTRIBUTE.equals(attribute.getName())) {
groupId = attribute.getValue();
} else if (ClasspathManager.ARTIFACT_ID_ATTRIBUTE.equals(attribute.getName())) {
artifactId = attribute.getValue();
} else if (ClasspathManager.VERSION_ATTRIBUTE.equals(attribute.getName())) {
version = attribute.getValue();
} else if (ClasspathManager.PACKAGING_ATTRIBUTE.equals(attribute.getName())) {
packaging = attribute.getValue();
} else if (ClasspathManager.CLASSIFIER_ATTRIBUTE.equals(attribute.getName())) {
classifier = attribute.getValue();
}
}
if (groupId != null && artifactId != null && version != null) {
return new MavenArtifactKey(groupId, artifactId, version, packaging, classifier);
}
return null;
}
示例11: testFindSdkFor_GwtUserProject
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
/**
* Tests that we find an {@link com.google.gdt.eclipse.core.sdk.Sdk} on the
* gwt-user project.
*
* @throws Exception
*/
public void testFindSdkFor_GwtUserProject() throws Exception {
GwtRuntimeTestUtilities.importGwtSourceProjects();
try {
IJavaModel javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
IJavaProject javaProject = javaModel.getJavaProject("gwt-user");
GwtSdk sdk = GwtSdk.findSdkFor(javaProject);
IClasspathEntry gwtUserEntry =
JavaCore.newSourceEntry(
javaModel.getJavaProject("gwt-user").getPath().append("core/src"),
new IPath[] {new Path("**/super/**")});
/*
* NOTE: Passing null for the IClasspathAttribute array tickles a bug in
* eclipse 3.3.
*/
IClasspathEntry gwtDevEntry =
JavaCore.newProjectEntry(javaModel.getJavaProject("gwt-dev").getPath(), null, false,
new IClasspathAttribute[0] /* */, false);
IClasspathEntry[] expected = new IClasspathEntry[] {gwtUserEntry, gwtDevEntry};
assertEquals(expected, sdk.getClasspathEntries());
} finally {
GwtRuntimeTestUtilities.removeGwtSourceProjects();
}
}
示例12: getLibraryJavadocLocation
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
public static URL getLibraryJavadocLocation(IClasspathEntry entry) {
if (entry == null) {
throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$
}
int kind= entry.getEntryKind();
if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) {
throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); //$NON-NLS-1$
}
IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
for (int i= 0; i < extraAttributes.length; i++) {
IClasspathAttribute attrib= extraAttributes[i];
if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
return parseURL(attrib.getValue());
}
}
return null;
}
示例13: getSourceAttachmentEncoding
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
private static String getSourceAttachmentEncoding(IPackageFragmentRoot root) throws JavaModelException {
String encoding= ResourcesPlugin.getEncoding();
IClasspathEntry entry= root.getRawClasspathEntry();
if (entry != null) {
int kind= entry.getEntryKind();
if (kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE) {
IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
for (int i= 0; i < extraAttributes.length; i++) {
IClasspathAttribute attrib= extraAttributes[i];
if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) {
return attrib.getValue();
}
}
}
}
return encoding;
}
示例14: handleContainerEntry
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
private IClasspathEntry handleContainerEntry(IPath containerPath, IJavaProject jproject, IPath jarPath) throws JavaModelException {
ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject);
if (initializer == null || container == null) {
setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_invalid_container, BasicElementLabels.getPathLabel(containerPath, false)));
return null;
}
String containerName= container.getDescription();
IStatus status= initializer.getAttributeStatus(containerPath, jproject, IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME);
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) {
setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_not_supported, containerName));
return null;
}
IClasspathEntry entry= JavaModelUtil.findEntryInContainer(container, jarPath);
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) {
setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_read_only, containerName));
fIsReadOnly= true;
return entry;
}
Assert.isNotNull(entry);
setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description);
return entry;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:JavadocConfigurationPropertyPage.java
示例15: createIgnoreOptionalProblemsLink
import org.eclipse.jdt.core.IClasspathAttribute; //导入依赖的package包/类
protected Link createIgnoreOptionalProblemsLink(Composite parent) {
final IClasspathEntry sourceFolderEntry= getSourceFolderIgnoringOptionalProblems();
if (sourceFolderEntry != null) {
Link link= new Link(parent, SWT.NONE);
link.setText(PreferencesMessages.OptionsConfigurationBlock_IgnoreOptionalProblemsLink);
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
HashMap<Object, Object> data= new HashMap<Object, Object>(1);
data.put(BuildPathsPropertyPage.DATA_REVEAL_ENTRY, sourceFolderEntry);
data.put(BuildPathsPropertyPage.DATA_REVEAL_ATTRIBUTE_KEY, IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS);
getPreferenceContainer().openPage(BuildPathsPropertyPage.PROP_ID, data);
}
});
return link;
}
return null;
}