use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.
the class RmicCompilerOptionsSerializer method loadExtensionWithDefaultSettings.
@Override
public void loadExtensionWithDefaultSettings(@NotNull JpsProject project) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
configuration.setCompilerOptions(myCompilerId, new RmicCompilerOptions());
}
use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project android by JetBrains.
the class AndroidBuilderTest method testGeneratedSources.
public void testGeneratedSources() throws Exception {
final MyExecutor executor = new MyExecutor("com.example.simple");
final JpsModule module = setUpSimpleAndroidStructure(new String[] { "src", "gen" }, executor, null).getFirst();
rebuildAll();
checkBuildLog(executor, "expected_log");
checkMakeUpToDate(executor);
change(getProjectPath("gen/com/example/simple/R.java"), AndroidCommonUtils.AUTOGENERATED_JAVA_FILE_HEADER + "\n\n" + "package com.example.simple;\n" + "public class R {}");
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_1");
assertCompiled(JavaBuilder.BUILDER_NAME, "targets/java-production/module/android/copied_sources/com/example/simple/MyGeneratedClass.java");
checkMakeUpToDate(executor);
change(getProjectPath("gen/com/example/simple/R.java"));
checkMakeUpToDate(executor);
change(getProjectPath("gen/com/example/simple/MyGeneratedClass.java"));
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_3");
assertCompiled(JavaBuilder.BUILDER_NAME, "targets/java-production/module/android/copied_sources/com/example/simple/MyGeneratedClass.java");
checkMakeUpToDate(executor);
change(getProjectPath("gen/com/example/simple/MyGeneratedClass.java"), AndroidCommonUtils.AUTOGENERATED_JAVA_FILE_HEADER + "\n\n" + "package com.example.simple;\n" + "public class MyGeneratedClass {}");
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_4");
assertCompiled(JavaBuilder.BUILDER_NAME);
checkMakeUpToDate(executor);
change(getProjectPath("gen/com/example/simple/MyGeneratedClass.java"), "package com.example.simple;\n" + "public class MyGeneratedClass {}");
change(getProjectPath("src/com/example/simple/MyActivity.java"), "package com.example.simple;\n" + "import android.app.Activity;\n" + "import android.os.Bundle;\n" + "public class MyActivity extends Activity {\n" + " public void onCreate(Bundle savedInstanceState) {\n" + " super.onCreate(savedInstanceState);\n" + " new MyGeneratedClass();" + " }\n" + "}\n");
makeAll().assertSuccessful();
checkBuildLog(executor, "expected_log_5");
assertCompiled(JavaBuilder.BUILDER_NAME, "root/src/com/example/simple/MyActivity.java", "targets/java-production/module/android/copied_sources/com/example/simple/MyGeneratedClass.java");
checkMakeUpToDate(executor);
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myProject);
final ProcessorConfigProfile profile = compilerConfig.getAnnotationProcessingProfile(module);
profile.setEnabled(true);
profile.setOutputRelativeToContentRoot(true);
profile.setGeneratedSourcesDirectoryName("gen", false);
final BuildResult result = makeAll();
result.assertFailed();
final List<BuildMessage> warnMessages = result.getMessages(BuildMessage.Kind.WARNING);
boolean containsForciblyExcludedRootWarn = false;
for (BuildMessage message : warnMessages) {
if (message.getMessageText().endsWith("was forcibly excluded by the IDE, so custom generated files won't be compiled")) {
containsForciblyExcludedRootWarn = true;
}
}
assertTrue(containsForciblyExcludedRootWarn);
}
use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-plugins by JetBrains.
the class FlexResourceBuilder method build.
public void build(@NotNull final FlexResourceBuildTarget target, @NotNull final DirtyFilesHolder<BuildRootDescriptor, FlexResourceBuildTarget> holder, @NotNull final BuildOutputConsumer outputConsumer, @NotNull final CompileContext context) throws ProjectBuildException, IOException {
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(target.getModule().getProject());
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
try {
holder.processDirtyFiles(new FileProcessor<BuildRootDescriptor, FlexResourceBuildTarget>() {
public boolean apply(final FlexResourceBuildTarget target, final File file, final BuildRootDescriptor root) throws IOException {
if (excludes.isExcluded(file))
return true;
final String relativePath = FileUtil.toSystemIndependentName(FileUtil.getRelativePath(root.getRootFile(), file));
if (target.isTests()) {
if (!FlexCommonUtils.isSourceFile(file.getName())) {
final String outputRootUrl = JpsJavaExtensionService.getInstance().getOutputUrl(target.getModule(), target.isTests());
if (outputRootUrl == null)
return true;
final String targetPath = JpsPathUtil.urlToPath(outputRootUrl) + '/' + relativePath;
context.processMessage(new ProgressMessage("Copying " + file.getPath()));
copyResource(context, file, Collections.singleton(targetPath), outputConsumer);
}
} else {
final Collection<String> targetPaths = new ArrayList<>();
for (JpsFlexBuildConfiguration bc : target.getModule().getProperties().getBuildConfigurations()) {
if (bc.isSkipCompile() || !FlexCommonUtils.canHaveResourceFiles(bc.getNature()) || bc.getCompilerOptions().getResourceFilesMode() == JpsFlexCompilerOptions.ResourceFilesMode.None) {
continue;
}
final JpsFlexCompilerOptions.ResourceFilesMode mode = bc.getCompilerOptions().getResourceFilesMode();
if (mode == JpsFlexCompilerOptions.ResourceFilesMode.All && !FlexCommonUtils.isSourceFile(file.getName()) || mode == JpsFlexCompilerOptions.ResourceFilesMode.ResourcePatterns && configuration.isResourceFile(file, root.getRootFile())) {
final String outputFolder = PathUtilRt.getParentPath(bc.getActualOutputFilePath());
targetPaths.add(outputFolder + "/" + relativePath);
}
}
if (!targetPaths.isEmpty()) {
context.processMessage(new ProgressMessage("Copying " + file.getPath()));
copyResource(context, file, targetPaths, outputConsumer);
}
}
return true;
}
});
} catch (Exception e) {
throw new ProjectBuildException(e.getMessage(), e);
}
}
use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.
the class IncProjectBuilder method cleanOutputRoots.
private void cleanOutputRoots(CompileContext context, boolean cleanCaches) throws ProjectBuildException {
final ProjectDescriptor projectDescriptor = context.getProjectDescriptor();
ProjectBuildException ex = null;
try {
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(projectDescriptor.getProject());
final boolean shouldClear = configuration.isClearOutputDirectoryOnRebuild();
if (shouldClear) {
clearOutputs(context);
} else {
for (BuildTarget<?> target : projectDescriptor.getBuildTargetIndex().getAllTargets()) {
context.checkCanceled();
if (context.getScope().isBuildForced(target)) {
clearOutputFilesUninterruptibly(context, target);
}
}
}
} catch (ProjectBuildException e) {
ex = e;
} finally {
if (cleanCaches) {
try {
projectDescriptor.timestamps.getStorage().clean();
} catch (IOException e) {
if (ex == null) {
ex = new ProjectBuildException("Error cleaning timestamps storage", e);
} else {
LOG.info("Error cleaning timestamps storage", e);
}
} finally {
try {
projectDescriptor.dataManager.clean();
} catch (IOException e) {
if (ex == null) {
ex = new ProjectBuildException("Error cleaning compiler storages", e);
} else {
LOG.info("Error cleaning compiler storages", e);
}
} finally {
projectDescriptor.fsState.clearAll();
if (ex != null) {
throw ex;
}
}
}
}
}
}
use of org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration in project intellij-community by JetBrains.
the class ModuleBuildTarget method getOutputRoots.
@NotNull
@Override
public Collection<File> getOutputRoots(CompileContext context) {
Collection<File> result = new SmartList<>();
final File outputDir = getOutputDir();
if (outputDir != null) {
result.add(outputDir);
}
final JpsModule module = getModule();
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(module.getProject());
final ProcessorConfigProfile profile = configuration.getAnnotationProcessingProfile(module);
if (profile.isEnabled()) {
final File annotationOut = ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir(module, isTests(), profile);
if (annotationOut != null) {
result.add(annotationOut);
}
}
return result;
}
Aggregations