Skip to content

Commit 8a33505

Browse files
committed
bump io.github.git-commit-id:git-commit-id-plugin-core from 6.1.5 to 6.2.0
See https://github.com/git-commit-id/git-commit-id-plugin-core/releases/tag/v6.2.0 - replace `org.eclipse.jgit.ssh.jsch` with `org.eclipse.jgit:org.eclipse.jgit.ssh.apache` (see https://github.com/eclipse-jgit/jgit/blob/master/org.eclipse.jgit.ssh.jsch/README.md) - add `org.bouncycastle:bcpkix-jdk18on` version `1.81` - remove `joda-time:joda-time` [replaced with Java 8+ Time API] - replace `com.google.code.findbugs:jsr305` version `3.0.2` with `org.jspecify:jspecify` version `1.0.0`
1 parent 4aefc60 commit 8a33505

File tree

9 files changed

+86
-51
lines changed

9 files changed

+86
-51
lines changed

pom.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@
6666
<dependency>
6767
<groupId>${project.groupId}</groupId>
6868
<artifactId>git-commit-id-plugin-core</artifactId>
69-
<version>6.1.5</version>
69+
<version>6.2.0</version>
7070
</dependency>
7171
<dependency>
72-
<groupId>com.google.code.findbugs</groupId>
73-
<artifactId>jsr305</artifactId>
74-
<version>3.0.2</version>
75-
<optional>true</optional>
72+
<groupId>org.jspecify</groupId>
73+
<artifactId>jspecify</artifactId>
74+
<version>1.0.0</version>
7675
</dependency>
7776
</dependencies>
7877
</dependencyManagement>
@@ -326,8 +325,8 @@
326325
</dependency>
327326

328327
<dependency>
329-
<groupId>com.google.code.findbugs</groupId>
330-
<artifactId>jsr305</artifactId>
328+
<groupId>org.jspecify</groupId>
329+
<artifactId>jspecify</artifactId>
331330
</dependency>
332331

333332
<!-- dependencies to annotations -->

src/main/java/pl/project13/maven/git/GitCommitIdMojo.java

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
import java.nio.charset.StandardCharsets;
2525
import java.text.SimpleDateFormat;
2626
import java.time.Instant;
27+
import java.time.format.DateTimeFormatter;
28+
import java.time.format.DateTimeParseException;
2729
import java.util.Collections;
2830
import java.util.Date;
2931
import java.util.List;
3032
import java.util.Map;
3133
import java.util.Optional;
3234
import java.util.Properties;
3335
import java.util.function.Supplier;
34-
import javax.annotation.Nonnull;
35-
import javax.annotation.Nullable;
3636
import org.apache.maven.execution.MavenSession;
3737
import org.apache.maven.plugin.AbstractMojo;
3838
import org.apache.maven.plugin.MojoExecution;
@@ -44,7 +44,8 @@
4444
import org.apache.maven.plugins.annotations.Parameter;
4545
import org.apache.maven.project.MavenProject;
4646
import org.apache.maven.settings.Settings;
47-
import org.joda.time.DateTime;
47+
import org.jspecify.annotations.NonNull;
48+
import org.jspecify.annotations.Nullable;
4849
import org.sonatype.plexus.build.incremental.BuildContext;
4950
import pl.project13.core.CommitIdGenerationMode;
5051
import pl.project13.core.CommitIdPropertiesOutputFormat;
@@ -1279,25 +1280,25 @@ public Supplier<String> supplyProjectVersion() {
12791280
return () -> project.getVersion();
12801281
}
12811282

1282-
@Nonnull
1283+
@NonNull
12831284
@Override
12841285
public LogInterface getLogInterface() {
12851286
return log;
12861287
}
12871288

1288-
@Nonnull
1289+
@NonNull
12891290
@Override
12901291
public String getDateFormat() {
12911292
return dateFormat;
12921293
}
12931294

1294-
@Nonnull
1295+
@NonNull
12951296
@Override
12961297
public String getDateFormatTimeZone() {
12971298
return dateFormatTimeZone;
12981299
}
12991300

