use of org.eclipse.jdt.core.IClasspathEntry in project xtext-xtend by eclipse.
the class XbaseEditorOpenClassFileTest method addJarToClassPath.
public IPackageFragmentRoot addJarToClassPath(final IJavaProject jp, final String fileName, final String fileNameOfSource) {
try {
IProject _project = jp.getProject();
Path _path = new Path(fileName);
final IFile jarFile = _project.getFile(_path);
jarFile.create(this.getClass().getResourceAsStream(fileName), true, null);
IFile _xifexpression = null;
if ((fileNameOfSource != null)) {
IFile _xblockexpression = null;
{
IProject _project_1 = jp.getProject();
Path _path_1 = new Path(fileNameOfSource);
final IFile source = _project_1.getFile(_path_1);
source.create(this.getClass().getResourceAsStream(fileNameOfSource), true, null);
_xblockexpression = source;
}
_xifexpression = _xblockexpression;
}
final IFile sourceFile = _xifexpression;
IPath _fullPath = jarFile.getFullPath();
IPath _fullPath_1 = null;
if (sourceFile != null) {
_fullPath_1 = sourceFile.getFullPath();
}
final IClasspathEntry cp = JavaCore.newLibraryEntry(_fullPath, _fullPath_1, null);
JavaProjectSetupUtil.addToClasspath(jp, cp);
return JavaCore.createJarPackageFragmentRootFrom(jarFile);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.jdt.core.IClasspathEntry in project xtext-xtend by eclipse.
the class PerformanceTestProjectSetup method createJavaProject.
public static IJavaProject createJavaProject(final String projectName, String[] projectNatures) {
IProject project = null;
IJavaProject javaProject = null;
try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
project = workspace.getRoot().getProject(projectName);
deleteProject(project);
javaProject = JavaCore.create(project);
IProjectDescription projectDescription = ResourcesPlugin.getWorkspace().newProjectDescription(projectName);
project.create(projectDescription, null);
List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
projectDescription.setNatureIds(projectNatures);
final ICommand java = projectDescription.newCommand();
java.setBuilderName(JavaCore.BUILDER_ID);
final ICommand manifest = projectDescription.newCommand();
manifest.setBuilderName("org.eclipse.pde.ManifestBuilder");
final ICommand schema = projectDescription.newCommand();
schema.setBuilderName("org.eclipse.pde.SchemaBuilder");
projectDescription.setBuildSpec(new ICommand[] { java, manifest, schema });
project.open(null);
project.setDescription(projectDescription, null);
classpathEntries.add(JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5")));
classpathEntries.add(JavaCore.newContainerEntry(new Path("org.eclipse.pde.core.requiredPlugins")));
javaProject.setRawClasspath(classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]), null);
makeJava5Compliant(javaProject);
javaProject.setOutputLocation(new Path("/" + projectName + "/bin"), null);
createManifest(projectName, project);
// project.build(IncrementalProjectBuilder.FULL_BUILD, null);
refreshExternalArchives(javaProject);
refresh(javaProject);
} catch (final Exception exception) {
throw new RuntimeException(exception);
}
return javaProject;
}
use of org.eclipse.jdt.core.IClasspathEntry in project jop by jop-devel.
the class JOPizer method getClassesClasspathEntry.
private IClasspathEntry getClassesClasspathEntry() throws JavaModelException {
IPreferenceStore prefs = JOPUIPlugin.getDefault().getPreferenceStore();
String jopHome = prefs.getString(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME);
IPath jopClasses = new Path(jopHome).append(new Path("java/target/dist/lib/classes.zip"));
IClasspathEntry[] entries = currentProject.getRawClasspath();
for (IClasspathEntry entry : entries) {
if (entry.getPath().equals(jopClasses)) {
return entry;
}
}
return null;
}
use of org.eclipse.jdt.core.IClasspathEntry in project che by eclipse.
the class ClasspathBuilder method addSourceFolders.
private void addSourceFolders(IJavaProject project, List<String> sourceFolders, List<IClasspathEntry> classpathEntries) {
for (String source : sourceFolders) {
IFolder src = project.getProject().getFolder(source);
if (src.exists()) {
IClasspathEntry sourceEntry = JavaCore.newSourceEntry(src.getFullPath());
classpathEntries.add(sourceEntry);
}
}
}
use of org.eclipse.jdt.core.IClasspathEntry in project che by eclipse.
the class PlainJavaInitHandler method initializeClasspath.
@Override
protected void initializeClasspath(IJavaProject javaProject) throws ServerException {
IClasspathEntry[] projectClasspath;
try {
projectClasspath = javaProject.getRawClasspath();
} catch (JavaModelException e) {
LOG.warn("Can't get classpath for: " + javaProject.getProject().getFullPath().toOSString(), e);
throw new ServerException(e);
}
//default classpath
IClasspathEntry[] defaultClasspath = new IClasspathEntry[] { JavaCore.newSourceEntry(javaProject.getPath()) };
if (!Arrays.equals(defaultClasspath, projectClasspath)) {
//classpath is already initialized
return;
}
RegisteredProject project = projectRegistryProvider.get().getProject(javaProject.getPath().toOSString());
List<String> sourceFolders = project.getAttributes().get(Constants.SOURCE_FOLDER);
List<String> library = project.getAttributes().get(LIBRARY_FOLDER);
classpathBuilder.generateClasspath(javaProject, sourceFolders, library);
}
Aggregations