openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1851711 - in /openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main: java/org/apache/meecrowave/maven/MeecrowaveBundleMojo.java resources/bin/meecrowave.bat resources/bin/meecrowave.sh
Date Sun, 20 Jan 2019 17:39:12 GMT
Author: rmannibucau
Date: Sun Jan 20 17:39:12 2019
New Revision: 1851711

URL: http://svn.apache.org/viewvc?rev=1851711&view=rev
Log:
MEECROWAVE-176 ensure to not use log4j if not bundled (meecrowave:bundle)

Modified:
    openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveBundleMojo.java
    openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.bat
    openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.sh

Modified: openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveBundleMojo.java
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveBundleMojo.java?rev=1851711&r1=1851710&r2=1851711&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveBundleMojo.java
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/java/org/apache/meecrowave/maven/MeecrowaveBundleMojo.java
Sun Jan 20 17:39:12 2019
@@ -41,6 +41,7 @@ import java.nio.file.attribute.BasicFile
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.stream.Stream;
 import java.util.zip.GZIPOutputStream;
@@ -180,19 +181,6 @@ public class MeecrowaveBundleMojo extend
 
         Stream.of("bin", "conf", "logs", "lib").forEach(i -> new File(distroFolder, i).mkdirs());
 
-        // TODO: add .bat support
-        for (final String ext : asList("sh", "bat")) {
-            try (final BufferedReader reader = new BufferedReader(new InputStreamReader(
-                    Thread.currentThread().getContextClassLoader().getResourceAsStream("bin/meecrowave."
+ ext)))) {
-                write(new File(distroFolder, "bin/meecrowave." + ext), StrSubstitutor.replace(reader.lines().collect(joining("\n")),
-                        new HashMap<String, String>() {{
-                            put("main", main);
-                        }}));
-            } catch (final IOException e) {
-                throw new MojoExecutionException(e.getMessage(), e);
-            }
-        }
-
         copyProvidedFiles(distroFolder);
 
         write(new File(distroFolder, "logs/you_can_safely_delete.txt"), DELETE_TEXT);
@@ -258,6 +246,23 @@ public class MeecrowaveBundleMojo extend
             }});
         }
 
+        for (final String ext : asList("sh", "bat")) {
+            try (final BufferedReader reader = new BufferedReader(new InputStreamReader(
+                    Thread.currentThread().getContextClassLoader().getResourceAsStream("bin/meecrowave."
+ ext)))) {
+                final File target = new File(distroFolder, "bin/meecrowave." + ext);
+                if (!target.exists()) {
+                    write(target, StrSubstitutor.replace(reader.lines().collect(joining("\n")),
+                            new HashMap<String, String>() {{
+                                put("main", main);
+                                put("logManager", hasLog4j(distroFolder) ?
+                                        "org.apache.logging.log4j.jul.LogManager" : "org.apache.juli.ClassLoaderLogManager");
+                            }}));
+                }
+            } catch (final IOException e) {
+                throw new MojoExecutionException(e.getMessage(), e);
+            }
+        }
+
         final Path prefix = skipArchiveRootFolder ? distroFolder.toPath() : distroFolder.getParentFile().toPath();
         for (final String format : formats) {
             getLog().info(format + "-ing Custom Meecrowave Distribution");
@@ -298,6 +303,15 @@ public class MeecrowaveBundleMojo extend
         }
     }
 
+    private boolean hasLog4j(final File distroFolder) {
+        try {
+            return Files.list(distroFolder.toPath().resolve("lib"))
+                    .anyMatch(it -> it.getFileName().toString().startsWith("log4j-jul"));
+        } catch (final IOException e) {
+            return true;
+        }
+    }
+
     private void addTransitiveDependencies(final File distroFolder, final Collection<String>
includedArtifacts, final Dependency dependency) {
         final DependencyResolutionRequest request = new DefaultDependencyResolutionRequest();
         request.setMavenProject(new MavenProject() {{

Modified: openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.bat
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.bat?rev=1851711&r1=1851710&r2=1851711&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.bat
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.bat
Sun Jan 20 17:39:12 2019
@@ -268,7 +268,7 @@ set LOGGING_CONFIG=-Djava.util.logging.c
 :noJuliConfig
 
 if not "%LOGGING_MANAGER%" == "" goto noJuliManager
-set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
+set LOGGING_MANAGER=-Djava.util.logging.manager=${logManager}
 :noJuliManager
 
 rem Configure JAVA 9 specific start-up parameters

Modified: openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.sh
URL: http://svn.apache.org/viewvc/openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.sh?rev=1851711&r1=1851710&r2=1851711&view=diff
==============================================================================
--- openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.sh
(original)
+++ openwebbeans/meecrowave/trunk/meecrowave-maven-plugin/src/main/resources/bin/meecrowave.sh
Sun Jan 20 17:39:12 2019
@@ -231,7 +231,7 @@ if [ -z "$LOGGING_CONFIG" ]; then
 fi
 
 if [ -z "$LOGGING_MANAGER" ]; then
-  LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager"
+  LOGGING_MANAGER="-Djava.util.logging.manager=${logManager}"
 fi
 
 # Set UMASK unless it has been overridden



Mime
View raw message