Fixing bug.

fixing bug.

Change-Id: Iedc29491adc1b066f9f6bfe4a4978c06de6be6bf
Issue-ID: SDC-1189
Signed-off-by: GAUTAMS <gautams@amdocs.com>
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildHelper.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildHelper.java
index 1b1278d..8f20f22 100644
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildHelper.java
+++ b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildHelper.java
@@ -48,12 +48,10 @@
 import java.util.jar.JarInputStream;
 import java.util.stream.Collectors;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
 
 class BuildHelper {
 
-    private static Log logger;
 
     private static Map<String, String> store = new HashMap<>();
 
@@ -61,10 +59,6 @@
         // donot remove.
     }
 
-    static void setLogger(Log log) {
-        logger = log;
-    }
-
     static String getSnapshotSignature(File snapshotFile, String moduleCoordinate, String version) {
         String key = moduleCoordinate + ":" + version;
         String signature = store.get(key);
@@ -76,7 +70,6 @@
             store.put(key, signature);
             return signature;
         } catch (IOException ioe) {
-            logger.debug(ioe);
             return version;
         }
 
@@ -218,7 +211,6 @@
              ObjectInputStream ois = new ObjectInputStream(is)) {
             return Optional.of(clazz.cast(ois.readObject()));
         } catch (Exception ignored) {
-            logger.debug(ignored);
             return Optional.empty();
         }
     }
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildState.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildState.java
index 1ce60a6..68557a9 100644
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildState.java
+++ b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildState.java
@@ -43,7 +43,6 @@
 import java.util.Set;
 import java.util.function.Function;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
 
 public class BuildState {
@@ -62,7 +61,6 @@
     private static File compileStateFile;
     private MavenProject project;
     private String compileStateFilePath;
-    private static Log logger;
 
     static {
         initializeStore();
@@ -76,12 +74,8 @@
         }
     }
 
-    private static void setLogger(Log log) {
-        logger = log;
-    }
 
-    void init(Log log) {
-        setLogger(log);
+    void init() {
         artifacts.clear();
         for (Artifact artifact : project.getArtifacts()) {
             if (artifact.isSnapshot() && JAR.equals(artifact.getType())) {
@@ -157,7 +151,7 @@
                 }
             }
         } catch (IOException ignored) {
-            logger.debug(ignored);
+            // ignored. No need to handle. System will take care.
         }
     }
 
@@ -168,7 +162,7 @@
                 compileDataStore.get(FULL_RESOURCE_BUILD_DATA).put(moduleCoordinates, buildTime);
                 writeCompileState();
             } catch (IOException ignored) {
-                logger.debug(ignored);
+                // ignored. No need to handle. System will take care.
             }
         }
     }
@@ -210,7 +204,7 @@
                  ObjectOutputStream ois = new ObjectOutputStream(fos)) {
                 ois.writeObject(dataToSave);
             } catch (IOException ignored) {
-                logger.debug(ignored);
+                // ignored. No need to handle. System will take care.
             }
         }
     }
@@ -239,9 +233,9 @@
             if (artifacts.containsKey(d) && JAR.equals(artifacts.get(d).getType())) {
                 boolean versionEqual = artifacts.get(d).getVersion().equals(project.getVersion());
                 if (versionEqual && getBuildTime(d) == 0) {
-                    logger.warn(ANSI_YELLOW + "[WARNING:]" + "You have module[" + d
-                                        + "] not locally compiled even once, please compile your project once daily from root to have reliable build results."
-                                        + ANSI_COLOR_RESET);
+                    System.err.println(ANSI_YELLOW + "[WARNING:]" + "You have module[" + d
+                                               + "] not locally compiled even once, please compile your project once daily from root to have reliable build results."
+                                               + ANSI_COLOR_RESET);
                     return true;
                 }
             }
@@ -281,7 +275,6 @@
         try (InputStream is = new FileInputStream(file); ObjectInputStream ois = new ObjectInputStream(is)) {
             return HashMap.class.cast(ois.readObject());
         } catch (Exception e) {
-            logger.debug(e);
             return new HashMap<>();
         }
     }
diff --git a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/InitializationHelperMojo.java b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/InitializationHelperMojo.java
index 42ddc65..6c1d2be 100644
--- a/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/InitializationHelperMojo.java
+++ b/openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/InitializationHelperMojo.java
@@ -64,8 +64,7 @@
         project.getProperties().setProperty(SKIP_PMD, Boolean.TRUE.toString());
 
         if (System.getProperties().containsKey(UNICORN)) {
-            buildState.init(getLog());
-            BuildHelper.setLogger(getLog());
+            buildState.init();
         } else {
             project.getProperties().setProperty("skipMainSourceCompile", Boolean.FALSE.toString());
             project.getProperties().setProperty("skipTestSourceCompile", Boolean.FALSE.toString());