@Override public ExitCode build( CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, OutputConsumer outputConsumer) throws ProjectBuildException, IOException { final IceConfig config = context.getProjectDescriptor().getProject().getContainer().getChild(IceConfig.ROLE); IceConfig iceConfig = config == null ? new IceConfig("") : config; File frameworkHome = JpsPathUtil.urlToFile(iceConfig.getFrameworkHomeUrl()); List<String> includes = new ArrayList<String>(); for (String include : iceConfig.getIncludeUrls()) { includes.add(JpsPathUtil.urlToFile(include).getAbsolutePath()); } final Map<ModuleBuildTarget, List<File>> toCompile = collectChangedFiles(context, dirtyFilesHolder); if (toCompile.isEmpty()) { return ExitCode.NOTHING_DONE; } for (Map.Entry<ModuleBuildTarget, List<File>> e : toCompile.entrySet()) { final ModuleBuildTarget target = e.getKey(); final JpsModule module = target.getModule(); SliceCompilerSettings settings = module.getContainer().getChild(SliceCompilerSettings.ROLE); final SliceCompilerSettings facetConfig = settings == null ? new SliceCompilerSettings() : settings; final List<File> sourceFiles = e.getValue(); List<Target> translators = facetConfig.getComponents(); if (translators.isEmpty()) { context.processMessage( new CompilerMessage( getPresentableName(), BuildMessage.Kind.WARNING, "No valid translators found for module " + module.getName() + ". Check facet configuration.")); continue; } // Translate files for (Target c : translators) { final File outputDir = c.getOutputFile(); if (facetConfig.isCleanOutput()) { try { FileUtils.cleanDirectory(outputDir); } catch (IOException ex) { context.processMessage( new CompilerMessage( getPresentableName(), BuildMessage.Kind.ERROR, "Failed to empty target directory: " + outputDir.getPath() + " . Error: " + ex.getMessage())); return ExitCode.ABORT; } } compileFiles( context, frameworkHome, includes, target, sourceFiles, c.getComponent(), outputDir); } } return ExitCode.OK; }
public static ThriftCompilerOptions getSettings(JpsModule module) { final ThriftCompilerOptions config = module.getContainer().getChild(ROLE); return config == null ? new ThriftCompilerOptions() : config; }