Skip to content

Commit

Permalink
[MSHARED-1421] Bump org.codehaus.plexus:plexus-archiver from 4.9.2 to…
Browse files Browse the repository at this point in the history
… 4.10.0 (#66)
  • Loading branch information
slachiewicz committed Jul 8, 2024
1 parent 2c54cd4 commit 53dd283
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 47 deletions.
11 changes: 9 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</distributionManagement>

<properties>
<mavenVersion>3.2.5</mavenVersion>
<mavenVersion>3.6.3</mavenVersion>
<javaVersion>8</javaVersion>
<project.build.outputTimestamp>2024-03-24T22:30:56Z</project.build.outputTimestamp>
</properties>
Expand Down Expand Up @@ -88,7 +88,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>4.9.2</version>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down Expand Up @@ -127,4 +127,11 @@
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven_central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
</project>
14 changes: 0 additions & 14 deletions src/main/java/org/apache/maven/archiver/MavenArchiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -584,24 +584,10 @@ public void createArchive(

// Configure the jar
archiver.addConfiguredManifest(manifest);

archiver.setCompress(archiveConfiguration.isCompress());

archiver.setRecompressAddedZips(archiveConfiguration.isRecompressAddedZips());

archiver.setIndex(archiveConfiguration.isIndex());

archiver.setDestFile(archiveFile);

// make the archiver index the jars on the classpath, if we are adding that to the manifest
if (archiveConfiguration.getManifest().isAddClasspath()) {
List<String> artifacts = project.getRuntimeClasspathElements();
for (String artifact : artifacts) {
File f = new File(artifact);
archiver.addConfiguredIndexJars(f);
}
}

archiver.setForced(forced);
if (!archiveConfiguration.isForced() && archiver.isSupportingForced()) {
// TODO Should issue a warning here, but how do we get a logger?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ void before() {
archive.setManifest(new ManifestConfiguration());
archive.setForced(false);
archive.setCompress(false);
archive.setIndex(false);
}

@Test
Expand Down
59 changes: 29 additions & 30 deletions src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.junit.jupiter.params.provider.NullAndEmptySource;
import org.junit.jupiter.params.provider.ValueSource;

import static org.apache.maven.archiver.MavenArchiver.parseBuildOutputTimestamp;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
Expand Down Expand Up @@ -1168,7 +1169,6 @@ private MavenProject getMavenProject() {
model.setVersion("0.1.1");

final MavenProject project = new MavenProject(model);
project.setExtensionArtifacts(Collections.emptySet());
project.setRemoteArtifactRepositories(Collections.emptyList());
project.setPluginArtifactRepositories(Collections.emptyList());
project.setName("archiver test");
Expand Down Expand Up @@ -1330,45 +1330,44 @@ public Manifest getJarFileManifest(File jarFile) throws IOException {

@Test
void testParseOutputTimestamp() {
MavenArchiver archiver = new MavenArchiver();

assertThat(archiver.parseOutputTimestamp(null)).isNull();
assertThat(archiver.parseOutputTimestamp("")).isNull();
assertThat(archiver.parseOutputTimestamp(".")).isNull();
assertThat(archiver.parseOutputTimestamp(" ")).isNull();
assertThat(archiver.parseOutputTimestamp("_")).isNull();
assertThat(archiver.parseOutputTimestamp("-")).isNull();
assertThat(archiver.parseOutputTimestamp("/")).isNull();
assertThat(archiver.parseOutputTimestamp("!")).isNull();
assertThat(archiver.parseOutputTimestamp("*")).isNull();

assertThat(archiver.parseOutputTimestamp("1570300662").getTime()).isEqualTo(1570300662000L);
assertThat(archiver.parseOutputTimestamp("0").getTime()).isZero();
assertThat(archiver.parseOutputTimestamp("1").getTime()).isEqualTo(1000L);

assertThat(archiver.parseOutputTimestamp("2019-10-05T18:37:42Z").getTime())
.isEqualTo(1570300662000L);
assertThat(archiver.parseOutputTimestamp("2019-10-05T20:37:42+02:00").getTime())
.isEqualTo(1570300662000L);
assertThat(archiver.parseOutputTimestamp("2019-10-05T16:37:42-02:00").getTime())
.isEqualTo(1570300662000L);
assertThat(parseBuildOutputTimestamp(null)).isEmpty();
assertThat(parseBuildOutputTimestamp("")).isEmpty();
assertThat(parseBuildOutputTimestamp(".")).isEmpty();
assertThat(parseBuildOutputTimestamp(" ")).isEmpty();
assertThat(parseBuildOutputTimestamp("_")).isEmpty();
assertThat(parseBuildOutputTimestamp("-")).isEmpty();
assertThat(parseBuildOutputTimestamp("/")).isEmpty();
assertThat(parseBuildOutputTimestamp("!")).isEmpty();
assertThat(parseBuildOutputTimestamp("*")).isEmpty();

assertThat(parseBuildOutputTimestamp("1570300662").get().getEpochSecond())
.isEqualTo(1570300662L);
assertThat(parseBuildOutputTimestamp("0").get().getEpochSecond()).isZero();
assertThat(parseBuildOutputTimestamp("1").get().getEpochSecond()).isEqualTo(1L);

assertThat(parseBuildOutputTimestamp("2019-10-05T18:37:42Z").get().getEpochSecond())
.isEqualTo(1570300662L);
assertThat(parseBuildOutputTimestamp("2019-10-05T20:37:42+02:00").get().getEpochSecond())
.isEqualTo(1570300662L);
assertThat(parseBuildOutputTimestamp("2019-10-05T16:37:42-02:00").get().getEpochSecond())
.isEqualTo(1570300662L);

// These must result in IAE because we expect extended ISO format only (ie with - separator for date and
// : separator for timezone), hence the XXX SimpleDateFormat for tz offset
// X SimpleDateFormat accepts timezone without separator while date has separator, which is a mix between
// basic (no separators, both for date and timezone) and extended (separator for both)
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> archiver.parseOutputTimestamp("2019-10-05T20:37:42+0200"));
.isThrownBy(() -> parseBuildOutputTimestamp("2019-10-05T20:37:42+0200"));
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> archiver.parseOutputTimestamp("2019-10-05T20:37:42-0200"));
.isThrownBy(() -> parseBuildOutputTimestamp("2019-10-05T20:37:42-0200"));
}

@ParameterizedTest
@NullAndEmptySource
@ValueSource(strings = {".", " ", "_", "-", "T", "/", "!", "!", "*", "ñ"})
void testEmptyParseOutputTimestampInstant(String value) {
// Empty optional if null or 1 char
assertThat(MavenArchiver.parseBuildOutputTimestamp(value)).isEmpty();
assertThat(parseBuildOutputTimestamp(value)).isEmpty();
}

@ParameterizedTest
Expand All @@ -1387,7 +1386,7 @@ void testEmptyParseOutputTimestampInstant(String value) {
"2099-12-31T23:59:59Z,4102444799"
})
void testParseOutputTimestampInstant(String value, long expected) {
assertThat(MavenArchiver.parseBuildOutputTimestamp(value)).contains(Instant.ofEpochSecond(expected));
assertThat(parseBuildOutputTimestamp(value)).contains(Instant.ofEpochSecond(expected));
}

@ParameterizedTest
Expand All @@ -1404,7 +1403,7 @@ void testParseOutputTimestampInstant(String value, long expected) {
void testThrownParseOutputTimestampInstant(String outputTimestamp) {
// Invalid parsing
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> MavenArchiver.parseBuildOutputTimestamp(outputTimestamp))
.isThrownBy(() -> parseBuildOutputTimestamp(outputTimestamp))
.withCauseInstanceOf(DateTimeParseException.class);
}

Expand All @@ -1421,7 +1420,7 @@ void testThrownParseOutputTimestampInstant(String outputTimestamp) {
void testThrownParseOutputTimestampInvalidRange(String outputTimestamp) {
// date is not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> MavenArchiver.parseBuildOutputTimestamp(outputTimestamp))
.isThrownBy(() -> parseBuildOutputTimestamp(outputTimestamp))
.withMessageContaining("is not within the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z");
}

Expand All @@ -1434,6 +1433,6 @@ void testThrownParseOutputTimestampInvalidRange(String outputTimestamp) {
})
@EnabledForJreRange(min = JRE.JAVA_9)
void testShortOffset(String value, long expected) {
assertThat(MavenArchiver.parseBuildOutputTimestamp(value)).contains(Instant.ofEpochSecond(expected));
assertThat(parseBuildOutputTimestamp(value)).contains(Instant.ofEpochSecond(expected));
}
}

0 comments on commit 53dd283

Please sign in to comment.