Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git.properties file is not created in v4.9.9 #571

Closed
ShanikaEdiriweera opened this issue Jul 19, 2021 · 15 comments
Closed

git.properties file is not created in v4.9.9 #571

ShanikaEdiriweera opened this issue Jul 19, 2021 · 15 comments

Comments

@ShanikaEdiriweera
Copy link

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
@svieujot
Copy link

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>

@TheSnoozer
Copy link
Collaborator

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.

@lprimak
Copy link

lprimak commented Jul 31, 2021

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
Copy link

lprimak commented Jul 31, 2021

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
Copy link

lprimak commented Jul 31, 2021

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.

@TheSnoozer
Copy link
Collaborator

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.

@lprimak
Copy link

lprimak commented Aug 1, 2021

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!

@TheSnoozer
Copy link
Collaborator

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.

@lprimak
Copy link

lprimak commented Aug 1, 2021

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.

@TheSnoozer
Copy link
Collaborator

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?

@lprimak
Copy link

lprimak commented Aug 1, 2021

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.

@TheSnoozer
Copy link
Collaborator

The only reason why there is a 4.9.9 release under the new coordinates is that it also broke maven (#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 TheSnoozer pinned this issue Aug 1, 2021
TheSnoozer pushed a commit that referenced this issue Aug 1, 2021
Welcome to a chicken or egg-problem.
In practice we want to relocate the plugin to a new location,
but if we do so without publishing the counterpart in the new location
maven fails with "Could not find artifact io.github.git-commit-id:git-commit-id-maven-plugin:jar:${version}".
If we publish a release under the new coordinates, maven silent ignores the plugin settings
when we happen to use the old coordinates in our config
(#571).

As a result: The plugin is moving to a new location, but we can't encode it in the pom :-(

If anyone ever asks for a relocation pom again the answer is simply: no, thanks.
@TheSnoozer TheSnoozer mentioned this issue Aug 1, 2021
12 tasks
@TheSnoozer
Copy link
Collaborator

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.

@lprimak
Copy link

lprimak commented Aug 1, 2021

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?

@TheSnoozer
Copy link
Collaborator

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 TheSnoozer added this to the 7.0.0 milestone May 19, 2023
@TheSnoozer TheSnoozer unpinned this issue May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants