use of org.jetbrains.jps.incremental.messages.CompilerMessage in project android by JetBrains.
the class AndroidManifestMergingBuilder method doManifestMerging.
private static boolean doManifestMerging(AndroidManifestMergingTarget target, CompileContext context, BuildOutputConsumer outputConsumer) throws IOException {
final JpsModule module = target.getModule();
final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(module);
assert extension != null;
assert !extension.isLibrary();
assert extension.isManifestMergingEnabled();
final File outputDir = target.getOutputDirectory(context);
if (!outputDir.exists() && !outputDir.mkdirs()) {
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.cannot.create.directory", outputDir.getPath())));
return false;
}
File manifestFile = null;
final List<File> libManifests = new ArrayList<File>();
final List<AndroidManifestMergingTarget.MyRootDescriptor> roots = context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(target, context);
for (AndroidManifestMergingTarget.MyRootDescriptor root : roots) {
if (root.isLibManifestRoot()) {
libManifests.add(root.getRootFile());
} else {
manifestFile = root.getRootFile();
}
}
if (manifestFile == null) {
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.errors.manifest.not.found", module.getName())));
return false;
}
final File outputFile = new File(outputDir, SdkConstants.FN_ANDROID_MANIFEST_XML);
if (!doMergeManifests(context, manifestFile, libManifests, outputFile)) {
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, "[" + module.getName() + "] Cannot perform manifest merging"));
return false;
}
final List<String> srcPaths = new ArrayList<String>();
srcPaths.add(manifestFile.getPath());
for (File libManifest : libManifests) {
srcPaths.add(libManifest.getPath());
}
outputConsumer.registerOutputFile(outputFile, srcPaths);
return true;
}
use of org.jetbrains.jps.incremental.messages.CompilerMessage in project intellij-plugins by JetBrains.
the class FlexResourceBuilder method copyResource.
private static void copyResource(final CompileContext context, final File file, final Collection<String> targetPaths, final BuildOutputConsumer outputConsumer) {
try {
for (String targetPath : targetPaths) {
final File targetFile = new File(targetPath);
FileUtil.copyContent(file, targetFile);
outputConsumer.registerOutputFile(targetFile, Collections.singletonList(file.getPath()));
}
} catch (IOException e) {
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, e.getMessage(), FileUtil.toSystemIndependentName(file.getPath())));
}
}
use of org.jetbrains.jps.incremental.messages.CompilerMessage in project intellij-plugins by JetBrains.
the class JpsBuiltInFlexCompilerHandler method readInputStreamUntilConnected.
private void readInputStreamUntilConnected(final Process process, final CompileContext context, final String compilerName) {
SharedThreadPool.getInstance().executeOnPooledThread(() -> {
final InputStreamReader reader = FlexCommonUtils.createInputStreamReader(process.getInputStream());
try {
char[] buf = new char[1024];
int read;
while ((read = reader.read(buf, 0, buf.length)) >= 0) {
final String output = new String(buf, 0, read);
if (output.startsWith(CONNECTION_SUCCESSFUL)) {
break;
} else {
closeSocket();
context.processMessage(new CompilerMessage(compilerName, BuildMessage.Kind.ERROR, output));
}
}
} catch (IOException e) {
closeSocket();
context.processMessage(new CompilerMessage(compilerName, BuildMessage.Kind.ERROR, "Failed to start Flex compiler: " + e.toString()));
} finally {
try {
reader.close();
} catch (IOException e) {
/*ignore*/
}
}
});
}
use of org.jetbrains.jps.incremental.messages.CompilerMessage in project android by JetBrains.
the class AndroidSourceGeneratingBuilder method checkUnambiguousAndRecursiveArtifacts.
private static boolean checkUnambiguousAndRecursiveArtifacts(CompileContext context, List<JpsArtifact> artifacts) {
boolean success = true;
for (JpsArtifact artifact : artifacts) {
if (artifact.getArtifactType() instanceof AndroidApplicationArtifactType) {
final List<JpsAndroidModuleExtension> facets = AndroidJpsUtil.getAllPackagedFacets(artifact);
if (facets.size() > 1) {
context.processMessage(new CompilerMessage(ANDROID_VALIDATOR, BuildMessage.Kind.ERROR, "Cannot build artifact '" + artifact.getName() + "' because it contains more than one Android package"));
success = false;
continue;
}
final String artifactOutputPath = artifact.getOutputFilePath();
if (artifactOutputPath != null && facets.size() > 0) {
final JpsAndroidModuleExtension facet = facets.get(0);
final String apkPath = AndroidFinalPackageElementBuilder.getApkPath(facet);
if (FileUtil.pathsEqual(apkPath, artifactOutputPath)) {
context.processMessage(new CompilerMessage(ANDROID_VALIDATOR, BuildMessage.Kind.ERROR, "Incorrect output path for artifact '" + artifact.getName() + "': " + FileUtil.toSystemDependentName(apkPath)));
success = false;
}
}
}
}
return success;
}
use of org.jetbrains.jps.incremental.messages.CompilerMessage in project android by JetBrains.
the class AndroidSourceGeneratingBuilder method checkArtifacts.
private static boolean checkArtifacts(@NotNull CompileContext context) {
final List<JpsArtifact> artifacts = AndroidJpsUtil.getAndroidArtifactsToBuild(context);
if (!checkUnambiguousAndRecursiveArtifacts(context, artifacts)) {
return false;
}
final Set<JpsArtifact> debugArtifacts = new HashSet<JpsArtifact>();
final Set<JpsArtifact> releaseArtifacts = new HashSet<JpsArtifact>();
final Map<String, List<JpsArtifact>> moduleName2Artifact = new HashMap<String, List<JpsArtifact>>();
for (JpsArtifact artifact : artifacts) {
final JpsElement properties = artifact.getProperties();
if (!(properties instanceof JpsAndroidApplicationArtifactProperties)) {
continue;
}
final AndroidArtifactSigningMode mode = ((JpsAndroidApplicationArtifactProperties) properties).getSigningMode();
if (mode == AndroidArtifactSigningMode.DEBUG || mode == AndroidArtifactSigningMode.DEBUG_WITH_CUSTOM_CERTIFICATE) {
debugArtifacts.add(artifact);
} else {
releaseArtifacts.add(artifact);
}
final JpsAndroidModuleExtension facet = AndroidJpsUtil.getPackagedFacet(artifact);
if (facet != null) {
final String moduleName = facet.getModule().getName();
List<JpsArtifact> list = moduleName2Artifact.get(moduleName);
if (list == null) {
list = new ArrayList<JpsArtifact>();
moduleName2Artifact.put(moduleName, list);
}
list.add(artifact);
}
}
boolean success = true;
if (debugArtifacts.size() > 0 && releaseArtifacts.size() > 0) {
final String message = "Cannot build debug and release Android artifacts in the same session\n" + "Debug artifacts: " + artifactsToString(debugArtifacts) + "\n" + "Release artifacts: " + artifactsToString(releaseArtifacts);
context.processMessage(new CompilerMessage(ANDROID_VALIDATOR, BuildMessage.Kind.ERROR, message));
success = false;
}
if (releaseArtifacts.size() > 0 && AndroidJpsUtil.getRunConfigurationTypeId(context) != null) {
final String message = "Cannot build release Android artifacts in the 'build before run' session\n" + "Release artifacts: " + artifactsToString(releaseArtifacts);
context.processMessage(new CompilerMessage(ANDROID_VALIDATOR, BuildMessage.Kind.ERROR, message));
success = false;
}
for (Map.Entry<String, List<JpsArtifact>> entry : moduleName2Artifact.entrySet()) {
final List<JpsArtifact> list = entry.getValue();
final String moduleName = entry.getKey();
if (list.size() > 1) {
final JpsArtifact firstArtifact = list.get(0);
final Object[] firstArtifactProGuardOptions = getProGuardOptions(firstArtifact);
for (int i = 1; i < list.size(); i++) {
final JpsArtifact artifact = list.get(i);
if (!Arrays.equals(getProGuardOptions(artifact), firstArtifactProGuardOptions)) {
context.processMessage(new CompilerMessage(ANDROID_VALIDATOR, BuildMessage.Kind.ERROR, "Artifacts related to the same module '" + moduleName + "' have different ProGuard options: " + firstArtifact.getName() + ", " + artifact.getName()));
success = false;
break;
}
}
}
}
return success;
}
Aggregations