Skip to content

Commit

Permalink
Merge pull request #810 from kusumotolab/output-build-failed
Browse files Browse the repository at this point in the history
build-failed個体の原因を出力する
  • Loading branch information
hnymA authored Dec 16, 2020
2 parents f3b5f5a + 9435c8a commit 4da1f09
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import jp.kusumotolab.kgenprog.project.GeneratedAST;
import jp.kusumotolab.kgenprog.project.GeneratedSourceCode;
import jp.kusumotolab.kgenprog.project.factory.TargetProject;
Expand All @@ -31,6 +33,8 @@
*/
public class ProjectBuilder {

public static final Logger log = LoggerFactory.getLogger(ProjectBuilder.class);

// TODO デフォルトのコンパイラバージョンは要検討.ひとまず1.8固定.
// TODO #289: 加え,toml からコンパイラバージョンを指定できるようにするべき.
private static final String DEFAULT_JDK_VERSION = "1.8";
Expand Down Expand Up @@ -79,6 +83,23 @@ public BuildResults build(final GeneratedSourceCode generatedSourceCode) {
final boolean success = build(allAsts, javaSourceObjects, diagnostics, progress);

if (!success) {
if (!diagnostics.getDiagnostics()
.isEmpty()) {
final StringBuilder sb = new StringBuilder();
sb.append("build failed.")
.append(System.lineSeparator())
.append(diagnostics.getDiagnostics()
.get(0));
if (diagnostics.getDiagnostics()
.size() > 1) {
sb.append(System.lineSeparator())
.append("and ")
.append(diagnostics.getDiagnostics()
.size() - 1)
.append(" more.");
}
log.debug(sb.toString());
}
return new EmptyBuildResults(diagnostics, progress.toString());
}
}
Expand Down

0 comments on commit 4da1f09

Please sign in to comment.