git-commit-id-maven-plugin icon indicating copy to clipboard operation
git-commit-id-maven-plugin copied to clipboard

git.properties file is not created in v4.9.9

Open ShanikaEdiriweera opened this issue 4 years ago • 14 comments

Describe the bug

git.properties file is not created in v4.9.9 which was created in target/classes in v4.0.5

Steps to Reproduce

  • Please include the full configuration of the plugin
<plugin>
				<groupId>pl.project13.maven</groupId>
				<artifactId>git-commit-id-plugin</artifactId>
				<!-- <version>4.0.5</version> -->
				<executions>
					<execution>
						<id>get-the-git-infos</id>
						<goals>
							<goal>revision</goal>
						</goals>
						<phase>initialize</phase>
					</execution>
					<execution>
						<id>validate-the-git-infos</id>
						<goals>
							<goal>validateRevision</goal>
						</goals>
						<phase>package</phase>
					</execution>
				</executions>
				<configuration>
					<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
					<prefix>git</prefix>
					<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
					<dateFormatTimeZone>${user.timezone}</dateFormatTimeZone>
					<verbose>false</verbose>
					<generateGitPropertiesFile>true</generateGitPropertiesFile>
					<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
					<format>properties</format>
					<skipPoms>true</skipPoms>
					<injectAllReactorProjects>false</injectAllReactorProjects>
					<failOnNoGitDirectory>true</failOnNoGitDirectory>
					<failOnUnableToExtractRepoInfo>true</failOnUnableToExtractRepoInfo>
					<skip>false</skip>
					<runOnlyOnce>false</runOnlyOnce>
					<excludeProperties>
						<!-- <excludeProperty>git.user.*</excludeProperty> -->
					</excludeProperties>
					<useNativeGit>false</useNativeGit>
					<abbrevLength>7</abbrevLength>
					<commitIdGenerationMode>flat</commitIdGenerationMode>
					<gitDescribe>
						<skip>false</skip>
						<always>true</always>
						<abbrev>7</abbrev>
						<dirty>-dirty</dirty>
						<match>*</match>
						<tags>false</tags>
						<forceLongFormat>false</forceLongFormat>
					</gitDescribe>

					<validationProperties>
						<validationProperty>
							<name>validating project version</name>
							<value>${git.dirty}</value>
							<shouldMatchTo>false</shouldMatchTo>
						</validationProperty>
					</validationProperties>
					<validationShouldFailIfNoMatch>true</validationShouldFailIfNoMatch>
					<evaluateOnCommit>HEAD</evaluateOnCommit>
				</configuration>
			</plugin>
  • Is there a (public) project where this issue can be reproduced? NO
  • Include any stack-traces or any error messages

Expected behavior

  • git.propertiesis created in target/classes

ShanikaEdiriweera avatar Jul 19 '21 07:07 ShanikaEdiriweera

I had the same issue.

You probably missed the <phase>initialize</phase> in the plugin declaration as it doesn't seemed necessary in earlier versions.

My new declaration:

			<plugin>
				<groupId>io.github.git-commit-id</groupId>
				<artifactId>git-commit-id-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>get-the-git-infos</id>
						<goals>
							<goal>revision</goal>
						</goals>
						<phase>initialize</phase>
					</execution>
				</executions>

				<configuration>
					<generateGitPropertiesFile>true</generateGitPropertiesFile>
				</configuration>
			</plugin>

svieujot avatar Jul 19 '21 13:07 svieujot

Hi, thanks for creating this ticket. I'm a bit surprised to see that there is apparently anything different between the v4.0.5 and v4.9.9 version. By looking at the change-set I don't see anything that could contribute to such change. Moreover the changes done should be just related to where the plugin is published.

As a result: Are you sure that with the exact same setup the properties file is generated with v4.0.5, but not with v4.9.9? Have you perhaps switched maven projects, changed java versions, maven versions, operating systems, or changed any other setting?

Perhaps as a side note: The Plugin should be executed by default in the initialize-phase so the definition of <phase>initialize</phase> should at least in theory be redundant.

TheSnoozer avatar Jul 19 '21 18:07 TheSnoozer

Same issue here. Only thing changed is the plugin version. git.properties is not getting generated

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /Users/lprimak/.sdkman/candidates/maven/current
Java version: 11.0.12, vendor: Azul Systems, Inc., runtime: /Users/lprimak/.sdkman/candidates/java/11.0.12-zulu/zulu-11.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "11.5", arch: "x86_64", family: "mac"

Complete setup:

            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>4.9.9</version>
                <executions>
                    <execution>
                        <id>get-the-git-infos</id>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                        <phase>initialize</phase>
                    </execution>
                </executions>
                <configuration>
                    <useNativeGit>false</useNativeGit>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <failOnNoGitDirectory>false</failOnNoGitDirectory>
                    <abbrevLength>7</abbrevLength>
                    <gitDescribe>
                        <skip>true</skip>
                    </gitDescribe>
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
                    <includeOnlyProperties>
                        <includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
                        <includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
                    </includeOnlyProperties>
                    <commitIdGenerationMode>full</commitIdGenerationMode>
                </configuration>
            </plugin>

lprimak avatar Jul 31 '21 23:07 lprimak

I have no answer why these seemingly innocuous changes are producing this bug. Are you sure the deployment worked correctly for that version? Perhaps it needs to be 'clean redeploy' or something like that?

