use of org.eclipse.xtext.xtext.wizard.SourceFolderDescriptor in project xtext-core by eclipse.
the class CliProjectsCreator method createProject.
public void createProject(ProjectDescriptor project) {
Preconditions.checkNotNull(lineDelimiter, "lineDelimiter may not be null");
try {
File projectRoot = new File(project.getLocation());
projectRoot.mkdirs();
for (AbstractFile f : project.getFiles()) {
String outletPath = project.getConfig().getSourceLayout().getPathFor(f.getOutlet());
String projectRelativePath = outletPath + "/" + f.getRelativePath();
File file = new File(projectRoot, projectRelativePath);
file.getParentFile().mkdirs();
if (f instanceof TextFile) {
String normalizedContent = ((TextFile) f).getContent().replace(Strings.newLine(), lineDelimiter);
Files.asCharSink(file, project.getConfig().getEncoding()).write(normalizedContent);
} else if (f instanceof BinaryFile) {
Files.write(Resources.toByteArray(((BinaryFile) f).getContent()), file);
}
if (f.isExecutable()) {
file.setExecutable(true);
}
}
for (SourceFolderDescriptor folder : project.getSourceFolders()) {
new File(projectRoot, folder.getPath()).mkdirs();
}
} catch (IOException e) {
throw Exceptions.sneakyThrow(e);
}
}
use of org.eclipse.xtext.xtext.wizard.SourceFolderDescriptor 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