Skip to content

Commit e5492fa

Browse files
authored
Merge pull request #910 from git-commit-id/per-module-versions
Add support for perModuleVersions + new publishing
2 parents 23cf5f6 + 02cf15f commit e5492fa

File tree

8 files changed

+221
-47
lines changed

8 files changed

+221
-47
lines changed

.bumpversion.cfg

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[bumpversion]
2+
current_version = 9.0.2
3+
commit = True
4+
tag = True
5+
tag_name = v{new_version}
6+
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
7+
serialize =
8+
{major}.{minor}.{patch}
9+
10+
[bumpversion:file:pom.xml]
11+
search = <version>{current_version}</version>
12+
replace = <version>{new_version}</version>
13+
14+
[bumpversion:file:./pom.xml]
15+
search = <tag>v{current_version}</tag>
16+
replace = <tag>v{new_version}</tag>

.github/ISSUE_TEMPLATE/new_release.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,34 @@ body:
1111
Just submit this as new issue...
1212
value: |
1313
This is the place holder to release the new **6.0.0** version.
14+
1415
Note that the current open tickets should be addressed, before performing a release.
1516
1617
# General scope of the new release:
1718
Fixed some minor things, added some minor features...(full list https://github.com/git-commit-id/git-commit-id-maven-plugin/issues?q=milestone%3A6.0.0).
1819
1920
# Release-Guide
20-
see http://central.sonatype.org/pages/ossrh-guide.html
21-
22-
- [ ] run an actual test with a local installed plugin (using https://github.com/git-commit-id/git-commit-id-maven-debugging)
23-
- [ ] ensure the local maven version is 3.9.0 and newer to avoid MNG-7055
24-
- [ ] verify that ~/.m2/settings.xml exists and contains username/password which is required as per https://central.sonatype.org/publish/publish-maven/#distribution-management-and-authentication
25-
- [ ] `mvn release:prepare`
26-
[INFO] Checking dependencies and plugins for snapshots ...
27-
What is the release version for "Git Commit Id Maven Plugin"? (io.github.git-commit-id:git-commit-id-maven-plugin) 6.0.0: : [ENTER]
28-
What is SCM release tag or label for "Git Commit Id Maven Plugin"? (io.github.git-commit-id:git-commit-id-maven-plugin) git-commit-id-maven-plugin-6.0.0: : **v6.0.0** [ENTER]
29-
What is the new development version for "Git Commit Id Maven Plugin"? (io.github.git-commit-id:git-commit-id-maven-plugin) 6.0.1-SNAPSHOT: : [ENTER]
21+
see
22+
- https://central.sonatype.org/publish/publish-guide
23+
- https://central.sonatype.org/publish/publish-portal-maven/
24+
- (OSSRH was deprecated on June 30, 2025 -- http://central.sonatype.org/pages/ossrh-guide.html)
25+
26+
The release process has changed from the old OSSRH staging to the new Central Portal:
27+
- Option 1: Use the new central-publishing-maven-plugin (recommended for automated releases)
28+
- Option 2: Use the OSSRH Staging API Service (compatibility layer)
3029
30+
- [ ] verify that `~/.m2/settings.xml` exists (https://central.sonatype.org/publish/publish-portal-maven/#credentials)
31+
- contains user token credentials from https://central.sonatype.com/ (generate token at https://central.sonatype.org/publish/generate-portal-token/)
32+
- [ ] Set release version: `bump2version patch --dry-run --verbose`
33+
- [ ] Push changes and tag: `git push origin master --follow-tags`
3134
- [ ] wait for github actions to pass
32-
- [ ] `mvn release:perform`
33-
- (or `mvn clean source:jar javadoc:jar deploy -Pgpg` from the git tag)
34-
- (or `mvn release:perform -Dresume=false`)
35-
- Note: If the uploading of the artifacts fails, ensure that a [`settings.xml`](https://github.com/git-commit-id/git-commit-id-maven-plugin/blob/master/.buildscript/settings.xml) exists under the local `.m2`-Folder
36-
- [ ] then go to https://s01.oss.sonatype.org/ log in there and go to the staging repositories, there will be the plugin, you have to first close and then release it if validation passed.
37-
- [ ] verify plugin is available on (might take some time) https://repo1.maven.org/maven2/io/github/git-commit-id/git-commit-id-maven-plugin/
38-
- [ ] under [Milestones](https://github.com/git-commit-id/git-commit-id-maven-plugin/milestones) close old milestone
39-
- [ ] under [Milestones](https://github.com/git-commit-id/git-commit-id-maven-plugin/milestones) create new milestone for new version
40-
- [ ] under [Releases](https://github.com/git-commit-id/git-commit-id-maven-plugin/releases) publish Release-Notes
35+
- [ ] `mvn clean deploy -Pgpg`
36+
- [ ] verify plugin is available on (might take some time) https://repo1.maven.org/maven2/io/github/git-commit-id/git-commit-id-plugin-core/
37+
- [ ] Set next development version: `bump2version patch --dry-run --verbose`
38+
- [ ] Push snapshot version: `git push origin master`
39+
- [ ] under [Milestones](https://github.com/git-commit-id/git-commit-id-plugin-core/milestones) close old milestone
40+
- [ ] under [Milestones](https://github.com/git-commit-id/git-commit-id-plugin-core/milestones) create new milestone for new version
41+
- [ ] under [Releases](https://github.com/git-commit-id/git-commit-id-plugin-core/releases) publish Release-Notes
4142
- [ ] update readme to point to the latest version available
42-
- [ ] run performance comparison with previous release (https://gist.github.com/TheSnoozer/7891eb9412c9584a052f00650d9c516b)
43-
4443
validations:
4544
required: true

.github/workflows/default-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
needs: checkstyle
3232
strategy:
3333
matrix:
34-
java_version: ['11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23']
34+
java_version: ['11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26' ]
3535

3636
steps:
3737
- uses: actions/checkout@v6

pom.xml

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@
33

44
<modelVersion>4.0.0</modelVersion>
55

6-
<parent>
7-
<groupId>org.sonatype.oss</groupId>
8-
<artifactId>oss-parent</artifactId>
9-
<version>9</version>
10-
<relativePath />
11-
</parent>
12-
136
<groupId>io.github.git-commit-id</groupId>
147
<artifactId>git-commit-id-maven-plugin</artifactId>
158
<packaging>maven-plugin</packaging>
16-
<version>9.0.3-SNAPSHOT</version>
9+
<version>9.0.2</version>
1710
<name>Git Commit Id Maven Plugin</name>
1811
<url>https://github.com/git-commit-id/git-commit-id-maven-plugin</url>
1912
<description>
@@ -23,6 +16,16 @@
2316
developers life easier. See https://github.com/git-commit-id/git-commit-id-maven-plugin
2417
</description>
2518

19+
<developers>
20+
<developer>
21+
<id>git-commit-id</id>
22+
<name>Git Commit ID Community</name>
23+
<email>github@git-commit-id.io</email>
24+
<organization>git-commit-id</organization>
25+
<organizationUrl>https://github.com/git-commit-id</organizationUrl>
26+
</developer>
27+
</developers>
28+
2629
<prerequisites>
2730
<maven>[3.6.3,)</maven>
2831
</prerequisites>
@@ -63,7 +66,7 @@
6366
<dependency>
6467
<groupId>${project.groupId}</groupId>
6568
<artifactId>git-commit-id-plugin-core</artifactId>
66-
<version>6.0.0</version>
69+
<version>6.1.5</version>
6770
</dependency>
6871
<dependency>
6972
<groupId>com.google.code.findbugs</groupId>
@@ -117,6 +120,9 @@
117120
<groupId>org.apache.maven.plugins</groupId>
118121
<artifactId>maven-release-plugin</artifactId>
119122
<version>3.3.1</version>
123+
<configuration>
124+
<arguments>-Pgpg</arguments>
125+
</configuration>
120126
</plugin>
121127
<plugin>
122128
<groupId>org.apache.maven.plugins</groupId>
@@ -132,6 +138,12 @@
132138
<groupId>org.apache.maven.plugins</groupId>
133139
<artifactId>maven-gpg-plugin</artifactId>
134140
<version>3.2.8</version>
141+
<configuration>
142+
<gpgArguments>
143+
<arg>--pinentry-mode</arg>
144+
<arg>loopback</arg>
145+
</gpgArguments>
146+
</configuration>
135147
</plugin>
136148
<plugin>
137149
<groupId>org.apache.maven.plugins</groupId>
@@ -164,9 +176,9 @@
164176
<version>3.1.4</version>
165177
</plugin>
166178
<plugin>
167-
<groupId>org.apache.maven.plugins</groupId>
168-
<artifactId>maven-deploy-plugin</artifactId>
169-
<version>3.1.4</version>
179+
<groupId>org.sonatype.central</groupId>
180+
<artifactId>central-publishing-maven-plugin</artifactId>
181+
<version>0.10.0</version>
170182
</plugin>
171183
<plugin>
172184
<groupId>org.apache.maven.plugins</groupId>
@@ -187,7 +199,16 @@
187199
</pluginManagement>
188200

189201
<plugins>
190-
<!-- Override oss parent downgrades -->
202+
<plugin>
203+
<groupId>org.sonatype.central</groupId>
204+
<artifactId>central-publishing-maven-plugin</artifactId>
205+
<extensions>true</extensions>
206+
<configuration>
207+
<publishingServerId>central</publishingServerId>
208+
<autoPublish>true</autoPublish>
209+
<waitUntil>published</waitUntil>
210+
</configuration>
211+
</plugin>
191212
<plugin>
192213
<groupId>org.apache.maven.plugins</groupId>
193214
<artifactId>maven-enforcer-plugin</artifactId>
@@ -368,17 +389,6 @@
368389
</dependency>
369390
</dependencies>
370391

371-
<distributionManagement>
372-
<snapshotRepository>
373-
<id>ossrh</id>
374-
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
375-
</snapshotRepository>
376-
<repository>
377-
<id>ossrh</id>
378-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
379-
</repository>
380-
</distributionManagement>
381-
382392
<profiles>
383393
<profile>
384394
<id>gpg</id>

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,31 @@ public class GitCommitIdMojo extends AbstractMojo {
130130
@Parameter(defaultValue = "false")
131131
boolean injectAllReactorProjects;
132132

133+
/**
134+
* Configuration to enable per-module version generation.
135+
* When enabled, the plugin will only consider commits affecting paths within the current module.
136+
*
137+
* <p>By default this option is disabled (set to {@code false})
138+
*
139+
* <p>This is useful in multi-module builds where you want to track module-specific changes
140+
* rather than the entire repository's commit history.
141+
*
142+
* <p>Example:
143+
*
144+
* <pre>{@code
145+
* <perModuleVersions>true</perModuleVersions>
146+
* }</pre>
147+
*
148+
* See
149+
* - https://github.com/git-commit-id/git-commit-id-plugin-core/pull/247
150+
* - https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/136
151+
* - https://github.com/git-commit-id/git-commit-id-maven-plugin/pull/535
152+
*
153+
* @since 9.1.0
154+
*/
155+
@Parameter(defaultValue = "false")
156+
boolean perModuleVersions;
157+
133158
/**
134159
* Configuration to tell the git-commit-id-maven-plugin to print some more verbose information
135160
* during the build (e.g. a summary of all collected properties when it's done).
@@ -1404,6 +1429,11 @@ public boolean shouldPropertiesEscapeUnicode() {
14041429
public boolean shouldFailOnNoGitDirectory() {
14051430
return failOnNoGitDirectory;
14061431
}
1432+
1433+
@Override
1434+
public boolean isPerModuleVersions() {
1435+
return perModuleVersions;
1436+
}
14071437
};
14081438

14091439
GitCommitIdPlugin.runPlugin(cb, properties);

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,41 @@ public enum AvailableGitTestRepo {
124124
*/
125125
WITH_THREE_COMMITS_AND_TWO_TAGS_CURRENTLY_ON_COMMIT_WITHOUT_TAG(
126126
"src/test/resources/_git_three_commits_and_two_tags_currently_on_commit_without_tag"),
127+
/**
128+
* <pre>
129+
* $ git log --name-only --pretty=format:"%H '%an' '%aD' '%s' %d" --date=short
130+
* 2ed2ea209fb99c360cd8434eb2d82b929da6b908
131+
* 'TheSnoozer'
132+
* 'Fri, 27 Mar 2026 17:40:36 +0100'
133+
* 'a change in the root pom' (HEAD -> master)
134+
* pom.xml
135+
*
136+
* 70a13b95591dac76ce92dd9087d557fca539f98a
137+
* 'submodule-two Author'
138+
* 'Fri, 27 Mar 2026 17:39:59 +0100'
139+
* 'a change in submodule-two' (tag: tag-submodule-two)
140+
* submodule-two/pom.xml
141+
*
142+
* 91e49245092c089624d3e770d902cfc8bc53a852
143+
* 'submodule-one Author'
144+
* 'Fri, 27 Mar 2026 17:39:23 +0100'
145+
* 'a change in submodule-one' (tag: tag-submodule-one)
146+
* submodule-one/pom.xml
147+
*
148+
* 9c5d2e13d042b0acb71c48232a9c408e42da87f7
149+
* 'TheSnoozer'
150+
* 'Fri, 27 Mar 2026 17:38:16 +0100'
151+
* 'new repo for testing (based on git-commit-id-maven-debugging)'
152+
* [snip]
153+
* </pre>
154+
* and dirty:
155+
* <pre>
156+
* $ git status -s
157+
* M submodule-two/pom.xml
158+
* </pre>
159+
*/
160+
WITH_SUBMODULES_AND_MULTIPLE_COMMITS(
161+
"src/test/resources/_git_with_submodules_and_multiple_commits"),
127162
// TODO: Why do the tests get stuck when we use .git??
128163
MAVEN_GIT_COMMIT_ID_PLUGIN("src/test/resources/_git_one_commit_with_umlaut");
129164

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

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,90 @@ public void shouldGeneratePropertiesWithMultiplePrefixesAndReactorProject(boolea
17161716
}
17171717
}
17181718

1719+
static Stream<Arguments> useNativeGitWithSubmoduleName() {
1720+
return useNativeGit().flatMap(arg ->
1721+
Stream.of(
1722+
"submodule-one",
1723+
"submodule-two"
1724+
).map(str ->
1725+
Arguments.of(arg.get()[0], str)
1726+
)
1727+
);
1728+
}
1729+
1730+
@ParameterizedTest
1731+
@MethodSource("useNativeGitWithSubmoduleName")
1732+
public void shouldGiveCommitIdForEachFolderWhenPerModuleVersionsEnabled(boolean useNativeGit, String submoduleName) throws Exception {
1733+
// given
1734+
mavenSandbox
1735+
.withParentProject("my-pom-project", "pom")
1736+
.withGitRepoInParent(AvailableGitTestRepo.WITH_SUBMODULES_AND_MULTIPLE_COMMITS)
1737+
.withChildProject(submoduleName, "jar")
1738+
.create();
1739+
MavenProject targetProject = mavenSandbox.getChildProject();
1740+
1741+
setProjectToExecuteMojoIn(targetProject);
1742+
1743+
GitDescribeConfig gitDescribeConfig = createGitDescribeConfig(false, 7);
1744+
1745+
mojo.gitDescribe = gitDescribeConfig;
1746+
mojo.useNativeGit = useNativeGit;
1747+
mojo.perModuleVersions = true;
1748+
mojo.dateFormatTimeZone = "CET";
1749+
1750+
// when
1751+
mojo.execute();
1752+
// then
1753+
Properties properties = targetProject.getProperties();
1754+
assertGitPropertiesPresentInProject(properties);
1755+
1756+
// setup expectations
1757+
Map<String, Object> expectedValues = new HashMap<>();
1758+
expectedValues.put("git.commit.id.full", null);
1759+
expectedValues.put("git.closest.tag.name", "tag-" + submoduleName);
1760+
expectedValues.put("git.closest.tag.commit.count", null);
1761+
expectedValues.put("git.dirty", null);
1762+
expectedValues.put("git.commit.message.full", "a change in " + submoduleName);
1763+
expectedValues.put("git.commit.user.name", submoduleName + " Author");
1764+
expectedValues.put("git.commit.user.email", submoduleName + "@example.com");
1765+
expectedValues.put("git.commit.time", null);
1766+
expectedValues.put("git.commit.author.time", null);
1767+
expectedValues.put("git.commit.committer.time", null);
1768+
1769+
if (submoduleName.equals("submodule-one")) {
1770+
expectedValues.put("git.commit.id.full", "91e49245092c089624d3e770d902cfc8bc53a852");
1771+
expectedValues.put("git.closest.tag.commit.count", 0);
1772+
expectedValues.put("git.dirty", true); // Really?
1773+
// date -d @$(git log -1 --pretty=format:%ct 91e4924) "+%Y-%m-%dT%H:%M:%S%z"
1774+
expectedValues.put("git.commit.time", "2026-03-28T11:47:51+0100");
1775+
// date -d @$(git log -1 --pretty=format:%at 91e4924) "+%Y-%m-%dT%H:%M:%S%z"
1776+
expectedValues.put("git.commit.author.time", "2026-03-27T17:39:23+0100");
1777+
// date -d @$(git log -1 --pretty=format:%ct 91e4924) "+%Y-%m-%dT%H:%M:%S%z"
1778+
expectedValues.put("git.commit.committer.time", "2026-03-28T11:47:51+0100");
1779+
} else if (submoduleName.equals("submodule-two")) {
1780+
expectedValues.put("git.commit.id.full", "70a13b95591dac76ce92dd9087d557fca539f98a");
1781+
expectedValues.put("git.closest.tag.commit.count", 0);
1782+
expectedValues.put("git.dirty", true);
1783+
// date -d @$(git log -1 --pretty=format:%ct 70a13b9) "+%Y-%m-%dT%H:%M:%S%z"
1784+
expectedValues.put("git.commit.time", "2026-03-28T11:48:17+0100");
1785+
// date -d @$(git log -1 --pretty=format:%at 70a13b9) "+%Y-%m-%dT%H:%M:%S%z"
1786+
expectedValues.put("git.commit.author.time", "2026-03-27T17:39:59+0100");
1787+
// date -d @$(git log -1 --pretty=format:%ct 70a13b9) "+%Y-%m-%dT%H:%M:%S%z"
1788+
expectedValues.put("git.commit.committer.time", "2026-03-28T11:48:17+0100");
1789+
}
1790+
1791+
// Assertions
1792+
for (Map.Entry<String, Object> entry : expectedValues.entrySet()) {
1793+
String key = entry.getKey();
1794+
Object expectedValue = entry.getValue();
1795+
1796+
assertThat(expectedValue).isNotNull();
1797+
assertThat(properties.getProperty(key))
1798+
.as("useNativeGit=%s,submoduleName=%s,key=%s", useNativeGit, submoduleName, key)
1799+
.isEqualTo(String.valueOf(expectedValue));
1800+
}
1801+
}
1802+
17191803
private GitDescribeConfig createGitDescribeConfig(boolean forceLongFormat, int abbrev) {
17201804
GitDescribeConfig gitDescribeConfig = new GitDescribeConfig();
17211805
gitDescribeConfig.setTags(true);

src/test/resources

Submodule resources updated 38 files

0 commit comments

Comments
 (0)