diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/Version.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/Version.java index c4a36a3a..1e896041 100644 --- a/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/Version.java +++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/versions/Version.java @@ -198,13 +198,13 @@ protected static String getVersionString(Version info, String buildSpecifier, St sb.append(joinDigitString(info.digits)); } - if (StringUtils.isNotEmpty(info.annotation)) { + if (info.annotation != null && !info.annotation.isEmpty()) { sb.append(StringUtils.defaultString(info.annotationSeparator)); sb.append(info.annotation); } - if (StringUtils.isNotEmpty(info.annotationRevision)) { - if (StringUtils.isEmpty(info.annotation)) { + if (info.annotationRevision != null && !info.annotationRevision.isEmpty()) { + if (info.annotation == null || info.annotation.isEmpty()) { sb.append(StringUtils.defaultString(info.annotationSeparator)); } else { sb.append(StringUtils.defaultString(info.annotationRevSeparator)); @@ -212,7 +212,7 @@ protected static String getVersionString(Version info, String buildSpecifier, St sb.append(info.annotationRevision); } - if (StringUtils.isNotEmpty(buildSpecifier)) { + if (buildSpecifier != null && !buildSpecifier.isEmpty()) { sb.append(StringUtils.defaultString(buildSeparator)); sb.append(buildSpecifier); } @@ -240,7 +240,7 @@ private List parseDigits(String strDigits) { } private static String nullIfEmpty(String s) { - return StringUtils.isEmpty(s) ? null : s; + return (s == null || s.isEmpty()) ? null : s; } /** diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java index 6358f241..bf793f0c 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java @@ -41,7 +41,6 @@ import org.apache.maven.shared.release.phase.ReleasePhase; import org.apache.maven.shared.release.phase.ResourceGenerator; import org.apache.maven.shared.release.strategy.Strategy; -import org.codehaus.plexus.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -459,7 +458,7 @@ public ReleaseDescriptorBuilder addReleaseVersion(String key, String value) { * @return The working directory */ protected File determineWorkingDirectory(File checkoutDirectory, String relativePathProjectDirectory) { - if (StringUtils.isNotEmpty(relativePathProjectDirectory)) { + if (relativePathProjectDirectory != null && !relativePathProjectDirectory.isEmpty()) { return new File(checkoutDirectory, relativePathProjectDirectory); } else { return checkoutDirectory; diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java index 7a807aaf..83f57b1d 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java @@ -34,7 +34,6 @@ import org.apache.maven.shared.release.ReleaseResult; import org.apache.maven.shared.release.env.ReleaseEnvironment; import org.apache.maven.shared.release.util.MavenCrypto; -import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.Commandline; @@ -128,7 +127,7 @@ public void executeGoals( cl.createArg().setValue("--batch-mode"); } - if (!StringUtils.isEmpty(additionalArguments)) { + if (!(additionalArguments == null || additionalArguments.isEmpty())) { cl.createArg().setLine(additionalArguments); } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java index c9772850..c248c5cb 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractInputVariablesPhase.java @@ -48,7 +48,6 @@ import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource; import org.codehaus.plexus.interpolation.RecursionInterceptor; import org.codehaus.plexus.interpolation.StringSearchInterpolator; -import org.codehaus.plexus.util.StringUtils; import static java.util.Objects.requireNonNull; import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; @@ -201,7 +200,7 @@ public ReleaseResult execute( tag = prompter.get() .prompt("What is the branch name for \"" + project.getName() + "\"? (" + buffer().project(project.getArtifactId()) + ")"); - if (StringUtils.isEmpty(tag)) { + if (tag == null || tag.isEmpty()) { throw new ReleaseExecutionException("No branch name was given."); } } else { diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java index c2b0a6fe..57605bfd 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractMapVersionsPhase.java @@ -39,7 +39,6 @@ import org.apache.maven.shared.release.versions.VersionParseException; import org.codehaus.plexus.components.interactivity.Prompter; import org.codehaus.plexus.components.interactivity.PrompterException; -import org.codehaus.plexus.util.StringUtils; import org.slf4j.Logger; import static java.util.Objects.requireNonNull; @@ -336,11 +335,11 @@ private String resolveSuggestedVersion( private String getDevelopmentVersion(String projectId, ReleaseDescriptor releaseDescriptor) { String projectVersion = releaseDescriptor.getProjectDevelopmentVersion(projectId); - if (StringUtils.isEmpty(projectVersion)) { + if (projectVersion == null || projectVersion.isEmpty()) { projectVersion = releaseDescriptor.getDefaultDevelopmentVersion(); } - if (StringUtils.isEmpty(projectVersion)) { + if (projectVersion == null || projectVersion.isEmpty()) { return null; } @@ -350,11 +349,11 @@ private String getDevelopmentVersion(String projectId, ReleaseDescriptor release private String getReleaseVersion(String projectId, ReleaseDescriptor releaseDescriptor) { String projectVersion = releaseDescriptor.getProjectReleaseVersion(projectId); - if (StringUtils.isEmpty(projectVersion)) { + if (projectVersion == null || projectVersion.isEmpty()) { projectVersion = releaseDescriptor.getDefaultReleaseVersion(); } - if (StringUtils.isEmpty(projectVersion)) { + if (projectVersion == null || projectVersion.isEmpty()) { return null; } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java index 17f0c578..d17865ec 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java @@ -409,7 +409,7 @@ private void transformDocument( private void rewriteBuildOutputTimestampProperty(Properties properties, ReleaseResult result) { String buildOutputTimestamp = properties.getProperty("project.build.outputTimestamp"); - if (buildOutputTimestamp == null || StringUtils.isEmpty(buildOutputTimestamp)) { + if (buildOutputTimestamp == null || (buildOutputTimestamp == null || buildOutputTimestamp.isEmpty())) { // no Reproducible Builds output timestamp defined return; } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java index ff30e4d1..76794f45 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRunGoalsPhase.java @@ -74,7 +74,7 @@ protected ReleaseResult execute( try { String goals = getGoals(releaseDescriptor); - if (!StringUtils.isEmpty(goals)) { + if (!(goals == null || goals.isEmpty())) { logInfo(result, "Executing goals '" + buffer().strong(goals) + "'..."); if (logArguments) { // logging arguments may log secrets: should be activated only on dryRun @@ -151,7 +151,7 @@ protected String getAdditionalArguments(ReleaseDescriptor releaseDescriptor) { protected File determineWorkingDirectory(File checkoutDirectory, String relativePathProjectDirectory) { File workingDirectory = checkoutDirectory; - if (StringUtils.isNotEmpty(relativePathProjectDirectory)) { + if (relativePathProjectDirectory != null && !relativePathProjectDirectory.isEmpty()) { workingDirectory = new File(checkoutDirectory, relativePathProjectDirectory); } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java index b233c60b..37d41fcc 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java @@ -50,7 +50,6 @@ import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator; import org.apache.maven.shared.release.util.ReleaseUtil; import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; import static java.util.Objects.requireNonNull; import static org.apache.maven.shared.utils.logging.MessageUtils.buffer; @@ -208,7 +207,7 @@ private ReleaseResult performCheckout( } String scmRelativePathProjectDirectory = scmResult.getRelativePathProjectDirectory(); - if (StringUtils.isEmpty(scmRelativePathProjectDirectory)) { + if (scmRelativePathProjectDirectory == null || scmRelativePathProjectDirectory.isEmpty()) { Path workingDirectory = Paths.get(releaseDescriptor.getWorkingDirectory()); Path rootProjectBasedir; diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java index 51dbb3c9..43a89add 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java @@ -65,7 +65,7 @@ private ReleaseResult runLogic( String additionalArguments = getAdditionalArguments(releaseDescriptor); if (releaseDescriptor.isUseReleaseProfile()) { - if (!StringUtils.isEmpty(additionalArguments)) { + if (!(additionalArguments == null || additionalArguments.isEmpty())) { additionalArguments = additionalArguments + " -DperformRelease=true"; } else { additionalArguments = "-DperformRelease=true"; @@ -79,7 +79,7 @@ private ReleaseResult runLogic( // ensure we don't use the release pom for the perform goals // ^^ paranoia? A MavenExecutor has already access to this. Probably worth refactoring. - if (!StringUtils.isEmpty(additionalArguments)) { + if (!(additionalArguments == null || additionalArguments.isEmpty())) { additionalArguments = additionalArguments + " -f " + pomFileName; } else { additionalArguments = "-f " + pomFileName; diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfigurator.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfigurator.java index f2adb28e..0f42cade 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfigurator.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/DefaultScmRepositoryConfigurator.java @@ -37,7 +37,6 @@ import org.apache.maven.shared.release.config.ReleaseDescriptor; import org.apache.maven.shared.release.util.MavenCrypto; import org.apache.maven.shared.release.util.MavenCrypto.MavenCryptoException; -import org.codehaus.plexus.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -134,20 +133,20 @@ public ScmRepository getConfiguredRepository(String url, ReleaseDescriptor relea } } - if (!StringUtils.isEmpty(username)) { + if (!(username == null || username.isEmpty())) { scmRepo.setUser(username); } - if (!StringUtils.isEmpty(password)) { + if (!(password == null || password.isEmpty())) { scmRepo.setPassword(password); } if (scmRepo instanceof ScmProviderRepositoryWithHost) { ScmProviderRepositoryWithHost repositoryWithHost = (ScmProviderRepositoryWithHost) scmRepo; - if (!StringUtils.isEmpty(privateKey)) { + if (!(privateKey == null || privateKey.isEmpty())) { repositoryWithHost.setPrivateKey(privateKey); } - if (!StringUtils.isEmpty(passphrase)) { + if (!(passphrase == null || passphrase.isEmpty())) { repositoryWithHost.setPassphrase(passphrase); } } @@ -156,12 +155,12 @@ public ScmRepository getConfiguredRepository(String url, ReleaseDescriptor relea SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) repository.getProviderRepository(); String tagBase = releaseDescriptor.getScmTagBase(); - if (!StringUtils.isEmpty(tagBase)) { + if (!(tagBase == null || tagBase.isEmpty())) { svnRepo.setTagBase(tagBase); } String branchBase = releaseDescriptor.getScmBranchBase(); - if (!StringUtils.isEmpty(branchBase)) { + if (!(branchBase == null || branchBase.isEmpty())) { svnRepo.setBranchBase(branchBase); } } diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java index 5a55c129..f57ba8bd 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java @@ -26,7 +26,6 @@ import java.util.Arrays; import java.util.List; -import org.apache.commons.lang3.StringUtils; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.release.ReleaseExecutionException; @@ -164,7 +163,7 @@ public static int getBaseWorkingDirectoryParentCount(final Path baseDirectory, f } public static String realignScmUrl(int parentLevels, String url) { - if (!StringUtils.isEmpty(url)) { + if (!(url == null || url.isEmpty())) { // normalize url = url.replaceAll("/\\./", "/") .replaceAll("/\\.$", "") diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java index 85dc1214..c7d71c8f 100644 --- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java +++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/versions/DefaultVersionInfo.java @@ -332,13 +332,13 @@ protected static String getVersionString(DefaultVersionInfo info, String buildSp sb.append(joinDigitString(info.digits)); } - if (StringUtils.isNotEmpty(info.annotation)) { + if (info.annotation != null && !info.annotation.isEmpty()) { sb.append(StringUtils.defaultString(info.annotationSeparator)); sb.append(info.annotation); } - if (StringUtils.isNotEmpty(info.annotationRevision)) { - if (StringUtils.isEmpty(info.annotation)) { + if (info.annotationRevision != null && !info.annotationRevision.isEmpty()) { + if (info.annotation == null || info.annotation.isEmpty()) { sb.append(StringUtils.defaultString(info.annotationSeparator)); } else { sb.append(StringUtils.defaultString(info.annotationRevSeparator)); @@ -346,7 +346,7 @@ protected static String getVersionString(DefaultVersionInfo info, String buildSp sb.append(info.annotationRevision); } - if (StringUtils.isNotEmpty(buildSpecifier)) { + if (buildSpecifier != null && !buildSpecifier.isEmpty()) { sb.append(StringUtils.defaultString(buildSeparator)); sb.append(buildSpecifier); } @@ -379,7 +379,7 @@ private List parseDigits(String strDigits) { // -------------------------------------------------- private static String nullIfEmpty(String s) { - return StringUtils.isEmpty(s) ? null : s; + return (s == null || s.isEmpty()) ? null : s; } /**