use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.
the class FilteredResourceRootDescriptor method createFileFilter.
@NotNull
@Override
public FileFilter createFileFilter() {
final JpsProject project = getTarget().getModule().getProject();
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
return file -> !excludes.isExcluded(file) && configuration.isResourceFile(file, getRootFile());
}
use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.
the class ModuleBuildTarget method writeConfiguration.
@Override
public void writeConfiguration(ProjectDescriptor pd, PrintWriter out) {
final JpsModule module = getModule();
int fingerprint = getDependenciesFingerprint();
for (JavaSourceRootDescriptor root : pd.getBuildRootIndex().getTargetRoots(this, null)) {
fingerprint += FileUtil.fileHashCode(root.getRootFile());
}
final LanguageLevel level = JpsJavaExtensionService.getInstance().getLanguageLevel(module);
if (level != null) {
fingerprint += level.name().hashCode();
}
final JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(module.getProject());
final String bytecodeTarget = config.getByteCodeTargetLevel(module.getName());
if (bytecodeTarget != null) {
fingerprint += bytecodeTarget.hashCode();
}
final CompilerEncodingConfiguration encodingConfig = pd.getEncodingConfiguration();
final String encoding = encodingConfig.getPreferredModuleEncoding(module);
if (encoding != null) {
fingerprint += encoding.hashCode();
}
out.write(Integer.toHexString(fingerprint));
}
use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.
the class ModuleBuildTarget method computeRootDescriptors.
@NotNull
@Override
public List<JavaSourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
List<JavaSourceRootDescriptor> roots = new ArrayList<>();
JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
Iterable<ExcludedJavaSourceRootProvider> excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class);
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myModule.getProject());
roots_loop: for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> sourceRoot : myModule.getSourceRoots(type)) {
if (index.isExcludedFromModule(sourceRoot.getFile(), myModule)) {
continue;
}
for (ExcludedJavaSourceRootProvider provider : excludedRootProviders) {
if (provider.isExcludedFromCompilation(myModule, sourceRoot)) {
continue roots_loop;
}
}
final String packagePrefix = sourceRoot.getProperties().getPackagePrefix();
// consider annotation processors output for generated sources, if contained under some source root
Set<File> excludes = computeRootExcludes(sourceRoot.getFile(), index);
final ProcessorConfigProfile profile = compilerConfig.getAnnotationProcessingProfile(myModule);
if (profile.isEnabled()) {
final File outputDir = ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir(myModule, JavaSourceRootType.TEST_SOURCE == sourceRoot.getRootType(), profile);
if (outputDir != null && FileUtil.isAncestor(sourceRoot.getFile(), outputDir, true)) {
excludes = ContainerUtil.newTroveSet(FileUtil.FILE_HASHING_STRATEGY, excludes);
excludes.add(outputDir);
}
}
roots.add(new JavaSourceRootDescriptor(sourceRoot.getFile(), this, false, false, packagePrefix, excludes));
}
return roots;
}
use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-plugins by JetBrains.
the class FlexResourceBuildTarget method writeConfiguration.
@Override
public void writeConfiguration(ProjectDescriptor pd, final PrintWriter out) {
out.println("Module: " + getModule().getName());
for (JpsFlexBuildConfiguration bc : getModule().getProperties().getBuildConfigurations()) {
if (!bc.isSkipCompile() && FlexCommonUtils.canHaveResourceFiles(bc.getNature()) && bc.getCompilerOptions().getResourceFilesMode() != JpsFlexCompilerOptions.ResourceFilesMode.None) {
out.print("BC: " + bc.getName());
out.print(", output folder: " + PathUtilRt.getParentPath(bc.getActualOutputFilePath()));
out.print(", mode: " + bc.getCompilerOptions().getResourceFilesMode());
if (bc.getCompilerOptions().getResourceFilesMode() == JpsFlexCompilerOptions.ResourceFilesMode.ResourcePatterns) {
final JpsJavaCompilerConfiguration c = JpsJavaExtensionService.getInstance().getCompilerConfiguration(getModule().getProject());
if (c != null) {
out.print(", patterns: " + StringUtil.join(c.getResourcePatterns(), " "));
}
}
out.println();
}
}
}
use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.
the class GreclipseBuilder method build.
@Override
public ExitCode build(final CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
if (!useGreclipse(context))
return ModuleLevelBuilder.ExitCode.NOTHING_DONE;
try {
final List<File> toCompile = myHelper.collectChangedFiles(context, dirtyFilesHolder, false, true, Ref.create(false));
if (toCompile.isEmpty()) {
return ExitCode.NOTHING_DONE;
}
Map<ModuleBuildTarget, String> outputDirs = GroovyBuilder.getCanonicalModuleOutputs(context, chunk, this);
if (outputDirs == null) {
return ExitCode.ABORT;
}
JpsProject project = context.getProjectDescriptor().getProject();
GreclipseSettings greclipseSettings = GreclipseJpsCompilerSettings.getSettings(project);
if (greclipseSettings == null) {
String message = "Compiler settings component not initialized for " + project;
LOG.error(message);
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, message));
return ExitCode.ABORT;
}
ClassLoader loader = createGreclipseLoader(greclipseSettings.greclipsePath);
if (loader == null) {
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, "Invalid jar path in the compiler settings: '" + greclipseSettings.greclipsePath + "'"));
return ExitCode.ABORT;
}
final JpsJavaExtensionService javaExt = JpsJavaExtensionService.getInstance();
final JpsJavaCompilerConfiguration compilerConfig = javaExt.getCompilerConfiguration(project);
assert compilerConfig != null;
final Set<JpsModule> modules = chunk.getModules();
ProcessorConfigProfile profile = null;
if (modules.size() == 1) {
profile = compilerConfig.getAnnotationProcessingProfile(modules.iterator().next());
} else {
String message = JavaBuilder.validateCycle(chunk, javaExt, compilerConfig, modules);
if (message != null) {
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, message));
return ExitCode.ABORT;
}
}
String mainOutputDir = outputDirs.get(chunk.representativeTarget());
final List<String> args = createCommandLine(context, chunk, toCompile, mainOutputDir, profile, greclipseSettings);
if (Utils.IS_TEST_MODE || LOG.isDebugEnabled()) {
LOG.debug("Compiling with args: " + args);
}
Boolean notified = COMPILER_VERSION_INFO.get(context);
if (notified != Boolean.TRUE) {
context.processMessage(new CompilerMessage("", BuildMessage.Kind.INFO, "Using Groovy-Eclipse to compile Java & Groovy sources"));
COMPILER_VERSION_INFO.set(context, Boolean.TRUE);
}
context.processMessage(new ProgressMessage("Compiling java & groovy [" + chunk.getPresentableShortName() + "]"));
StringWriter out = new StringWriter();
StringWriter err = new StringWriter();
HashMap<String, List<String>> outputMap = ContainerUtil.newHashMap();
boolean success = performCompilation(args, out, err, outputMap, context, chunk);
List<GroovycOutputParser.OutputItem> items = ContainerUtil.newArrayList();
for (String src : outputMap.keySet()) {
//noinspection ConstantConditions
for (String classFile : outputMap.get(src)) {
items.add(new GroovycOutputParser.OutputItem(FileUtil.toSystemIndependentName(mainOutputDir + classFile), FileUtil.toSystemIndependentName(src)));
}
}
MultiMap<ModuleBuildTarget, GroovycOutputParser.OutputItem> successfullyCompiled = myHelper.processCompiledFiles(context, chunk, outputDirs, mainOutputDir, items);
EclipseOutputParser parser = new EclipseOutputParser(getPresentableName(), chunk);
List<CompilerMessage> messages = ContainerUtil.concat(parser.parseMessages(out.toString()), parser.parseMessages(err.toString()));
boolean hasError = false;
for (CompilerMessage message : messages) {
if (message.getKind() == BuildMessage.Kind.ERROR) {
hasError = true;
}
context.processMessage(message);
}
if (!success && !hasError) {
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, "Compilation failed"));
}
myHelper.updateDependencies(context, toCompile, successfullyCompiled, new DefaultOutputConsumer(outputConsumer), this);
return ExitCode.OK;
} catch (Exception e) {
throw new ProjectBuildException(e);
}
}
Aggregations