use of org.eclipse.jdt.core.IClasspathAttribute in project xtext-eclipse by eclipse.
the class JavaProjectFactory method enhanceProject.
@Override
protected void enhanceProject(IProject project, SubMonitor monitor, Shell shell) throws CoreException {
super.enhanceProject(project, monitor, shell);
if (builderIds.contains(JavaCore.BUILDER_ID)) {
SubMonitor subMonitor = SubMonitor.convert(monitor, 10);
try {
subMonitor.subTask(Messages.JavaProjectFactory_ConfigureJavaProject + projectName);
IJavaProject javaProject = JavaCore.create(project);
List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
for (final IProject referencedProject : project.getReferencedProjects()) {
final IClasspathEntry referencedProjectClasspathEntry = JavaCore.newProjectEntry(referencedProject.getFullPath());
classpathEntries.add(referencedProjectClasspathEntry);
}
for (final String folderName : getFolders()) {
final IFolder sourceFolder = project.getFolder(folderName);
String outputFolderName = sourceFolderOutputs.get(folderName);
final IClasspathEntry srcClasspathEntry = JavaCore.newSourceEntry(sourceFolder.getFullPath(), ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, outputFolderName == null ? null : project.getFolder(outputFolderName).getFullPath(), testSourceFolders.contains(folderName) ? new IClasspathAttribute[] { JavaCore.newClasspathAttribute("test", "true") } : new IClasspathAttribute[0]);
classpathEntries.add(srcClasspathEntry);
}
classpathEntries.addAll(extraClasspathEntries);
IClasspathEntry defaultJREContainerEntry = getJreContainerEntry();
classpathEntries.add(defaultJREContainerEntry);
addMoreClasspathEntriesTo(classpathEntries);
javaProject.setRawClasspath(classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]), subMonitor.newChild(1));
javaProject.setOutputLocation(new Path("/" + project.getName() + "/" + defaultOutput), subMonitor.newChild(1));
String executionEnvironmentId = JavaRuntime.getExecutionEnvironmentId(defaultJREContainerEntry.getPath());
if (executionEnvironmentId != null) {
BuildPathSupport.setEEComplianceOptions(javaProject, executionEnvironmentId, null);
}
} catch (JavaModelException e) {
logger.error(e.getMessage(), e);
}
}
}
use of org.eclipse.jdt.core.IClasspathAttribute in project xtext-eclipse by eclipse.
the class XtextProjectCreator method configureJavaProject.
private void configureJavaProject(ProjectDescriptor descriptor, JavaProjectFactory factory) {
configurePlainProject(descriptor, factory);
factory.addProjectNatures(XtextProjectHelper.NATURE_ID);
factory.addBuilderIds(XtextProjectHelper.BUILDER_ID);
factory.addProjectNatures(JavaCore.NATURE_ID);
factory.addBuilderIds(JavaCore.BUILDER_ID);
for (SourceFolderDescriptor sourceFolder : descriptor.getSourceFolders()) {
String output = sourceFolder.isTest() ? (needsM2eIntegration(descriptor) ? "target/test-classes" : "test-bin") : null;
factory.addSourceFolder(sourceFolder.getPath(), output, sourceFolder.isTest());
}
factory.setJreContainerEntry(JREContainerProvider.getJREContainerEntry(descriptor.getBree()));
if (needsM2eIntegration(descriptor)) {
factory.setDefaultOutput("target/classes");
if (!descriptor.isEclipsePluginProject()) {
factory.addClasspathEntries(JavaCore.newContainerEntry(new Path("org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER")));
}
}
if (needsBuildshipIntegration(descriptor) && !descriptor.isEclipsePluginProject()) {
factory.addClasspathEntries(JavaCore.newContainerEntry(new Path("org.eclipse.buildship.core.gradleclasspathcontainer")));
}
if (requiresJUnitLibContainer(descriptor)) {
JUnitVersion junitVersion = descriptor.getConfig().getJunitVersion();
factory.addClasspathEntries(JavaCore.newContainerEntry(new Path("org.eclipse.jdt.junit.JUNIT_CONTAINER").append(Integer.toString(junitVersion.getVersion())), new IAccessRule[0], new IClasspathAttribute[] { JavaCore.newClasspathAttribute("test", "true") }, false));
}
}
Aggregations