Correctly report locations of output files
This commit is contained in:
@@ -251,10 +251,19 @@ public class CompileEnvironmentUtil {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeToOutputWithDirector(ClassFileFactory factory, @NotNull OutputDirector outputDirector) {
|
public static void writeToOutputWithDirector(
|
||||||
|
ClassFileFactory factory,
|
||||||
|
@NotNull OutputDirector outputDirector,
|
||||||
|
@NotNull MessageCollector messageCollector
|
||||||
|
) {
|
||||||
List<String> files = factory.files();
|
List<String> files = factory.files();
|
||||||
for (String file : files) {
|
for (String file : files) {
|
||||||
File target = new File(outputDirector.getOutputDirectory(factory.getSourceFiles(file)), file);
|
List<File> sourceFiles = factory.getSourceFiles(file);
|
||||||
|
File target = new File(outputDirector.getOutputDirectory(sourceFiles), file);
|
||||||
|
messageCollector.report(
|
||||||
|
CompilerMessageSeverity.OUTPUT,
|
||||||
|
OutputMessageUtil.formatOutputMessage(sourceFiles, target),
|
||||||
|
CompilerMessageLocation.NO_LOCATION);
|
||||||
try {
|
try {
|
||||||
FileUtil.writeToFile(target, factory.asBytes(file));
|
FileUtil.writeToFile(target, factory.asBytes(file));
|
||||||
}
|
}
|
||||||
@@ -265,7 +274,7 @@ public class CompileEnvironmentUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void writeToOutputDirectory(ClassFileFactory factory, @NotNull File outputDir) {
|
public static void writeToOutputDirectory(ClassFileFactory factory, @NotNull File outputDir) {
|
||||||
writeToOutputWithDirector(factory, singleDirectory(outputDir));
|
writeToOutputWithDirector(factory, singleDirectory(outputDir), MessageCollector.NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used for debug output only
|
// Used for debug output only
|
||||||
@@ -292,25 +301,13 @@ public class CompileEnvironmentUtil {
|
|||||||
writeToJar(jar, includeRuntime, mainClass, factory);
|
writeToJar(jar, includeRuntime, mainClass, factory);
|
||||||
}
|
}
|
||||||
else if (outputDir != null) {
|
else if (outputDir != null) {
|
||||||
reportOutputs(factory, messageCollector);
|
writeToOutputWithDirector(factory, outputDir, messageCollector);
|
||||||
writeToOutputWithDirector(factory, outputDir);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new CompileEnvironmentException("Output directory or jar file is not specified - no files will be saved to the disk");
|
throw new CompileEnvironmentException("Output directory or jar file is not specified - no files will be saved to the disk");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reportOutputs(ClassFileFactory factory, MessageCollector messageCollector) {
|
|
||||||
for (String outputFile : factory.files()) {
|
|
||||||
List<File> sourceFiles = factory.getSourceFiles(outputFile);
|
|
||||||
messageCollector.report(
|
|
||||||
CompilerMessageSeverity.OUTPUT,
|
|
||||||
OutputMessageUtil.formatOutputMessage(sourceFiles, new File(outputFile)),
|
|
||||||
CompilerMessageLocation.NO_LOCATION);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class DescriptionToModuleAdapter implements Module {
|
private static class DescriptionToModuleAdapter implements Module {
|
||||||
private final ModuleDescription description;
|
private final ModuleDescription description;
|
||||||
|
|
||||||
|
|||||||
+1
-8
@@ -18,7 +18,6 @@ package org.jetbrains.jet.compiler.runner;
|
|||||||
|
|
||||||
import com.intellij.util.containers.ContainerUtil;
|
import com.intellij.util.containers.ContainerUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -26,16 +25,10 @@ import java.util.List;
|
|||||||
|
|
||||||
public class OutputItemsCollectorImpl implements OutputItemsCollector {
|
public class OutputItemsCollectorImpl implements OutputItemsCollector {
|
||||||
private final List<SimpleOutputItem> outputs = ContainerUtil.newArrayList();
|
private final List<SimpleOutputItem> outputs = ContainerUtil.newArrayList();
|
||||||
@Nullable
|
|
||||||
private final File outputDir;
|
|
||||||
|
|
||||||
public OutputItemsCollectorImpl(@Nullable File outputDir) {
|
|
||||||
this.outputDir = outputDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(Collection<File> sourceFiles, File outputFile) {
|
public void add(Collection<File> sourceFiles, File outputFile) {
|
||||||
outputs.add(new SimpleOutputItem(sourceFiles, new File(outputDir, outputFile.getPath())));
|
outputs.add(new SimpleOutputItem(sourceFiles, outputFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class JetCompiler implements TranslatingCompiler {
|
|||||||
|
|
||||||
if (scriptFile == null) return;
|
if (scriptFile == null) return;
|
||||||
|
|
||||||
OutputItemsCollectorImpl collector = new OutputItemsCollectorImpl(outputDir) {
|
OutputItemsCollectorImpl collector = new OutputItemsCollectorImpl() {
|
||||||
@Override
|
@Override
|
||||||
public void add(Collection<File> sourceFiles, File outputFile) {
|
public void add(Collection<File> sourceFiles, File outputFile) {
|
||||||
super.add(sourceFiles, outputFile);
|
super.add(sourceFiles, outputFile);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public final class K2JSCompiler implements TranslatingCompiler {
|
|||||||
|
|
||||||
private static void doCompile(@NotNull final MessageCollector messageCollector, @NotNull OutputSink sink, @NotNull final Module module,
|
private static void doCompile(@NotNull final MessageCollector messageCollector, @NotNull OutputSink sink, @NotNull final Module module,
|
||||||
@NotNull final CompilerEnvironment environment) {
|
@NotNull final CompilerEnvironment environment) {
|
||||||
OutputItemsCollectorImpl collector = new OutputItemsCollectorImpl(environment.getOutput());
|
OutputItemsCollectorImpl collector = new OutputItemsCollectorImpl();
|
||||||
outputCompilerMessagesAndHandleExitCode(messageCollector, collector, new Function<PrintStream, Integer>() {
|
outputCompilerMessagesAndHandleExitCode(messageCollector, collector, new Function<PrintStream, Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public Integer fun(PrintStream stream) {
|
public Integer fun(PrintStream stream) {
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class KotlinBuilder extends ModuleLevelBuilder {
|
|||||||
|
|
||||||
assert outputDir != null : "CompilerEnvironment must have checked for outputDir to be not null, but it didn't";
|
assert outputDir != null : "CompilerEnvironment must have checked for outputDir to be not null, but it didn't";
|
||||||
|
|
||||||
OutputItemsCollectorImpl outputItemCollector = new OutputItemsCollectorImpl(outputDir);
|
OutputItemsCollectorImpl outputItemCollector = new OutputItemsCollectorImpl();
|
||||||
|
|
||||||
JpsProject project = representativeTarget.getModule().getProject();
|
JpsProject project = representativeTarget.getModule().getProject();
|
||||||
CommonCompilerArguments commonSettings = JpsKotlinCompilerSettings.getCommonSettings(project);
|
CommonCompilerArguments commonSettings = JpsKotlinCompilerSettings.getCommonSettings(project);
|
||||||
|
|||||||
Reference in New Issue
Block a user