Fixing bug. 09/50109/2
authorGautam Shah <gautams@amdocs.com>
Mon, 4 Jun 2018 12:57:59 +0000 (18:27 +0530)
committerGAUTAMS <gautams@amdocs.com>
Mon, 4 Jun 2018 13:30:46 +0000 (19:00 +0530)
fixing bug.

Change-Id: Iedc29491adc1b066f9f6bfe4a4978c06de6be6bf
Issue-ID: SDC-1189
Signed-off-by: GAUTAMS <gautams@amdocs.com>
openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildHelper.java
openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/BuildState.java
openecomp-be/tools/compile-helper-plugin/src/main/java/org/openecomp/sdc/onboarding/InitializationHelperMojo.java

index 1b1278d..8f20f22 100644 (file)
@@ -48,12 +48,10 @@ import java.util.jar.JarEntry;
 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 @@ class BuildHelper {
         // 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 @@ class BuildHelper {
             store.put(key, signature);
             return signature;
         } catch (IOException ioe) {
-            logger.debug(ioe);
             return version;
         }
 
@@ -218,7 +211,6 @@ class BuildHelper {
              ObjectInputStream ois = new ObjectInputStream(is)) {
             return Optional.of(clazz.cast(ois.readObject()));
         } catch (Exception ignored) {
-            logger.debug(ignored);
             return Optional.empty();
         }
     }
index 1ce60a6..68557a9 100644 (file)
@@ -43,7 +43,6 @@ import java.util.Optional;
 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 @@ public class BuildState {
     private static File compileStateFile;
     private MavenProject project;
     private String compileStateFilePath;
-    private static Log logger;
 
     static {
         initializeStore();
@@ -76,12 +74,8 @@ public class BuildState {
         }
     }
 
-    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 @@ public class BuildState {
                 }
             }
         } catch (IOException ignored) {
-            logger.debug(ignored);
+            // ignored. No need to handle. System will take care.
         }
     }
 
@@ -168,7 +162,7 @@ public class BuildState {
                 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 @@ public class BuildState {
                  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 @@ public class BuildState {
             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 @@ public class BuildState {
         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<>();
         }
     }
index 42ddc65..6c1d2be 100644 (file)
@@ -64,8 +64,7 @@ public class InitializationHelperMojo extends AbstractMojo {
         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());