From 743c4152b74a5ac2ff715019a43de4545af64dc6 Mon Sep 17 00:00:00 2001 From: TheSnoozer <6849390+TheSnoozer@users.noreply.github.com> Date: Sun, 29 Mar 2026 21:57:03 +0200 Subject: [PATCH 1/4] update links to git-commit-id-maven-plugin (we are not in the core module :-) --- .github/ISSUE_TEMPLATE/new_release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/new_release.yml b/.github/ISSUE_TEMPLATE/new_release.yml index b52fcb74..f3aed330 100644 --- a/.github/ISSUE_TEMPLATE/new_release.yml +++ b/.github/ISSUE_TEMPLATE/new_release.yml @@ -33,12 +33,12 @@ body: - [ ] Push changes and tag: `git push origin master --follow-tags` - [ ] wait for github actions to pass - [ ] `mvn clean deploy -Pgpg` - - [ ] verify plugin is available on (might take some time) https://repo1.maven.org/maven2/io/github/git-commit-id/git-commit-id-plugin-core/ + - [ ] verify plugin is available on (might take some time) https://repo1.maven.org/maven2/io/github/git-commit-id/git-commit-id-maven-plugin/ - [ ] Set next development version: `bump2version patch --dry-run --verbose` - [ ] Push snapshot version: `git push origin master` - - [ ] under [Milestones](https://github.com/git-commit-id/git-commit-id-plugin-core/milestones) close old milestone - - [ ] under [Milestones](https://github.com/git-commit-id/git-commit-id-plugin-core/milestones) create new milestone for new version - - [ ] under [Releases](https://github.com/git-commit-id/git-commit-id-plugin-core/releases) publish Release-Notes + - [ ] under [Milestones](https://github.com/git-commit-id/git-commit-id-maven-plugin/milestones) close old milestone + - [ ] under [Milestones](https://github.com/git-commit-id/git-commit-id-maven-plugin/milestones) create new milestone for new version + - [ ] under [Releases](https://github.com/git-commit-id/git-commit-id-maven-plugin/releases) publish Release-Notes - [ ] update readme to point to the latest version available validations: required: true From 4aefc60d18f84de98f86c9b0ad650c2e3efe9449 Mon Sep 17 00:00:00 2001 From: TheSnoozer <6849390+TheSnoozer@users.noreply.github.com> Date: Sun, 29 Mar 2026 21:58:49 +0200 Subject: [PATCH 2/4] update to the latest version in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 160fadaf..8f4e8029 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The plugin is **available from [Maven Central](https://central.sonatype.com/arti io.github.git-commit-id git-commit-id-maven-plugin - 9.0.2 + 9.1.0 get-the-git-infos From 8a33505bbb1474df89ac21d9aef9888c16f550e7 Mon Sep 17 00:00:00 2001 From: TheSnoozer <6849390+TheSnoozer@users.noreply.github.com> Date: Thu, 2 Apr 2026 21:38:54 +0200 Subject: [PATCH 3/4] 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` --- pom.xml | 13 ++-- .../project13/maven/git/GitCommitIdMojo.java | 60 +++++++++++++++---- .../jgit/DescribeCommandIntegrationTest.java | 6 +- .../maven/git/AvailableGitTestRepo.java | 4 +- .../maven/git/ContainsKeyCondition.java | 4 +- .../maven/git/DoesNotContainKeyCondition.java | 4 +- .../maven/git/FileSystemMavenSandbox.java | 30 +++++----- .../maven/git/GitIntegrationTest.java | 12 ++-- .../DescribeCommandAbbrevIntegrationTest.java | 4 +- 9 files changed, 86 insertions(+), 51 deletions(-) diff --git a/pom.xml b/pom.xml index 581dd8e3..410ec67e 100644 --- a/pom.xml +++ b/pom.xml @@ -66,13 +66,12 @@ ${project.groupId} git-commit-id-plugin-core - 6.1.5 + 6.2.0 - com.google.code.findbugs - jsr305 - 3.0.2 - true + org.jspecify + jspecify + 1.0.0 @@ -326,8 +325,8 @@ - com.google.code.findbugs - jsr305 + org.jspecify + jspecify diff --git a/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java b/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java index 9e1557ec..d454de7e 100644 --- a/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java +++ b/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java @@ -24,6 +24,8 @@ import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.time.Instant; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.Collections; import java.util.Date; import java.util.List; @@ -31,8 +33,6 @@ import java.util.Optional; import java.util.Properties; import java.util.function.Supplier; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecution; @@ -44,7 +44,8 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; -import org.joda.time.DateTime; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.sonatype.plexus.build.incremental.BuildContext; import pl.project13.core.CommitIdGenerationMode; import pl.project13.core.CommitIdPropertiesOutputFormat; @@ -1279,25 +1280,25 @@ public Supplier supplyProjectVersion() { return () -> project.getVersion(); } - @Nonnull + @NonNull @Override public LogInterface getLogInterface() { return log; } - @Nonnull + @NonNull @Override public String getDateFormat() { return dateFormat; } - @Nonnull + @NonNull @Override public String getDateFormatTimeZone() { return dateFormatTimeZone; } - @Nonnull + @NonNull @Override public String getPrefixDot() { String trimmedPrefix = prefix.trim(); @@ -1443,8 +1444,8 @@ public boolean isPerModuleVersions() { } private void publishToAllSystemEnvironments( - @Nonnull LogInterface log, - @Nonnull Properties propertiesToPublish, + @NonNull LogInterface log, + @NonNull Properties propertiesToPublish, @Nullable Properties contextProperties) { publishPropertiesInto(propertiesToPublish, project.getProperties()); // some plugins rely on the user properties (e.g. flatten-maven-plugin) @@ -1505,7 +1506,44 @@ protected static Date parseOutputTimestamp(String outputTimestamp) { // no timestamp configured return null; } - return new DateTime(outputTimestamp).toDate(); + // Normalize the timestamp to handle common variations + String normalized = outputTimestamp.trim(); + + // Handle lowercase designators + normalized = normalized.replace('t', 'T').replace('z', 'Z'); + + // Handle hours-only offsets by adding :00 minutes if needed + if (normalized.matches(".*[+-]\\d{2}$")) { + normalized = normalized.substring(0, normalized.length() - 3) + + normalized.substring(normalized.length() - 3) + ":00"; + } + + // Try parsing with different formatters in order of preference + DateTimeFormatter[] formatters = { + DateTimeFormatter.ISO_INSTANT, // 2022-02-12T15:30:00Z + DateTimeFormatter.ISO_OFFSET_DATE_TIME, // 2022-02-12T15:30+00:00 + DateTimeFormatter.ISO_LOCAL_DATE_TIME, // 2022-02-12T15:30:00 + DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mmZ"), // 2019-03-26T10:00-0400 + DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ"), // 2019-03-26T10:00:00-0400 + DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm") // 2022-02-12T15:30 + }; + + for (DateTimeFormatter formatter : formatters) { + try { + if ( + formatter == DateTimeFormatter.ISO_LOCAL_DATE_TIME + && + (normalized.contains("+") || normalized.contains("-") || normalized.endsWith("Z")) + ) { + continue; // Skip local formatter for timestamps with timezones + } + return Date.from(Instant.from(formatter.parse(normalized))); + } catch (DateTimeParseException ignore) { + // Try next formatter + } + } + + throw new IllegalArgumentException("Unable to parse timestamp: " + outputTimestamp); } private void publishPropertiesInto(Properties propertiesToPublish, Properties propertiesTarget) { @@ -1536,7 +1574,7 @@ private void logProperties(LogInterface log, Properties propertiesToPublish) { } } - private boolean isPomProject(@Nonnull MavenProject project) { + private boolean isPomProject(@NonNull MavenProject project) { return project.getPackaging().equalsIgnoreCase("pom"); } } diff --git a/src/test/java/pl/project13/core/jgit/DescribeCommandIntegrationTest.java b/src/test/java/pl/project13/core/jgit/DescribeCommandIntegrationTest.java index 58560703..2772096b 100644 --- a/src/test/java/pl/project13/core/jgit/DescribeCommandIntegrationTest.java +++ b/src/test/java/pl/project13/core/jgit/DescribeCommandIntegrationTest.java @@ -26,12 +26,12 @@ import java.util.Collections; import java.util.Optional; -import javax.annotation.Nonnull; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ResetCommand; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; +import org.jspecify.annotations.NonNull; import org.junit.jupiter.api.Test; import pl.project13.log.DummyTestLoggerBridge; import pl.project13.maven.git.AvailableGitTestRepo; @@ -448,11 +448,11 @@ public void shouldReturnJustTheNearestTagWhenAbbrevIsZero() throws Exception { } } - String abbrev(@Nonnull String id) { + String abbrev(@NonNull String id) { return abbrev(id, DEFAULT_ABBREV_LEN); } - String abbrev(@Nonnull String id, int n) { + String abbrev(@NonNull String id, int n) { return id.substring(0, n); } } diff --git a/src/test/java/pl/project13/maven/git/AvailableGitTestRepo.java b/src/test/java/pl/project13/maven/git/AvailableGitTestRepo.java index 0eb5bed3..c61c8657 100644 --- a/src/test/java/pl/project13/maven/git/AvailableGitTestRepo.java +++ b/src/test/java/pl/project13/maven/git/AvailableGitTestRepo.java @@ -19,7 +19,7 @@ package pl.project13.maven.git; import java.io.File; -import javax.annotation.Nonnull; +import org.jspecify.annotations.NonNull; /** * List of available git repositories that we can use to perform tests with. @@ -168,7 +168,7 @@ public enum AvailableGitTestRepo { this.dir = dir; } - @Nonnull + @NonNull public File getDir() { return new File(dir); } diff --git a/src/test/java/pl/project13/maven/git/ContainsKeyCondition.java b/src/test/java/pl/project13/maven/git/ContainsKeyCondition.java index e172a9f2..bf23b944 100644 --- a/src/test/java/pl/project13/maven/git/ContainsKeyCondition.java +++ b/src/test/java/pl/project13/maven/git/ContainsKeyCondition.java @@ -19,8 +19,8 @@ package pl.project13.maven.git; import java.util.Map; -import javax.annotation.Nonnull; import org.assertj.core.api.Condition; +import org.jspecify.annotations.NonNull; class ContainsKeyCondition extends Condition> { @@ -31,7 +31,7 @@ public ContainsKeyCondition(String key) { } @Override - public boolean matches(@Nonnull Map map) { + public boolean matches(@NonNull Map map) { boolean containsKey = map.containsKey(key); if (!containsKey) { throw new RuntimeException( diff --git a/src/test/java/pl/project13/maven/git/DoesNotContainKeyCondition.java b/src/test/java/pl/project13/maven/git/DoesNotContainKeyCondition.java index 49f13b0e..e863a8a8 100644 --- a/src/test/java/pl/project13/maven/git/DoesNotContainKeyCondition.java +++ b/src/test/java/pl/project13/maven/git/DoesNotContainKeyCondition.java @@ -19,8 +19,8 @@ package pl.project13.maven.git; import java.util.Map; -import javax.annotation.Nonnull; import org.assertj.core.api.Condition; +import org.jspecify.annotations.NonNull; class DoesNotContainKeyCondition extends Condition> { @@ -31,7 +31,7 @@ public DoesNotContainKeyCondition(String key) { } @Override - public boolean matches(@Nonnull Map map) { + public boolean matches(@NonNull Map map) { boolean containsKey = map.containsKey(key); if (containsKey) { System.out.println(String.format("Map contained [%s] key! Map is: %s", key, map)); diff --git a/src/test/java/pl/project13/maven/git/FileSystemMavenSandbox.java b/src/test/java/pl/project13/maven/git/FileSystemMavenSandbox.java index 93df7e06..cb0e7975 100644 --- a/src/test/java/pl/project13/maven/git/FileSystemMavenSandbox.java +++ b/src/test/java/pl/project13/maven/git/FileSystemMavenSandbox.java @@ -21,10 +21,10 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import org.apache.commons.io.FileUtils; import org.apache.maven.project.MavenProject; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; /** * Quick and dirty maven projects tree structure to create on disk during integration tests. Can @@ -50,20 +50,20 @@ public FileSystemMavenSandbox(String rootSandboxPath) { this.rootSandboxPath = rootSandboxPath; } - @Nonnull + @NonNull public FileSystemMavenSandbox withParentProject(String parentProjectDirName, String packaging) { parentProject = createProject(new File(rootSandboxPath + File.separator + parentProjectDirName), packaging); return this; } - @Nonnull + @NonNull public FileSystemMavenSandbox withNoChildProject() { // no-op: marker for better tests readability return this; } - @Nonnull + @NonNull public FileSystemMavenSandbox withChildProject(String childProjectDirName, String packaging) { childProject = createProject(new File(parentProject.getBasedir(), childProjectDirName), packaging); @@ -71,8 +71,8 @@ public FileSystemMavenSandbox withChildProject(String childProjectDirName, Strin return this; } - @Nonnull - public FileSystemMavenSandbox withGitRepoInParent(@Nonnull AvailableGitTestRepo repo) { + @NonNull + public FileSystemMavenSandbox withGitRepoInParent(@NonNull AvailableGitTestRepo repo) { System.out.println("TEST: Will prepare sandbox repository based on: [" + repo.getDir() + "]"); gitRepoSourceDir = repo.getDir(); @@ -80,27 +80,27 @@ public FileSystemMavenSandbox withGitRepoInParent(@Nonnull AvailableGitTestRepo return this; } - @Nonnull - public FileSystemMavenSandbox withGitRepoInChild(@Nonnull AvailableGitTestRepo repo) { + @NonNull + public FileSystemMavenSandbox withGitRepoInChild(@NonNull AvailableGitTestRepo repo) { gitRepoSourceDir = repo.getDir(); gitRepoTargetDir = childProject.getBasedir(); return this; } - @Nonnull - public FileSystemMavenSandbox withGitRepoAboveParent(@Nonnull AvailableGitTestRepo repo) { + @NonNull + public FileSystemMavenSandbox withGitRepoAboveParent(@NonNull AvailableGitTestRepo repo) { gitRepoSourceDir = repo.getDir(); gitRepoTargetDir = new File(rootSandboxPath); return this; } - @Nonnull + @NonNull public FileSystemMavenSandbox withNoGitRepoAvailable() { gitRepoTargetDir = null; return this; } - @Nonnull + @NonNull public FileSystemMavenSandbox create() throws RuntimeException { try { createParentDir(); @@ -145,7 +145,7 @@ public MavenProject getChildProject() { return childProject; } - @Nonnull + @NonNull private MavenProject createProject(File basedir, String packaging) { MavenProject project = new MavenProject(); project.setFile(new File(basedir + File.separator + "pom.xml")); @@ -166,7 +166,7 @@ public String toString() { + '}'; } - @Nonnull + @NonNull public FileSystemMavenSandbox withKeepSandboxWhenFinishedTest( boolean keepSandboxWhenFinishedTest) { // if we want to keep the generated sandbox for overwiew the content of it diff --git a/src/test/java/pl/project13/maven/git/GitIntegrationTest.java b/src/test/java/pl/project13/maven/git/GitIntegrationTest.java index f90414b8..88b93e61 100644 --- a/src/test/java/pl/project13/maven/git/GitIntegrationTest.java +++ b/src/test/java/pl/project13/maven/git/GitIntegrationTest.java @@ -18,7 +18,6 @@ package pl.project13.maven.git; -import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -27,18 +26,17 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.Properties; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Stream; -import javax.annotation.Nonnull; import org.apache.commons.io.FileUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Settings; import org.eclipse.jgit.api.Git; +import org.jspecify.annotations.NonNull; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.provider.Arguments; @@ -115,8 +113,8 @@ protected Optional projectDir() { return Optional.empty(); } - @Nonnull - protected File dotGitDir(@Nonnull Optional projectDir) { + @NonNull + protected File dotGitDir(@NonNull Optional projectDir) { if (projectDir.isPresent()) { return new File(currSandbox + File.separator + projectDir.get() + File.separator + ".git"); } else { @@ -143,7 +141,7 @@ public static void initializeMojoWithDefaults(GitCommitIdMojo mojo) { mojo.settings = mockSettings(); } - public void setProjectToExecuteMojoIn(@Nonnull MavenProject project) { + public void setProjectToExecuteMojoIn(@NonNull MavenProject project) { mojo.project = project; mojo.dotGitDirectory = new File(project.getBasedir(), ".git"); mojo.reactorProjects = getReactorProjects(project); @@ -162,7 +160,7 @@ private static Settings mockSettings() { return settings; } - private static List getReactorProjects(@Nonnull MavenProject project) { + private static List getReactorProjects(@NonNull MavenProject project) { List reactorProjects = new ArrayList<>(); MavenProject mavenProject = project; while (mavenProject != null) { diff --git a/src/test/java/pl/project13/maven/jgit/DescribeCommandAbbrevIntegrationTest.java b/src/test/java/pl/project13/maven/jgit/DescribeCommandAbbrevIntegrationTest.java index c17bf536..e745a3d8 100644 --- a/src/test/java/pl/project13/maven/jgit/DescribeCommandAbbrevIntegrationTest.java +++ b/src/test/java/pl/project13/maven/jgit/DescribeCommandAbbrevIntegrationTest.java @@ -21,9 +21,9 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.Optional; -import javax.annotation.Nonnull; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.lib.Repository; +import org.jspecify.annotations.NonNull; import org.junit.jupiter.api.Test; import pl.project13.core.jgit.DescribeCommand; import pl.project13.core.jgit.DescribeResult; @@ -113,7 +113,7 @@ public void onGitCommitIdsRepo_shouldNoticeThat2CharsIsTooLittleToBeUniqueAndUse } } - String abbrev(@Nonnull String id, int n) { + String abbrev(@NonNull String id, int n) { return id.substring(0, n); } } From 0163ad6b8774452588ef6cc95665ba20eaa7b286 Mon Sep 17 00:00:00 2001 From: TheSnoozer <6849390+TheSnoozer@users.noreply.github.com> Date: Fri, 3 Apr 2026 09:15:30 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Bump=20version:=209.1.0=20=E2=86=92=209.2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 7f9b0d55..7e0f1db3 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 9.1.0 +current_version = 9.2.0 commit = True tag = True tag_name = v{new_version} diff --git a/pom.xml b/pom.xml index 410ec67e..85d021bf 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.git-commit-id git-commit-id-maven-plugin maven-plugin - 9.1.0 + 9.2.0 Git Commit Id Maven Plugin https://github.com/git-commit-id/git-commit-id-maven-plugin @@ -41,7 +41,7 @@ git@github.com:git-commit-id/git-commit-id-maven-plugin.git scm:git@github.com:git-commit-id/git-commit-id-maven-plugin scm:git:git@github.com:git-commit-id/git-commit-id-maven-plugin.git - v9.1.0 + v9.2.0