List of usage examples for org.eclipse.jdt.core IJavaProject getOutputLocation
IPath getOutputLocation() throws JavaModelException;
From source file:net.rim.ejde.internal.util.ImportUtils.java
License:Open Source License
/** * Get the set of output paths of the given <code>IJavaProject</code>. * * @param javaProject//from w w w . j a v a2s .com * @return * @throws JavaModelException */ static public Set<IPath> getOutputPathSet(IJavaProject javaProject) { HashSet<IPath> outputPathSet = new HashSet<IPath>(); try { // get the output folder path of the project IPath outputFolderPath = javaProject.getOutputLocation(); if (outputFolderPath != null) { outputPathSet.add(outputFolderPath); } IClasspathEntry[] _classPathEntries = javaProject.getRawClasspath(); IClasspathEntry entry; for (int i = 0; i < _classPathEntries.length; i++) { entry = _classPathEntries[i]; if (IClasspathEntry.CPE_SOURCE == entry.getEntryKind()) { // get the output folder of the entry outputFolderPath = entry.getOutputLocation(); if (outputFolderPath != null) { outputPathSet.add(outputFolderPath); } } } } catch (JavaModelException e) { _log.debug(e.getMessage(), e); } return outputPathSet; }
From source file:net.sf.eclipse.tomcat.TomcatBootstrap.java
License:Open Source License
private void getClassPathEntries(IJavaProject prj, ArrayList data, List selectedPaths, ArrayList visitedProjects) { IClasspathEntry[] entries = null;/*from w ww . j a va 2 s. c o m*/ IPath outputPath = null; try { outputPath = prj.getOutputLocation(); if (selectedPaths.contains(outputPath.toFile().toString().replace('\\', '/'))) { add(data, prj.getProject().getWorkspace().getRoot().findMember(outputPath)); } entries = prj.getRawClasspath(); } catch (JavaModelException e) { TomcatLauncherPlugin.log(e); } if (entries != null) { getClassPathEntries(entries, prj, data, selectedPaths, visitedProjects, outputPath); } }
From source file:net.sf.eclipse.tomcat.TomcatBootstrap.java
License:Open Source License
private void collectMavenDependencies(IJavaProject prj, List data, List visitedProjects) { IClasspathEntry[] entries = null;// w w w .jav a 2 s. c o m try { add(data, prj.getProject().getWorkspace().getRoot().findMember(prj.getOutputLocation())); entries = prj.getRawClasspath(); } catch (JavaModelException e) { TomcatLauncherPlugin.log(e); } if (entries != null) { collectMavenDependencies(entries, prj, data, visitedProjects); } }
From source file:net.sf.eclipse.tomcat.TomcatBootstrap.java
License:Open Source License
private void collectMavenDependencies(IClasspathEntry[] entries, IJavaProject prj, List data, List visitedProjects) {/*from w ww .j ava 2 s .c o m*/ for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; IPath path = entry.getPath(); if ((entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) && entry.getPath().toString().endsWith("MAVEN2_CLASSPATH_CONTAINER")) { IClasspathEntry[] tmpEntry = null; try { tmpEntry = JavaCore.getClasspathContainer(path, prj).getClasspathEntries(); } catch (JavaModelException e1) { TomcatLauncherPlugin.log(e1); continue; } for (int j = 0; j < tmpEntry.length; j++) { if (tmpEntry[j].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { if (tmpEntry[j].getPath().lastSegment().matches(".*servlet-api[^\\/]{0,10}\\.jar$")) { continue; } if (tmpEntry[j].getPath().lastSegment().matches(".*jasper[^\\/]{0,10}\\.jar$")) { continue; } if (tmpEntry[j].getPath().lastSegment().matches(".*annotations-api[^\\/]{0,10}.\\.jar$")) { continue; } if (tmpEntry[j].getPath().lastSegment().matches(".*el-api[^\\/]{0,10}\\.jar$")) { continue; } if (tmpEntry[j].getPath().lastSegment().matches(".*jsp-api[^\\/]{0,10}\\.jar$")) { continue; } IResource res = prj.getProject().getWorkspace().getRoot().findMember(tmpEntry[j].getPath()); if (res != null) { add(data, res); } else { add(data, tmpEntry[j].getPath()); } } else if (tmpEntry[j].getEntryKind() == IClasspathEntry.CPE_PROJECT) { String prjName = tmpEntry[j].getPath().lastSegment(); IJavaProject subPrj = prj.getJavaModel().getJavaProject(prjName); try { add(data, prj.getProject().getWorkspace().getRoot() .findMember(subPrj.getOutputLocation())); } catch (JavaModelException e1) { TomcatLauncherPlugin.log(e1); continue; } if (!visitedProjects.contains(prjName)) { visitedProjects.add(prjName); collectMavenDependencies(subPrj, data, visitedProjects); } continue; } else { TomcatLauncherPlugin.log(">>> " + tmpEntry[j]); if (tmpEntry[j].getPath() != null) { add(data, tmpEntry[j].getPath()); } } } } } }
From source file:net.sf.eclipse.tomcat.TomcatProjectWebclasspathPropertyPage.java
License:Open Source License
public void getClassPathEntries(IJavaProject prj, ArrayList data) { IClasspathEntry[] myEntries = null;// w ww .j a va 2 s. c om IPath outputPath = null; try { outputPath = prj.getOutputLocation(); add(data, prj.getOutputLocation()); myEntries = prj.getRawClasspath(); } catch (JavaModelException e) { TomcatLauncherPlugin.log(e); } if (myEntries != null) { getClassPathEntries(myEntries, prj, data, outputPath); } }
From source file:net.sf.eclipsecs.core.builder.ProjectClassLoader.java
License:Open Source License
/** * Helper method to handle a source path. * //w w w . j a v a 2 s . c o m * @param project the original project * @param cpURLs the list that is to contain the projects classpath * @param entry the actually processed classpath entry * @param javapProject the java project * @throws JavaModelException an exception with the java project occured */ private static void handleSourcePath(IProject project, List<URL> cpURLs, IClasspathEntry entry, IJavaProject javapProject) throws JavaModelException { IPath sourcePath = entry.getPath(); // check for if the output path is different to the source path IPath outputPath = entry.getOutputLocation(); if (outputPath == null) { sourcePath = javapProject.getOutputLocation(); } else if (!outputPath.equals(sourcePath)) { // make the output path the relevant path since it contains the // class files sourcePath = outputPath; } // check if the sourcepath is relative to the project IPath projPath = project.getFullPath(); if (!projPath.equals(sourcePath) && sourcePath.matchingFirstSegments(projPath) > 0) { // remove the project part from the source path sourcePath = sourcePath.removeFirstSegments(projPath.segmentCount()); // get the folder for the path IFolder sourceFolder = project.getFolder(sourcePath); // get the absolute path for the folder sourcePath = sourceFolder.getLocation(); } else if (projPath.equals(sourcePath)) { sourcePath = project.getLocation(); } // try to add the path to the classpath handlePath(sourcePath, cpURLs); }
From source file:net.sf.fjep.fatjar.popup.actions.BuildFatJar.java
License:Open Source License
/** * @param jproject/*from w ww . j a v a 2 s . co m*/ * @param property * @return */ private Set getExcludes(IJavaProject jproject, String excludeString) { Set result = new HashSet(); IWorkspaceRoot root = jproject.getProject().getWorkspace().getRoot(); if ((excludeString != null) && !excludeString.trim().equals("")) { String[] excludes = excludeString.split("[;]"); for (int i = 0; i < excludes.length; i++) { String exclude = excludes[i]; String absPath = exclude; if (exclude.startsWith("<po|")) { String javaProjectName = exclude.replaceFirst("[<]po[|](.*)[>](.*)", "$1"); exclude = exclude.replaceFirst("[<]po[|](.*)[>](.*)", "$2").replaceAll("[~]", "").replace('/', File.separatorChar); try { IJavaProject javaProject = JavaModelManager.getJavaModelManager().getJavaModel() .getJavaProject(javaProjectName); if (javaProject != null) { String projectOutput = javaProject.getOutputLocation().toOSString(); exclude = projectOutput + File.separatorChar + exclude; } } catch (JavaModelException e) { e.printStackTrace(); } absPath = absProjectPath(root, exclude); } else if (exclude.startsWith("<cl|")) { exclude = exclude.replaceFirst("[<]cl[|](.*)[>]", "$1/").replaceAll("[~]", "").replace('/', File.separatorChar); absPath = exclude; } else if (exclude.startsWith("<jar|")) { exclude = exclude.replaceFirst("[<]jar[|](.*)[>]", "$1"); // absolute path is unknown here, but the check for excudes // recognises jars to exclude without path absPath = exclude; } if (absPath.endsWith(File.separator)) { absPath = absPath.substring(0, absPath.length() - 1); } result.add(absPath); } } return result; }
From source file:net.sf.fjep.fatjar.popup.actions.BuildFatJar.java
License:Open Source License
private void getClassesDir(IJavaProject jproject, Vector classesDirs) { IProject project = jproject.getProject(); IWorkspaceRoot workspaceRoot = project.getWorkspace().getRoot(); String outputDir = null;/* w ww.j a v a 2 s. c o m*/ try { outputDir = absProjectPath(workspaceRoot, relPath(jproject.getOutputLocation())); } catch (JavaModelException e) { e.printStackTrace(); } if (!classesDirs.contains(outputDir)) classesDirs.add(outputDir); }
From source file:net.sf.j2s.ui.actions.UnitJavaScriptUtil.java
License:Open Source License
protected static String getRelativeJSPath(ICompilationUnit unit) { if (unit == null) { return null; }/*from w ww . jav a2s .c o m*/ IJavaProject javaProject = unit.getJavaProject(); if (javaProject != null) { String relativePath = null; IJavaElement parent = unit.getParent(); while (parent != null) { if (parent instanceof PackageFragmentRoot) { relativePath = unit.getPath().toPortableString() .substring(parent.getPath().toPortableString().length()); break; } parent = parent.getParent(); } IPath outputLocation = null; try { outputLocation = javaProject.getOutputLocation(); } catch (JavaModelException e) { e.printStackTrace(); } if (outputLocation != null && relativePath != null) { relativePath = outputLocation + relativePath.substring(0, relativePath.lastIndexOf('.')) + ".js"; return relativePath; } } return null; }
From source file:net.sf.j2s.ui.launching.J2SClasspathOptionTab.java
License:Open Source License
public void initializeFrom(ILaunchConfiguration configuration) { setDirty(false);//from w w w .jav a2 s . c o m this.fLaunchConfiguration = configuration; try { IJavaModel javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); String projectName = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null); if ((projectName == null) || (projectName.trim().length() < 1)) { return; } IJavaProject javaProject = javaModel.getJavaProject(projectName); if ((javaProject == null) || !javaProject.exists()) { return; } IProject project = javaProject.getProject(); String prjFolder = project.getLocation().toOSString(); File workingDir = new File(prjFolder); String path = javaProject.getOutputLocation().toString(); int idx = path.indexOf('/', 2); String relativePath = null; if (idx != -1) { relativePath = path.substring(idx + 1); } File j2sFile = new File(workingDir, ".j2s"); String classpath = configuration.getAttribute(IJ2SLauchingConfiguration.J2S_CLASS_PATH, (String) null); String abandonClasspath = configuration.getAttribute(IJ2SLauchingConfiguration.J2S_ABANDON_CLASS_PATH, (String) null); if ((classpath == null || classpath.trim().length() == 0) && (abandonClasspath == null || abandonClasspath.trim().length() == 0)) { configPage.initConfigPage(j2sFile); } else { if (relativePath == null) { relativePath = ""; } String propStr = "j2s.compiler.status=enable\r\nj2s.output.path=" + relativePath + "\r\nj2s.resources.list=" + classpath + "\r\nj2s.abandoned.resources.list=" + abandonClasspath; configPage.initConfigPage(j2sFile, new ByteArrayInputStream(propStr.getBytes())); } } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } }