Skip to content

Commit

Permalink
[MSHARED-1297] Prefer JDK features over plexus-utils, plexus-io
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Aug 17, 2023
1 parent 87edd76 commit 482ec06
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 83 deletions.
10 changes: 0 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,11 @@
<!--
Plexus dependencies
-->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-io</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>4.8.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interpolation</artifactId>
Expand Down
25 changes: 20 additions & 5 deletions src/main/java/org/apache/maven/archiver/MavenArchiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
import org.codehaus.plexus.interpolation.RecursionInterceptor;
import org.codehaus.plexus.interpolation.StringSearchInterpolator;
import org.codehaus.plexus.interpolation.ValueSource;
import org.codehaus.plexus.util.StringUtils;

import static org.apache.maven.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_CUSTOM;
import static org.apache.maven.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_TYPE_REPOSITORY;
Expand Down Expand Up @@ -390,9 +389,10 @@ private void handleExtraExpression(Artifact artifact, List<ValueSource> valueSou
}

extraExpressions.setProperty("groupIdPath", artifact.getGroupId().replace('.', '/'));
if (StringUtils.isNotEmpty(artifact.getClassifier())) {
extraExpressions.setProperty("dashClassifier", "-" + artifact.getClassifier());
extraExpressions.setProperty("dashClassifier?", "-" + artifact.getClassifier());
String classifier = artifact.getClassifier();
if (classifier != null && !classifier.isEmpty()) {
extraExpressions.setProperty("dashClassifier", "-" + classifier);
extraExpressions.setProperty("dashClassifier?", "-" + classifier);
} else {
extraExpressions.setProperty("dashClassifier", "");
extraExpressions.setProperty("dashClassifier?", "");
Expand Down Expand Up @@ -772,7 +772,7 @@ public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp
}

// Number representing seconds since the epoch
if ((outputTimestamp != null && !outputTimestamp.isEmpty()) && StringUtils.isNumeric(outputTimestamp)) {
if (isNumeric(outputTimestamp)) {
return Optional.of(Instant.ofEpochSecond(Long.parseLong(outputTimestamp)));
}

Expand Down Expand Up @@ -800,6 +800,21 @@ public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp
}
}

private static boolean isNumeric(String str) {

if (str.isEmpty()) {
return false;
}

for (char c : str.toCharArray()) {
if (!Character.isDigit(c)) {
return false;
}
}

return true;
}

/**
* Configure Reproducible Builds archive creation if a timestamp is provided.
*
Expand Down
Loading

0 comments on commit 482ec06

Please sign in to comment.