use of org.eclipse.xtext.xtext.wizard.BinaryFile in project xtext-core by eclipse.
the class CliProjectsCreator method createProject.
public void createProject(final ProjectDescriptor project) {
String _location = project.getLocation();
final File projectRoot = new File(_location);
projectRoot.mkdirs();
final Consumer<AbstractFile> _function = (AbstractFile it) -> {
try {
String _pathFor = project.getConfig().getSourceLayout().getPathFor(it.getOutlet());
String _plus = (_pathFor + "/");
String _relativePath = it.getRelativePath();
final String projectRelativePath = (_plus + _relativePath);
final File file = new File(projectRoot, projectRelativePath);
file.getParentFile().mkdirs();
boolean _matched = false;
if (it instanceof TextFile) {
_matched = true;
final String normalizedContent = ((TextFile) it).getContent().replace(Strings.newLine(), this.lineDelimiter);
Files.write(normalizedContent, file, project.getConfig().getEncoding());
}
if (!_matched) {
if (it instanceof BinaryFile) {
_matched = true;
Files.write(Resources.toByteArray(((BinaryFile) it).getContent()), file);
}
}
boolean _isExecutable = it.isExecutable();
if (_isExecutable) {
file.setExecutable(true);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
project.getFiles().forEach(_function);
final Consumer<String> _function_1 = (String it) -> {
new File(projectRoot, it).mkdirs();
};
project.getSourceFolders().forEach(_function_1);
}
use of org.eclipse.xtext.xtext.wizard.BinaryFile in project xtext-core by eclipse.
the class ParentProjectDescriptor method getFiles.
@Override
public Iterable<? extends AbstractFile> getFiles() {
final ArrayList<AbstractFile> files = CollectionLiterals.<AbstractFile>newArrayList();
Iterable<? extends AbstractFile> _files = super.getFiles();
Iterables.<AbstractFile>addAll(files, _files);
boolean _needsGradleBuild = this.getConfig().needsGradleBuild();
if (_needsGradleBuild) {
PlainTextFile _file = this.file(Outlet.ROOT, "settings.gradle", this.settingsGradle());
files.add(_file);
PlainTextFile _file_1 = this.file(Outlet.ROOT, "gradle/source-layout.gradle", this.sourceLayoutGradle());
files.add(_file_1);
PlainTextFile _file_2 = this.file(Outlet.ROOT, "gradle/maven-deployment.gradle", this.mavenDeploymentGradle());
files.add(_file_2);
boolean _isNeedsGradleWrapper = this.getConfig().isNeedsGradleWrapper();
if (_isNeedsGradleWrapper) {
PlainTextFile _file_3 = this.file(Outlet.ROOT, "gradlew", this.loadResource("gradlew/gradlew"), true);
files.add(_file_3);
PlainTextFile _file_4 = this.file(Outlet.ROOT, "gradlew.bat", this.loadResource("gradlew/gradlew.bat"));
files.add(_file_4);
PlainTextFile _file_5 = this.file(Outlet.ROOT, "gradle/wrapper/gradle-wrapper.properties", this.loadResource("gradlew/gradle-wrapper.properties"));
files.add(_file_5);
BinaryFile _binaryFile = this.binaryFile(Outlet.ROOT, "gradle/wrapper/gradle-wrapper.jar", this.getClass().getClassLoader().getResource("gradlew/gradle-wrapper.jar"));
files.add(_binaryFile);
}
}
return files;
}
Aggregations