1300-
@Nonnull
1301+
@NonNull
13011302
@Override
13021303
public String getPrefixDot() {
13031304
String trimmedPrefix = prefix.trim();
@@ -1443,8 +1444,8 @@ public boolean isPerModuleVersions() {
14431444
}
14441445

14451446
private void publishToAllSystemEnvironments(
1446-
@Nonnull LogInterface log,
1447-
@Nonnull Properties propertiesToPublish,
1447+
@NonNull LogInterface log,
1448+
@NonNull Properties propertiesToPublish,
14481449
@Nullable Properties contextProperties) {
14491450
publishPropertiesInto(propertiesToPublish, project.getProperties());
14501451
// some plugins rely on the user properties (e.g. flatten-maven-plugin)
@@ -1505,7 +1506,44 @@ protected static Date parseOutputTimestamp(String outputTimestamp) {
15051506
// no timestamp configured
15061507
return null;
15071508
}
1508-
return new DateTime(outputTimestamp).toDate();
1509+
// Normalize the timestamp to handle common variations
1510+
String normalized = outputTimestamp.trim();
1511+
1512+
// Handle lowercase designators
1513+
normalized = normalized.replace('t', 'T').replace('z', 'Z');
1514+
1515+
// Handle hours-only offsets by adding :00 minutes if needed
1516+
if (normalized.matches(".*[+-]\\d{2}$")) {
1517+
normalized = normalized.substring(0, normalized.length() - 3)
1518+
+ normalized.substring(normalized.length() - 3) + ":00";
1519+
}
1520+
1521+
// Try parsing with different formatters in order of preference
1522+
DateTimeFormatter[] formatters = {
1523+
DateTimeFormatter.ISO_INSTANT, // 2022-02-12T15:30:00Z
1524+
DateTimeFormatter.ISO_OFFSET_DATE_TIME, // 2022-02-12T15:30+00:00
1525+
DateTimeFormatter.ISO_LOCAL_DATE_TIME, // 2022-02-12T15:30:00
1526+
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mmZ"), // 2019-03-26T10:00-0400
1527+
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ"), // 2019-03-26T10:00:00-0400
1528+
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm") // 2022-02-12T15:30
1529+
};
1530+
1531+
for (DateTimeFormatter formatter : formatters) {
1532+
try {
1533+
if (
1534+
formatter == DateTimeFormatter.ISO_LOCAL_DATE_TIME
1535+
&&
1536+
(normalized.contains("+") || normalized.contains("-") || normalized.endsWith("Z"))
1537+
) {
1538+
continue; // Skip local formatter for timestamps with timezones
1539+
}
1540+
return Date.from(Instant.from(formatter.parse(normalized)));
1541+
} catch (DateTimeParseException ignore) {
1542+
// Try next formatter
1543+
}
1544+
}
1545+
1546+
throw new IllegalArgumentException("Unable to parse timestamp: " + outputTimestamp);
15091547
}
15101548

15111549
private void publishPropertiesInto(Properties propertiesToPublish, Properties propertiesTarget) {
@@ -1536,7 +1574,7 @@ private void logProperties(LogInterface log, Properties propertiesToPublish) {
15361574
}
15371575
}
15381576

1539-
private boolean isPomProject(@Nonnull MavenProject project) {
1577+
private boolean isPomProject(@NonNull MavenProject project) {
15401578
return project.getPackaging().equalsIgnoreCase("pom");
15411579
}
15421580
}

src/test/java/pl/project13/core/jgit/DescribeCommandIntegrationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626

2727
import java.util.Collections;
2828
import java.util.Optional;
29-
import javax.annotation.Nonnull;
3029
import org.eclipse.jgit.api.Git;
3130
import org.eclipse.jgit.api.ResetCommand;
3231
import org.eclipse.jgit.lib.ObjectId;
3332
import org.eclipse.jgit.lib.Repository;
3433
import org.eclipse.jgit.revwalk.RevCommit;
34+
import org.jspecify.annotations.NonNull;
3535
import org.junit.jupiter.api.Test;
3636
import pl.project13.log.DummyTestLoggerBridge;
3737
import pl.project13.maven.git.AvailableGitTestRepo;
@@ -448,11 +448,11 @@ public void shouldReturnJustTheNearestTagWhenAbbrevIsZero() throws Exception {
448448
}
449449
}
450450

