You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "rgoers (via GitHub)" <gi...@apache.org> on 2024/10/15 19:05:49 UTC

[PR] Skip the transformer if log4j-api isn't present [logging-log4j-transform]

rgoers opened a new pull request, #134:
URL: https://github.com/apache/logging-log4j-transform/pull/134

   This will exit the plugin with an info message if log4j-api is not present.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Skip the transformer if log4j-api isn't present [logging-log4j-transform]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #134:
URL: https://github.com/apache/logging-log4j-transform/pull/134#discussion_r1801793050


##########
log4j-transform-maven-plugin/src/main/java/org/apache/logging/log4j/transform/maven/LocationMojo.java:
##########
@@ -189,11 +192,17 @@ private WrappedIOException(IOException cause) {
         }
     }
 
-    private void validateLog4jVersion() throws MojoExecutionException {
-        Artifact log4jApi = project.getArtifacts().stream()
+    private boolean validateLog4jVersion() throws MojoExecutionException {

Review Comment:
   This method should probably either throw or return a `boolean`. Can you replace the `throw` statements with log + return?



##########
log4j-transform-maven-plugin/src/main/java/org/apache/logging/log4j/transform/maven/LocationMojo.java:
##########
@@ -189,11 +192,17 @@ private WrappedIOException(IOException cause) {
         }
     }
 
-    private void validateLog4jVersion() throws MojoExecutionException {
-        Artifact log4jApi = project.getArtifacts().stream()
+    private boolean validateLog4jVersion() throws MojoExecutionException {
+        Optional<Artifact> artifact = project.getArtifacts().stream()
                 .filter(a -> LOG4J_GROUP_ID.equals(a.getGroupId()) && LOG4J_API_ARTIFACT_ID.equals(a.getArtifactId()))
-                .findAny()
-                .orElseThrow(() -> new MojoExecutionException("Missing `log4j-api` dependency."));
+                .findAny();
+        Artifact log4jApi;
+        if (artifact.isPresent()) {
+            log4jApi = artifact.get();
+        } else {
+            getLog().info("Skipping project. Log4j is not being used.");

Review Comment:
   I would call it "Log4j API" instead of "Log4j", so users don't think it only works with "Log4j Core".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Skip the transformer if log4j-api isn't present [logging-log4j-transform]

Posted by "rgoers (via GitHub)" <gi...@apache.org>.
rgoers merged PR #134:
URL: https://github.com/apache/logging-log4j-transform/pull/134


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Skip the transformer if log4j-api isn't present [logging-log4j-transform]

Posted by "rgoers (via GitHub)" <gi...@apache.org>.
rgoers commented on code in PR #134:
URL: https://github.com/apache/logging-log4j-transform/pull/134#discussion_r1801835942


##########
log4j-transform-maven-plugin/src/main/java/org/apache/logging/log4j/transform/maven/LocationMojo.java:
##########
@@ -189,11 +192,17 @@ private WrappedIOException(IOException cause) {
         }
     }
 
-    private void validateLog4jVersion() throws MojoExecutionException {
-        Artifact log4jApi = project.getArtifacts().stream()
+    private boolean validateLog4jVersion() throws MojoExecutionException {

Review Comment:
   I am not sure I understand. This will still throw an exception if the log4j version is wrong. Why wouldn't you want that?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Skip the transformer if log4j-api isn't present [logging-log4j-transform]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #134:
URL: https://github.com/apache/logging-log4j-transform/pull/134#discussion_r1801839227


##########
log4j-transform-maven-plugin/src/main/java/org/apache/logging/log4j/transform/maven/LocationMojo.java:
##########
@@ -189,11 +192,17 @@ private WrappedIOException(IOException cause) {
         }
     }
 
-    private void validateLog4jVersion() throws MojoExecutionException {
-        Artifact log4jApi = project.getArtifacts().stream()
+    private boolean validateLog4jVersion() throws MojoExecutionException {

Review Comment:
   If the version of Log4j API is too old, we can log an error and skip the execution.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org