Search in sources :

Example 1 with TextFile

use of org.eclipse.xtext.xtext.wizard.TextFile 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);
}
Also used : AbstractFile(org.eclipse.xtext.xtext.wizard.AbstractFile) TextFile(org.eclipse.xtext.xtext.wizard.TextFile) BinaryFile(org.eclipse.xtext.xtext.wizard.BinaryFile) TextFile(org.eclipse.xtext.xtext.wizard.TextFile) AbstractFile(org.eclipse.xtext.xtext.wizard.AbstractFile) File(java.io.File) BinaryFile(org.eclipse.xtext.xtext.wizard.BinaryFile)

Example 2 with TextFile

use of org.eclipse.xtext.xtext.wizard.TextFile in project xtext-core by eclipse.

the class ProjectDescriptor method getFiles.

public Iterable<? extends AbstractFile> getFiles() {
    final List<TextFile> files = CollectionLiterals.<TextFile>newArrayList();
    boolean _isEclipsePluginProject = this.isEclipsePluginProject();
    if (_isEclipsePluginProject) {
        PlainTextFile _file = this.file(Outlet.META_INF, "MANIFEST.MF", this.manifest());
        files.add(_file);
        PlainTextFile _file_1 = this.file(Outlet.ROOT, "build.properties", this.buildProperties());
        files.add(_file_1);
    }
    boolean _isEclipseFeatureProject = this.isEclipseFeatureProject();
    if (_isEclipseFeatureProject) {
        PlainTextFile _file_2 = this.file(Outlet.ROOT, "build.properties", this.buildProperties());
        files.add(_file_2);
    }
    if ((this.config.needsGradleBuild() && this.isPartOfGradleBuild())) {
        GradleBuildFile _buildGradle = this.buildGradle();
        files.add(_buildGradle);
    }
    if ((this.config.needsMavenBuild() && this.isPartOfMavenBuild())) {
        PomFile _pom = this.pom();
        files.add(_pom);
    }
    return files;
}
Also used : GradleBuildFile(org.eclipse.xtext.xtext.wizard.GradleBuildFile) PlainTextFile(org.eclipse.xtext.xtext.wizard.PlainTextFile) PomFile(org.eclipse.xtext.xtext.wizard.PomFile) TextFile(org.eclipse.xtext.xtext.wizard.TextFile) PlainTextFile(org.eclipse.xtext.xtext.wizard.PlainTextFile)

Aggregations

TextFile (org.eclipse.xtext.xtext.wizard.TextFile)2 File (java.io.File)1 AbstractFile (org.eclipse.xtext.xtext.wizard.AbstractFile)1 BinaryFile (org.eclipse.xtext.xtext.wizard.BinaryFile)1 GradleBuildFile (org.eclipse.xtext.xtext.wizard.GradleBuildFile)1 PlainTextFile (org.eclipse.xtext.xtext.wizard.PlainTextFile)1 PomFile (org.eclipse.xtext.xtext.wizard.PomFile)1