Skip to content

Commit

Permalink
check whether report viewer exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Feb 2, 2025
1 parent 10306cc commit a9901d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/src/main/java/de/jplag/cli/JPlagRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public static JPlagResult runJPlag(JPlagOptions options) throws ExitException {
* @throws IOException If the internal server throws an exception
*/
public static void runInternalServer(File zipFile, int port) throws IOException {
if (!ReportViewer.hasCompiledViewer()) {
logger.info("The report viewer is not available. Check whether you compiled JPlag with the report viewer.");
return;
}
ReportViewer reportViewer = new ReportViewer(zipFile, port);
int actualPort = reportViewer.start();
logger.info("ReportViewer started on port http://localhost:{}", actualPort);
Expand Down
4 changes: 4 additions & 0 deletions cli/src/main/java/de/jplag/cli/server/ReportViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,8 @@ public void handle(HttpExchange exchange) throws IOException {
RoutingTree getRoutingTree() {
return routingTree;
}

public static boolean hasCompiledViewer() {
return ResponseData.fromResourceUrl("/" + REPORT_VIEWER_RESOURCE_PREFIX + "/index.html") != null;
}
}

0 comments on commit a9901d7

Please sign in to comment.