lprimak avatar Jul 31 '21 23:07 lprimak

I found the issue. v4.9.9 is an 'empty' deploy under the 'old' target spec on maven central - thare are no JAR files. This is why the plugin is not working.

the 'new' spec must be used:

 <groupId>io.github.git-commit-id</groupId>
  <artifactId>git-commit-id-maven-plugin</artifactId>
  <version>4.9.9</version>
https://repo1.maven.org/maven2/pl/project13/maven/git-commit-id-plugin/4.9.9/
pl/project13/maven/git-commit-id-plugin/4.9.9

../
git-commit-id-plugin-4.9.9.pom                    2021-07-10 10:06      1372      
git-commit-id-plugin-4.9.9.pom.asc                2021-07-10 10:06       833      
git-commit-id-plugin-4.9.9.pom.md5                2021-07-10 10:06        32      
git-commit-id-plugin-4.9.9.pom.sha1               2021-07-10 10:06        40      
		

@TheSnoozer Can you deploy 4.9.10 under the old target so auto upgrade tools don't get confused?

Thank you.

lprimak avatar Jul 31 '21 23:07 lprimak

Holy cow, thanks for the investigation! I don't have any words for this. While I feel this is truly a correct bug, I can't change or delete already performed releases so the only way "out" is to revert again to the old coordinates and deploy again. IMHO this relocation has become such a pain that I dislike maven now even more, plus this would be yet another pointless release. Whats the value of releasing again under the old coordinates, when we already know they changed...I truly don't know.

TheSnoozer avatar Aug 01 '21 16:08 TheSnoozer

Unfortunately, I don't think there is any way to get around making an "pointless" new release, especially since the failure occurs in a very non-obvious way. The latest release cannot be left 'broken' in the old coordinates.

But I see you already doing the release, thanks!

lprimak avatar Aug 01 '21 17:08 lprimak

Indeed, I wanted to cut a 4.9.10 release to potentially fix this issue, but noticed that once I had the plugin installed locally I observed the same issue even when i had a jar installed along-side. Hence I'm assuming that a new deployment will not fix this issue discovered here.

I couldn't resist to troubleshoot this further and noticed that this is not a plugin issue, but an issue within maven itself. I have created https://issues.apache.org/jira/browse/MNG-7204 for broader visibility.

In short the problem can be summarized that Maven will not forward the correct settings when you use the old coordinates. Regardless if you publish a jar, or just a relocation pom (for 4.9.9 I just had published a relocation pom).

TLDR: Congratulation you found a maven bug. For now I won't publish a new version since it would not fix the issue.

TheSnoozer avatar Aug 01 '21 20:08 TheSnoozer

From what I understand from the relocation page, is that the functionality is incomplete/ I would say that relocation should not be used until it's completed.

May I suggest to release 4.9.10 at the old coordinates, without relocation, as the last version, and then start at the new coordinates.

Also, please make it clear at the web page that the plugin has been relocated.

lprimak avatar Aug 01 '21 20:08 lprimak

I have done the relocation as outlined in the relocation guide. It just breaks the plugin. The version 4.9.9 is the exact same version as 4.0.5. When I now would release a 4.9.10 there would be yet another release of pretty much the same version. Publishing it without relocation is IMHO not want I want. The plugin wants to live under new coordinates.

The relocation has been mentioned in the release-notes https://github.com/git-commit-id/git-commit-id-maven-plugin/releases/tag/v5.0.0, on the readme https://github.com/git-commit-id/git-commit-id-maven-plugin#relocation-of-the-project, plus that was the entire exercise of even reacting a 4.9.9 release (or a relocation pom). Where else should I mention it? What web-page?

TheSnoozer avatar Aug 01 '21 20:08 TheSnoozer

In the “relocation of the project” heading on GH it says that only 5.x are available at the new coordinates. This is what confused me. 4.9.9+ is at the new coordinates. The GH page should reflect that.

Besides that everything should work and my preference would be to release 4.9.10 at the old and new coordinates with no relocation since that doesn’t work correctly yet.

lprimak avatar Aug 01 '21 21:08 lprimak

The only reason why there is a 4.9.9 release under the new coordinates is that it also broke maven (https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/569). I don't want to publish a release under the old coordinates without relocation information. Technially I never wanted to publish anything ever again under the old coordinates. Now I could publish a 4.9.10 under the old, but then would never be allowed to publish the same under the new coordinates. IMHO that smells fishy and should be properly be fixed by maven instead of publishing again and again....

TheSnoozer avatar Aug 01 '21 21:08 TheSnoozer

Despite my reluctance: There is now a 4.9.10 release under the old coordinates WITHOUT relocation information. At this point I just refuse to publish a 4.X under the new coordinates.

I'd still keep this open, since it's technically not fixed.

TheSnoozer avatar Aug 01 '21 22:08 TheSnoozer

I would think that this issue can be closed then since 4.9.10 fixes the problem and the relocation issue is present within maven. what do you think?

lprimak avatar Aug 01 '21 23:08 lprimak

Ok, I think this was now open for long enough, thanks again for reporting and apologies for all the issue it may have caused, please keep in mind that the plugin is available under different coordinates now:

 <relocation>
      <groupId>io.github.git-commit-id</groupId>
      <artifactId>git-commit-id-maven-plugin</artifactId>
    </relocation>

TheSnoozer avatar May 19 '23 06:05 TheSnoozer