451-
String abbrev(@Nonnull String id) {
451+
String abbrev(@NonNull String id) {
452452
return abbrev(id, DEFAULT_ABBREV_LEN);
453453
}
454454

455-
String abbrev(@Nonnull String id, int n) {
455+
String abbrev(@NonNull String id, int n) {
456456
return id.substring(0, n);
457457
}
458458
}

src/test/java/pl/project13/maven/git/AvailableGitTestRepo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package pl.project13.maven.git;
2020

2121
import java.io.File;
22-
import javax.annotation.Nonnull;
22+
import org.jspecify.annotations.NonNull;
2323

2424
/**
2525
* List of available git repositories that we can use to perform tests with.
@@ -168,7 +168,7 @@ public enum AvailableGitTestRepo {
168168
this.dir = dir;
169169
}
170170

171-
@Nonnull
171+
@NonNull
172172
public File getDir() {
173173
return new File(dir);
174174
}

src/test/java/pl/project13/maven/git/ContainsKeyCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
package pl.project13.maven.git;
2020

2121
import java.util.Map;
22-
import javax.annotation.Nonnull;
2322
import org.assertj.core.api.Condition;
23+
import org.jspecify.annotations.NonNull;
2424

2525
class ContainsKeyCondition extends Condition<Map<?, ?>> {
2626

@@ -31,7 +31,7 @@ public ContainsKeyCondition(String key) {
3131
}
3232

3333
@Override
34-
public boolean matches(@Nonnull Map<?, ?> map) {
34+
public boolean matches(@NonNull Map<?, ?> map) {
3535
boolean containsKey = map.containsKey(key);
3636
if (!containsKey) {
3737
throw new RuntimeException(

src/test/java/pl/project13/maven/git/DoesNotContainKeyCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
package pl.project13.maven.git;
2020

2121
import java.util.Map;
22-
import javax.annotation.Nonnull;
2322
import org.assertj.core.api.Condition;
23+
import org.jspecify.annotations.NonNull;
2424

2525
class DoesNotContainKeyCondition extends Condition<Map<?, ?>> {
2626

@@ -31,7 +31,7 @@ public DoesNotContainKeyCondition(String key) {
3131
}
3232

3333
@Override
34-
public boolean matches(@Nonnull Map<?, ?> map) {
34+
public boolean matches(@NonNull Map<?, ?> map) {
3535
boolean containsKey = map.containsKey(key);
3636
if (containsKey) {
3737
System.out.println(String.format("Map contained [%s] key! Map is: %s", key, map));

src/test/java/pl/project13/maven/git/FileSystemMavenSandbox.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
import java.io.File;
2222
import java.io.IOException;
2323
import java.nio.file.Files;
24-
import javax.annotation.Nonnull;
25-
import javax.annotation.Nullable;
2624
import org.apache.commons.io.FileUtils;
2725
import org.apache.maven.project.MavenProject;
26+
import org.jspecify.annotations.NonNull;
27+
import org.jspecify.annotations.Nullable;
2828

2929
/**
3030
* Quick and dirty maven projects tree structure to create on disk during integration tests. Can
@@ -50,57 +50,57 @@ public FileSystemMavenSandbox(String rootSandboxPath) {
5050
this.rootSandboxPath = rootSandboxPath;
5151
}
5252

53-
@Nonnull
53+
@NonNull
5454
public FileSystemMavenSandbox withParentProject(String parentProjectDirName, String packaging) {
5555
parentProject =
5656
createProject(new File(rootSandboxPath + File.separator + parentProjectDirName), packaging);
5757
return this;
5858
}
5959

60-
@Nonnull
60+
@NonNull
6161
public FileSystemMavenSandbox withNoChildProject() {
6262
// no-op: marker for better tests readability
6363
return this;
6464
}
6565

66-
@Nonnull
66+
@NonNull
6767
public FileSystemMavenSandbox withChildProject(String childProjectDirName, String packaging) {
6868
childProject =
6969
createProject(new File(parentProject.getBasedir(), childProjectDirName), packaging);
7070
childProject.setParent(parentProject);
7171
return this;
7272
}
7373

74-
@Nonnull
75-
public FileSystemMavenSandbox withGitRepoInParent(@Nonnull AvailableGitTestRepo repo) {
74+
@NonNull
75+
public FileSystemMavenSandbox withGitRepoInParent(@NonNull AvailableGitTestRepo repo) {
7676
System.out.println("TEST: Will prepare sandbox repository based on: [" + repo.getDir() + "]");
7777

7878
gitRepoSourceDir = repo.getDir();
7979
gitRepoTargetDir = parentProject.getBasedir();
8080
return this;
8181
}
8282

83-
@Nonnull
84-
public FileSystemMavenSandbox withGitRepoInChild(@Nonnull AvailableGitTestRepo repo) {
83+
@NonNull
84+
public FileSystemMavenSandbox withGitRepoInChild(@NonNull AvailableGitTestRepo repo) {
8585
gitRepoSourceDir = repo.getDir();
8686
gitRepoTargetDir = childProject.getBasedir();
8787
return this;
8888
}
8989

90-
@Nonnull
91-
public FileSystemMavenSandbox withGitRepoAboveParent(@Nonnull AvailableGitTestRepo repo) {
90+
@NonNull
91+
public FileSystemMavenSandbox withGitRepoAboveParent(@NonNull AvailableGitTestRepo repo) {
9292
gitRepoSourceDir = repo.getDir();
9393
gitRepoTargetDir = new File(rootSandboxPath);
9494
return this;
9595
}
9696

97-
@Nonnull
97+
@NonNull
9898
public FileSystemMavenSandbox withNoGitRepoAvailable() {
9999
gitRepoTargetDir = null;
100100
return this;
101101
}
102102

103-
@Nonnull
103+
@NonNull
104104
public FileSystemMavenSandbox create() throws RuntimeException {
105105
try {
106106
createParentDir();
@@ -145,7 +145,7 @@ public MavenProject getChildProject() {
145145
return childProject;
146146
}
147147

148-
@Nonnull
148+
@NonNull
149149
private MavenProject createProject(File basedir, String packaging) {
150150
MavenProject project = new MavenProject();
151151
project.setFile(new File(basedir + File.separator + "pom.xml"));
@@ -166,7 +166,7 @@ public String toString() {
166166
+ '}';
167167
}
168168

169-
@Nonnull
169+
@NonNull
170170
public FileSystemMavenSandbox withKeepSandboxWhenFinishedTest(
171171
boolean keepSandboxWhenFinishedTest) {
172172
// if we want to keep the generated sandbox for overwiew the content of it

src/test/java/pl/project13/maven/git/GitIntegrationTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
package pl.project13.maven.git;
2020

21-
import static java.util.Arrays.asList;
2221
import static org.assertj.core.api.Assertions.assertThat;
2322
import static org.mockito.Mockito.mock;
2423
import static org.mockito.Mockito.spy;
@@ -27,18 +26,17 @@
2726
import java.io.File;
2827
import java.io.IOException;
2928
import java.util.ArrayList;
30-
import java.util.Collection;
3129
import java.util.List;
3230
import java.util.Optional;
3331
import java.util.Properties;
3432
import java.util.concurrent.ThreadLocalRandom;
3533
import java.util.stream.Stream;
36-
import javax.annotation.Nonnull;
3734
import org.apache.commons.io.FileUtils;
3835
import org.apache.maven.execution.MavenSession;
3936
import org.apache.maven.project.MavenProject;
4037
import org.apache.maven.settings.Settings;
4138
import org.eclipse.jgit.api.Git;
39+
import org.jspecify.annotations.NonNull;
4240
import org.junit.jupiter.api.AfterEach;
4341
import org.junit.jupiter.api.BeforeEach;
4442
import org.junit.jupiter.params.provider.Arguments;
@@ -115,8 +113,8 @@ protected Optional<String> projectDir() {
115113
return Optional.empty();
116114
}
117115

118-
@Nonnull
119-
protected File dotGitDir(@Nonnull Optional<String> projectDir) {
116+
@NonNull
117+
protected File dotGitDir(@NonNull Optional<String> projectDir) {
120118
if (projectDir.isPresent()) {
121119
return new File(currSandbox + File.separator + projectDir.get() + File.separator + ".git");
122120
} else {
@@ -143,7 +141,7 @@ public static void initializeMojoWithDefaults(GitCommitIdMojo mojo) {
143141
mojo.settings = mockSettings();
144142
}
145143

146-
public void setProjectToExecuteMojoIn(@Nonnull MavenProject project) {
144+
public void setProjectToExecuteMojoIn(@NonNull MavenProject project) {
147145
mojo.project = project;
148146
mojo.dotGitDirectory = new File(project.getBasedir(), ".git");
149147
mojo.reactorProjects = getReactorProjects(project);
@@ -162,7 +160,7 @@ private static Settings mockSettings() {
162160
return settings;
163161
}
164162

165-
private static List<MavenProject> getReactorProjects(@Nonnull MavenProject project) {
163+
private static List<MavenProject> getReactorProjects(@NonNull MavenProject project) {
166164
List<MavenProject> reactorProjects = new ArrayList<>();
167165
MavenProject mavenProject = project;
168166
while (mavenProject != null) {

0 commit comments

Comments
 (0)