From ffcff757f20c94b5fa2e2b9cc504dcd16c80a686 Mon Sep 17 00:00:00 2001
From: aai <aai@kereval.com>
Date: Thu, 28 Oct 2021 12:06:38 +0200
Subject: [PATCH] Fix Pipeline Jacoco

---
 .../peripherals/HL7Templates2GOC.java         | 20 +++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/HL7Templates2GOC.java b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/HL7Templates2GOC.java
index 889fd3a..99bb6aa 100644
--- a/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/HL7Templates2GOC.java
+++ b/hl7templates/hl7templates-packager-jar/src/main/java/net/ihe/gazelle/lib/hl7templatespackager/peripherals/HL7Templates2GOC.java
@@ -200,6 +200,8 @@ public class HL7Templates2GOC {
         try {
             parser.parseArgument(args);
 
+            addSubDirectoryToOutput("/validator");
+
             // initialize log variable
             initLog();
             GOCLogger gocLogger = new GOCLoggerImpl(getWorkspaceRoot(getOutputFile()), generationDate);
@@ -211,10 +213,7 @@ public class HL7Templates2GOC {
             environementChecker.checkMVNPath(mvnExecPath,processExecutor);
             environementChecker.checkJavaVersion();
 
-            if (this.bbr == null || this.outputFile == null) {
-                log.info(HL7Templates2GOC.DOCUMENTATION_STRING);
-                return;
-            }
+
             HL7TEMP_RESOURCES_PATH = HL7TEMP_RESOURCES_PATH==null?
                     getWorkspaceRoot(outputFile)+"/hl7templates-resources":HL7TEMP_RESOURCES_PATH;
 
@@ -265,6 +264,19 @@ public class HL7Templates2GOC {
         return getOutputFile().substring(0, getOutputFile().lastIndexOf("/") + 1);
     }
 
+    /**
+     * Method to add sub-directories to the provided output path
+     * To encapsulate validator and logs in one directory
+     * Provide empty string to use the old behavior
+     * @param subDirectory sub-directorie(s), started with '/'
+     */
+    private void addSubDirectoryToOutput(String subDirectory){
+        if(subDirectory == null){
+            subDirectory = "";
+        }
+        this.outputFile  = this.outputFile + subDirectory;
+    }
+
     public static void main(String[] args) {
         HL7Templates2GOC hl7Templates2GOC = new HL7Templates2GOC();
         hl7Templates2GOC.execute(args);
-- 
GitLab