List of usage examples for org.eclipse.jdt.core IClasspathEntry getOutputLocation
IPath getOutputLocation();
.class
files generated for this source entry (entry kind #CPE_SOURCE ). From source file:org.eclipse.che.plugin.java.testing.ProjectClasspathProviderTest.java
License:Open Source License
private IClasspathEntry mockClasspathEntry(int kind, String path, String outputPath) { IClasspathEntry result = mock(IClasspathEntry.class); when(result.getEntryKind()).thenReturn(kind); when(result.getPath()).thenReturn(new Path(path)); if (outputPath != null) { when(result.getOutputLocation()).thenReturn(new Path(outputPath)); }//from w w w . j a v a 2 s.co m return result; }
From source file:org.eclipse.che.plugin.maven.server.classpath.OutputPathTest.java
License:Open Source License
@Test public void testSourceClasspathEntryShouldHaveOutputLocationPath() throws Exception { String pom = "<groupId>test</groupId>" + "<artifactId>testOutputLocation</artifactId>" + "<version>42</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>"; createTestProject("test", pom); IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test"); mavenWorkspace.update(Collections.singletonList(test)); mavenWorkspace.waitForUpdate();/*from w w w. j av a 2 s .com*/ JavaProject javaProject = (JavaProject) JavaCore.create(test); IClasspathEntry[] classpath = javaProject.getResolvedClasspath(); IClasspathEntry srcMainJava = null; for (IClasspathEntry entry : classpath) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().toOSString().endsWith("src/main/java")) { srcMainJava = entry; break; } } assertThat(srcMainJava).isNotNull(); assertThat(srcMainJava.getOutputLocation()).isNotNull(); assertThat(srcMainJava.getOutputLocation().toOSString()).endsWith("target/classes"); }
From source file:org.eclipse.che.plugin.maven.server.classpath.OutputPathTest.java
License:Open Source License
@Test public void testSourceClasspathEntryShouldHaveCustomOutputLocationPath() throws Exception { String pom = "<groupId>test</groupId>" + "<artifactId>testOutputLocation</artifactId>" + "<version>42</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>" + "<build>" + " <outputDirectory>bin/classes</outputDirectory>" + "</build>"; createTestProject("test", pom); IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test"); mavenWorkspace.update(Collections.singletonList(test)); mavenWorkspace.waitForUpdate();/* w w w . jav a 2 s . c om*/ JavaProject javaProject = (JavaProject) JavaCore.create(test); IClasspathEntry[] classpath = javaProject.getResolvedClasspath(); IClasspathEntry srcMainJava = null; for (IClasspathEntry entry : classpath) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().toOSString().endsWith("src/main/java")) { srcMainJava = entry; break; } } assertThat(srcMainJava).isNotNull(); assertThat(srcMainJava.getOutputLocation()).isNotNull(); assertThat(srcMainJava.getOutputLocation().toOSString()).endsWith("bin/classes"); }
From source file:org.eclipse.che.plugin.maven.server.classpath.OutputPathTest.java
License:Open Source License
@Test public void testTestSourceClasspathEntryShouldHaveOutputLocationPath() throws Exception { String pom = "<groupId>test</groupId>" + "<artifactId>testOutputLocation</artifactId>" + "<version>42</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>"; createTestProject("test", pom); IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test"); mavenWorkspace.update(Collections.singletonList(test)); mavenWorkspace.waitForUpdate();// w w w . j av a 2s .c o m JavaProject javaProject = (JavaProject) JavaCore.create(test); IClasspathEntry[] classpath = javaProject.getResolvedClasspath(); IClasspathEntry srcMainJava = null; for (IClasspathEntry entry : classpath) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().toOSString().endsWith("src/test/java")) { srcMainJava = entry; break; } } assertThat(srcMainJava).isNotNull(); assertThat(srcMainJava.getOutputLocation()).isNotNull(); assertThat(srcMainJava.getOutputLocation().toOSString()).endsWith("target/test-classes"); }
From source file:org.eclipse.che.plugin.maven.server.classpath.OutputPathTest.java
License:Open Source License
@Test public void testTestSourceClasspathEntryShouldHaveCustomOutputLocationPath() throws Exception { String pom = "<groupId>test</groupId>" + "<artifactId>testOutputLocation</artifactId>" + "<version>42</version>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>" + "<build>" + " <testOutputDirectory>test/test-classes</testOutputDirectory>" + "</build>"; createTestProject("test", pom); IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test"); mavenWorkspace.update(Collections.singletonList(test)); mavenWorkspace.waitForUpdate();/* w w w . ja v a2 s .com*/ JavaProject javaProject = (JavaProject) JavaCore.create(test); IClasspathEntry[] classpath = javaProject.getResolvedClasspath(); IClasspathEntry srcMainJava = null; for (IClasspathEntry entry : classpath) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().toOSString().endsWith("src/test/java")) { srcMainJava = entry; break; } } assertThat(srcMainJava).isNotNull(); assertThat(srcMainJava.getOutputLocation()).isNotNull(); assertThat(srcMainJava.getOutputLocation().toOSString()).endsWith("test/test-classes"); }
From source file:org.eclipse.che.plugin.maven.server.core.classpath.ClasspathEntryHelper.java
License:Open Source License
private void setClasspathEntry(IClasspathEntry entry) { this.kind = entry.getEntryKind(); this.path = entry.getPath(); this.exported = entry.isExported(); this.outputLocation = entry.getOutputLocation(); this.accessRules = new ArrayList<>(); for (IAccessRule rule : entry.getAccessRules()) { this.accessRules.add(rule); }/*from w w w.j av a 2 s .c o m*/ this.attributes = new HashMap<>(); for (IClasspathAttribute attribute : entry.getExtraAttributes()) { attributes.put(attribute.getName(), attribute.getValue()); } this.sourcePath = entry.getSourceAttachmentPath(); this.sourceRootPath = entry.getSourceAttachmentRootPath(); setInclusionPatterns(entry.getInclusionPatterns()); setExclusionPatterns(entry.getExclusionPatterns()); this.combineAccessRules = entry.combineAccessRules(); String groupId = attributes.get(ClasspathManager.GROUP_ID_ATTRIBUTE); String artifactId = attributes.get(ClasspathManager.ARTIFACT_ID_ATTRIBUTE); String version = attributes.get(ClasspathManager.VERSION_ATTRIBUTE); String packaging = attributes.get(ClasspathManager.PACKAGING_ATTRIBUTE); String classifier = attributes.get(ClasspathManager.CLASSIFIER_ATTRIBUTE); if (groupId != null && artifactId != null && version != null) { this.artifactKey = new MavenArtifactKey(groupId, artifactId, version, packaging, classifier); } }
From source file:org.eclipse.e4.tools.ui.designer.session.JavaHelper.java
License:Open Source License
/** * Get output folders.<br>/*from w w w . ja va 2s . c o m*/ * * @param project * @return a List of IFolders */ public static List<IFolder> getOutputFolders(IJavaProject project) throws CoreException { List<IFolder> folders = new UniqueEList<IFolder>(); if (project == null || project.exists() == false) { return folders; } // Default Output Location IFolder folder = findFolder(project.getOutputLocation()); if (folder != null) { folders.add(folder); } // Lookup in source folders for (IClasspathEntry entry : project.getResolvedClasspath(true)) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IFolder innerFolder = findFolder(entry.getOutputLocation()); if (innerFolder != null) { folders.add(innerFolder); } } } return folders; }
From source file:org.eclipse.edt.debug.core.java.filters.ClasspathEntryFilter.java
License:Open Source License
protected void processSourceEntry(IClasspathEntry entry, Map<String, Object> classMap) { IPath output = entry.getOutputLocation(); if (output == null) { // Check Java project's default. try {//from ww w. j a v a 2s . c o m IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(entry.getPath().segment(0)); if (project.isAccessible() && project.hasNature(JavaCore.NATURE_ID)) { output = JavaCore.create(project).getOutputLocation(); } } catch (CoreException ce) { EDTDebugCorePlugin.log(ce); } } if (output != null) { IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(output); if (resource != null) { IPath abs = resource.getLocation(); if (abs != null) { File file = abs.toFile(); if (file.isDirectory()) { String rootPath = file.getPath(); if (!rootPath.endsWith(File.separator)) { rootPath = rootPath + File.separator; } processDirectory(file, rootPath, classMap); } } } } }
From source file:org.eclipse.edt.debug.internal.core.java.SMAPBuilder.java
License:Open Source License
private void buildAll() throws CoreException { // Performance: only visit the bin directories. IJavaProject project = JavaCore.create(getProject()); IClasspathEntry[] cp = project.getResolvedClasspath(true); Set<IPath> binDirectories = new HashSet<IPath>(cp.length); for (IClasspathEntry entry : cp) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath outputLocation = entry.getOutputLocation(); if (outputLocation != null) { binDirectories.add(outputLocation); }//www. ja v a2 s. c om } } IPath outputLocation = project.getOutputLocation(); if (outputLocation != null) { binDirectories.add(outputLocation); } ResourceVisitor visitor = new ResourceVisitor(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for (IPath path : binDirectories) { IResource resource = root.findMember(path); if (resource != null) { resource.accept(visitor); } } }
From source file:org.eclipse.edt.ide.deployment.services.generators.ServiceUriMappingGenerator.java
License:Open Source License
private static String createClasspath(IJavaProject javaProject) throws JavaModelException, MalformedURLException, URISyntaxException { StringBuffer classpath = new StringBuffer(); String path;//from w w w. j av a2 s .c o m IClasspathEntry[] resolvedClasspath = javaProject.getResolvedClasspath(true); for (int i = 0; i < resolvedClasspath.length; i++) { IClasspathEntry entry = resolvedClasspath[i]; if (entry.getEntryKind() != IClasspathEntry.CPE_SOURCE) { path = entry.getPath().toPortableString(); } else { if (entry.getOutputLocation() != null) { path = javaProject.getProject().getLocation().removeLastSegments(1) .append(entry.getOutputLocation()).toPortableString(); } else { path = javaProject.getProject().getLocation().removeLastSegments(1) .append(javaProject.getOutputLocation()).toPortableString(); } } classpath.append(path); classpath.append(";"); } return classpath.toString(); }