List of usage examples for org.eclipse.jdt.core IJavaProject getOutputLocation
IPath getOutputLocation() throws JavaModelException;
From source file:org.objectstyle.wolips.jrebel.utils.WOProjectClassLoader.java
License:BSD License
private void addURLs(IJavaProject javaProject, boolean exportsOnly) { if (!javaProjects.contains(javaProject)) { javaProjects.add(javaProject);/* ww w. j a v a 2 s.c o m*/ try { // Add default output location addURL(javaProject.getOutputLocation()); // Add each classpath entry IClasspathEntry[] classpathEntries = javaProject.getResolvedClasspath(true); for (IClasspathEntry classpathEntry : classpathEntries) { if (classpathEntry.isExported() || !exportsOnly) { switch (classpathEntry.getEntryKind()) { // Recurse on projects case IClasspathEntry.CPE_PROJECT: IProject project = javaProject.getProject().getWorkspace().getRoot() .getProject(classpathEntry.getPath().toString()); IJavaProject javaProj = JavaCore.create(project); if (javaProj != null) { addURLs(javaProj, true); } break; // Library case IClasspathEntry.CPE_LIBRARY: addURL(classpathEntry); break; // Only Source entries with custom output location need to be added case IClasspathEntry.CPE_SOURCE: IPath outputLocation = classpathEntry.getOutputLocation(); if (outputLocation != null) { addURL(outputLocation); } break; // Variable and Container entries should not be happening, because // we've asked for resolved entries. case IClasspathEntry.CPE_VARIABLE: case IClasspathEntry.CPE_CONTAINER: break; } } } } catch (JavaModelException e) { e.printStackTrace(); // log.debug("MalformedURLException occurred: " + e.getLocalizedMessage(),e); } } }
From source file:org.objectstyle.wolips.target.TargetBuilder.java
License:Open Source License
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { State buildState;// ww w . j a va 2 s . c o m String buldStateKey; IProject[] result = null; IProject project = getProject(); List targets = targets(); if (targets == null) return null; IJavaProject javaProject = JavaCore.create(project); IPath projectOutputLocation = javaProject.getOutputLocation(); IClasspathEntry[] projectClasspath = javaProject.getRawClasspath(); _problemMarkers = new HashMap(); TargetBuilderPlugin plugin = TargetBuilderPlugin.getDefault(); try { for (int i = 0; i < targets.size(); i++) { BuildTarget target = (BuildTarget) targets.get(i); buldStateKey = project.getName() + "/" + target.name(); javaProject.setOutputLocation(target.outputLocation(), monitor); javaProject.setRawClasspath(target.classPathEntries(), monitor); buildState = plugin.buildStateForKey(buldStateKey); JavaModelManager.getJavaModelManager().setLastBuiltState(project, buildState); result = super.build(kind, args, monitor); buildState = (State) JavaModelManager.getJavaModelManager().getLastBuiltState(project, monitor); plugin.setBuildStateForKey(buildState, buldStateKey); registerProblemMarkers(JavaBuilder.getProblemsFor(getProject())); // cancelBuildOnErrors(javaProject); } } finally { javaProject.setOutputLocation(projectOutputLocation, monitor); javaProject.setRawClasspath(projectClasspath, monitor); updateProblemMarkers(); cancelBuildOnErrors(); } return result; }
From source file:org.openoffice.ide.eclipse.java.JavaProjectHandler.java
License:LGPL
/** * {@inheritDoc}/* ww w . j a v a2 s.com*/ */ public IFolder[] getBinFolders(IUnoidlProject pUnoidlProject) { ArrayList<IFolder> folders = new ArrayList<IFolder>(); IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot(); IProject prj = workspace.getProject(pUnoidlProject.getName()); IJavaProject javaPrj = JavaCore.create(prj); try { folders.add(workspace.getFolder(javaPrj.getOutputLocation())); IClasspathEntry[] entries = javaPrj.getRawClasspath(); for (IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getOutputLocation() != null) { folders.add(workspace.getFolder(entry.getOutputLocation())); } } } catch (JavaModelException e) { } return folders.toArray(new IFolder[folders.size()]); }
From source file:org.ow2.chameleon.eclipse.ipojo.builder.IPojoBuilder.java
License:Apache License
/** * Retrieves the Java project output path * /*from w ww . j a v a2 s. com*/ * @return The Java project output path * @throws CoreException * An error occurred while retrieving project informations */ protected IPath getProjectOutputPath() throws CoreException { final IJavaProject javaProject = (IJavaProject) getProject().getNature(JavaCore.NATURE_ID); return javaProject.getOutputLocation(); }
From source file:org.ow2.chameleon.eclipse.ipojo.core.EclipseResourceStore.java
License:Apache License
/** * Prepares the resource store/* w ww.j a va 2 s .c o m*/ * * @param aProject * An iPOJO Java project * @throws CoreException * The project is not of Java nature */ public EclipseResourceStore(final IProject aProject) throws CoreException { pProject = aProject; pWorkspaceRoot = pProject.getWorkspace().getRoot(); // Get the output location final IJavaProject pJavaProject = (IJavaProject) aProject.getNature(JavaCore.NATURE_ID); pOutputLocation = pJavaProject.getOutputLocation(); }
From source file:org.ow2.chameleon.eclipse.ipojo.exporter.core.BundleExporter.java
License:Apache License
/** * Prepares the project output files mapping for a JAR output, based on the * Java project output folder/* w w w . j a v a 2 s . c o m*/ * * @param aJavaProject * A Java project (JDT) * @param aJarEntriesMapping * A map to populate with found files * @throws CoreException */ protected void prepareProjectFilesList(final IJavaProject aJavaProject, final Map<IFile, String> aJarEntriesMapping) throws CoreException { try { // Get the project output folder final IPath outputLocation = aJavaProject.getOutputLocation(); final IFolder outputFolder = pWorkspaceRoot.getFolder(outputLocation); // Look for any file in this folder visitFolder(outputLocation, outputFolder, aJarEntriesMapping); } catch (final JavaModelException e) { IPojoExporterPlugin.logWarning(MessageFormat.format("Error reading the project model of {0}", aJavaProject.getProject().getName()), e); } }
From source file:org.rascalmpl.eclipse.nature.ProjectEvaluatorFactory.java
License:Open Source License
private void collectClassPathForProject(IProject project, List<URL> classPath, List<String> compilerClassPath, Evaluator parser) {/*from ww w . j a va 2 s . c o m*/ try { if (!project.hasNature(JavaCore.NATURE_ID)) { for (IProject ref : project.getReferencedProjects()) { collectClassPathForProject(ref, classPath, compilerClassPath, parser); } } else { IJavaProject jProject = JavaCore.create(project); IPath binFolder = jProject.getOutputLocation(); String binLoc = project.getLocation() + "/" + binFolder.removeFirstSegments(1).toString(); compilerClassPath.add(binLoc); URL binURL = new URL("file", "", binLoc + "/"); parser.addClassLoader(new URLClassLoader(new URL[] { binURL }, getClass().getClassLoader())); classPath.add(binURL); if (!jProject.isOpen()) { return; } IClasspathEntry[] entries = jProject.getResolvedClasspath(true); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: if (entry.getPath().segment(0).equals(project.getName())) { String file = project.getLocation() + "/" + entry.getPath().removeFirstSegments(1).toString(); URL url = new URL("file", "", file); if (!classPath.contains(url)) { classPath.add(url); compilerClassPath.add(file); } } else { URL url = new URL("file", "", entry.getPath().toString()); if (!classPath.contains(url)) { classPath.add(url); compilerClassPath.add(entry.getPath().toString()); } } break; case IClasspathEntry.CPE_PROJECT: collectClassPathForProject( (IProject) project.getWorkspace().getRoot().findMember(entry.getPath()), classPath, compilerClassPath, parser); break; } } } } catch (CoreException e) { Activator.getInstance().logException("failed to configure classpath", e); } catch (MalformedURLException e) { Activator.getInstance().logException("failed to configure classpath", e); } }
From source file:org.robovm.eclipse.internal.ib.IBIntegratorManager.java
License:Open Source License
private LinkedHashSet<File> getOutputLocations(IJavaProject javaProject) throws JavaModelException { LinkedHashSet<File> result = new LinkedHashSet<>(); IProject project = javaProject.getProject(); if (javaProject.getOutputLocation() != null) { File f = project.getFile(javaProject.getOutputLocation().removeFirstSegments(1)).getLocation().toFile(); if (f.exists()) { result.add(f);//w ww .j a va 2 s . com } } for (IClasspathEntry cpe : javaProject.getRawClasspath()) { if (cpe.getOutputLocation() != null) { File f = project.getFile(cpe.getOutputLocation().removeFirstSegments(1)).getLocation().toFile(); if (f.exists()) { result.add(f); } } } return result; }
From source file:org.savara.tools.scenario.designer.simulate.ScenarioSimulationLauncher.java
License:Apache License
/** * This method derives the classpath required to run the * ScenarioTester utility./* www .j av a 2s . c o m*/ * * @param configuration The launch configuation * @return The list of classpath entries */ public String[] getClasspath(ILaunchConfiguration configuration) { String[] ret = null; java.util.Vector<String> classpathEntries = new java.util.Vector<String>(); // Add classpath entry for current Java project String projnames = null; try { projnames = configuration.getAttribute(ScenarioSimulationLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); String[] projname = projnames.split(","); java.util.List<String> outputPaths = new java.util.Vector<String>(); for (int n = 0; n < projname.length; n++) { try { if (logger.isLoggable(Level.FINE)) { logger.fine("Building classpath for project: " + projname[n]); } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projname[n]); IJavaProject jproject = JavaCore.create(project); // Add output location IPath outputLocation = jproject.getOutputLocation(); IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(outputLocation); String path = folder.getLocation().toString(); outputPaths.add(path); // Add other libraries to the classpath IClasspathEntry[] curclspath = jproject.getRawClasspath(); for (int i = 0; curclspath != null && i < curclspath.length; i++) { if (curclspath[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(curclspath[i].getPath()); if (file.exists()) { // Library is within the workspace classpathEntries.add(file.getLocation().toString()); } else { // Assume library is external to workspace classpathEntries.add(curclspath[i].getPath().toString()); } } else if (curclspath[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER) { // Container's not currently handled - but // problem need to retrieve from project and // iterate over container entries } } } catch (Exception e) { // TODO: report error } } if (outputPaths.size() == 1) { classpathEntries.add(outputPaths.get(0)); } else if (outputPaths.size() > 0) { // Need to merge output folders into one location java.io.File dir = new java.io.File( System.getProperty("java.io.tmpdir") + java.io.File.separatorChar + "savara" + java.io.File.separatorChar + "simulation" + System.currentTimeMillis()); dir.deleteOnExit(); dir.mkdirs(); classpathEntries.add(dir.getAbsolutePath()); for (String path : outputPaths) { copy(new java.io.File(path), dir); } } } catch (Exception ex) { ex.printStackTrace(); } java.util.List<Bundle> bundles = getBundles(); for (Bundle b : bundles) { buildClassPath(b, classpathEntries); } ret = new String[classpathEntries.size()]; classpathEntries.copyInto(ret); if (logger.isLoggable(Level.FINEST)) { logger.finest("Scenario Simulation Classpath:"); for (int i = 0; i < ret.length; i++) { logger.finest(" [" + i + "] " + ret[i]); } } return (ret); }
From source file:org.seasar.dblauncher.preferences.impl.H2PreferencesImpl.java
License:Apache License
public static String getDefaultBaseDir(IProject project) { String result = ""; try {// w ww . j a v a2s . c o m if (project != null) { IJavaProject jp = JavaCore.create(project); IPath p = jp.getOutputLocation(); IFolder f = project.getParent().getFolder(p.append("data")); if (f.exists() == false) { f.create(true, true, null); } IPath data = f.getFullPath(); result = data.toString(); } } catch (Exception e) { DbLauncherPlugin.log(e); } return result; }