This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new ccc252b [MJLINK-84] Remove remaining commons-lang3 (#211)
ccc252b is described below
commit ccc252b42f1cdd46a0890fc22316b09b8b0a68d0
Author: Marios Trivyzas <[email protected]>
AuthorDate: Thu Dec 19 13:05:25 2024 +0100
[MJLINK-84] Remove remaining commons-lang3 (#211)
* [MJLINK-84] Remove remaining commons-lang3
Dependency to commons-lang3 has been removed earlier on,
but still there were usages of `StringUtils` & `SystemUtils`
which lead to the plugin requiring the dependency to be
added explicitly when used.
Follows: https://github.com/apache/maven-jlink-plugin/pull/167
* use trim().isEmpty() vs isBlank() (j8 compt)
* address comments
* remove lang3 dep from pom.xml
---
pom.xml | 5 -----
.../jlink/AbstractJLinkToolchainExecutor.java | 26 +++++++++++++++-------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7422fe4..2af5a92 100644
--- a/pom.xml
+++ b/pom.xml
@@ -143,11 +143,6 @@
<version>3.6.3</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.8.1</version>
- </dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
diff --git
a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java
b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java
index 1401bb5..06f2c77 100644
---
a/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java
+++
b/src/main/java/org/apache/maven/plugins/jlink/AbstractJLinkToolchainExecutor.java
@@ -43,8 +43,6 @@ import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.stream.Collectors;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.SystemUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.shared.utils.cli.CommandLineException;
@@ -131,7 +129,7 @@ abstract class AbstractJLinkToolchainExecutor extends
AbstractJLinkExecutor {
}
// TODO: Check if there exist a more elegant way?
- String jLinkCommand = "jlink" + (SystemUtils.IS_OS_WINDOWS ? ".exe" :
"");
+ String jLinkCommand = "jlink" + (isOSWindows() ? ".exe" : "");
File jLinkExe = new File(jLinkExecutable);
@@ -139,7 +137,7 @@ abstract class AbstractJLinkToolchainExecutor extends
AbstractJLinkExecutor {
jLinkExe = new File(jLinkExe, jLinkCommand);
}
- if (SystemUtils.IS_OS_WINDOWS && jLinkExe.getName().indexOf('.') < 0) {
+ if (isOSWindows() && jLinkExe.getName().indexOf('.') < 0) {
jLinkExe = new File(jLinkExe.getPath() + ".exe");
}
@@ -160,9 +158,8 @@ abstract class AbstractJLinkToolchainExecutor extends
AbstractJLinkExecutor {
try {
int exitCode = CommandLineUtils.executeCommandLine(cmd, out, err);
- String output = StringUtils.isEmpty(out.getOutput())
- ? null
- : '\n' + out.getOutput().trim();
+ String output = out.getOutput().trim();
+ output = output.isEmpty() ? null : '\n' + output;
if (exitCode != 0) {
@@ -176,7 +173,7 @@ abstract class AbstractJLinkToolchainExecutor extends
AbstractJLinkExecutor {
StringBuilder msg = new StringBuilder("\nExit code: ");
msg.append(exitCode);
- if (StringUtils.isNotEmpty(err.getOutput())) {
+ if (!err.getOutput().trim().isEmpty()) {
msg.append(" - ").append(err.getOutput());
}
msg.append('\n');
@@ -197,4 +194,17 @@ abstract class AbstractJLinkToolchainExecutor extends
AbstractJLinkExecutor {
throw new MojoExecutionException("Unable to execute jlink command:
" + e.getMessage(), e);
}
}
+
+ private static boolean isOSWindows() {
+ try {
+ String osName = System.getProperty("os.name");
+ if (osName == null) {
+ return false;
+ }
+ return osName.startsWith("Windows");
+ } catch (final SecurityException ex) {
+ // we are not allowed to look at this property
+ return false;
+ }
+ }
}