Skip to content

Option to accept multiple git directories  #137

Closed
@andrecr12

Description

@andrecr12

Hi,

Firstly, I'd to congratulate you all for this great plugin. This is very useful!

Second, I'd like to ask if already exists or suggest an option to configure the plugin to read multiple Git folder information.
For instance in my current case, I have a git repo that tracks the J2EE content and another git repo that tracks just the front-end code (HTML, CSS, Js, etc):

- <project_root>/.git
- <project_root>/src/main/webapp/.git

And, it'd be great if I could track the latest version of the built package of both gits.

Maybe, setting two configuration sets with two different prefix:

...
<configuration>
    <prefix>git1</prefix>
    ...
</configuration>
<configuration>
    <prefix>git2</prefix>
    ...
</configuration>

And, instead of only one git.properties, we could have:

# git1.properties
git.commit.id.describe=${git1.commit.id.describe}
...
# git2.properties
git.commit.id.describe=${git2.commit.id.describe}

I understand that this is not very common, but I believe it'd be nice to have this plugin the most flexible as possible.

Thanks

Activity

ktoso

ktoso commented on Dec 13, 2014

@ktoso
Collaborator

That might be rather weird to implement... I won't be implementing this any time soon, though I understand your use case.

I would be perfectly happy to review and pull in a pull request though :-) hint, hint 😉

TheSnoozer

TheSnoozer commented on Sep 3, 2018

@TheSnoozer
Collaborator

Even though this issue is here for ages and the original reporter probability doesn't need it anymore....out of curiosity I tested that and this is somewhat already supported by maven to run the plugin with different configurations. Simply specify each run as execution.

Full example:

<!-- GIT COMMIT ID PLUGIN CONFIGURATION -->
<plugin>
	<groupId>pl.project13.maven</groupId>
	<artifactId>git-commit-id-plugin</artifactId>
	<version>2.2.5</version>
	<executions>
		<execution>
			<phase>initialize</phase>
			<id>get-the-git-infos-for-repository-one</id>
			<goals>
				<goal>revision</goal>
			</goals>
			<configuration>
                                <prefix>git1</prefix>
				<dotGitDirectory>pathToRepositoryOne/.git</dotGitDirectory>
				<generateGitPropertiesFilename>${project.build.outputDirectory}/repository_one_git.properties</generateGitPropertiesFilename>
			</configuration>
		</execution>
		<execution>
			<phase>initialize</phase>
			<id>get-the-git-infos-for-repository-two</id>
			<goals>
				<goal>revision</goal>
			</goals>
			<configuration>
                                <prefix>git2</prefix>
				<dotGitDirectory>pathToRepositoryTwo/.git</dotGitDirectory>
				<generateGitPropertiesFilename>${project.build.outputDirectory}/repository_two_git.properties</generateGitPropertiesFilename>
			</configuration>
		</execution>
	</executions>
	<configuration>
		<verbose>false</verbose>
		<skipPoms>false</skipPoms>
		<injectAllReactorProjects>true</injectAllReactorProjects>
		<generateGitPropertiesFile>true</generateGitPropertiesFile>
	</configuration>
</plugin>

Now you could use this to either generate two (or multiple) property files, or simply use maven filtering and populate the generated properties into an aggregated property file:

# place this in src/main/resources and rely on maven's resource filtering (https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html)
# aggregation
# from git1.properties
git1.commit.id.describe=${git1.commit.id.describe}
# from git2.properties
git2.commit.id.describe=${git2.commit.id.describe}
# whatever else you might want to aggregate...

Personal remarks / Note

Intuitively I would assume that in the above example the configuration inside the execution would inherit from the configuration defined on the global plugin level. Knowing maven I would strongly advice to test this carefully with all maven versions you want to support with this configuration. This might not be working as you want in all circumstances (worked fine for some maven versions I just tested). In case you run into issues, I would advice to duplicate the plugin configuration into each configuration inside the execution and remove the plugin configuration entirely (so each execution has its own configuration and the inheritance question doesn't even pop up).

See also
https://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag
for further information (e.g. since Maven 3.3.1 you could also invoke the executions via CLI mvn git-commit-id-plugin:revision@get-the-git-infos-for-repository-one)

Since this is somewhat a border case and already somewhat supported (by just running the plugin multiple times) I'll go ahead and close this issue.
Feel free to reopen if you have further questions.

added this to the 3.0 milestone on Sep 3, 2018
added a commit that references this issue on May 1, 2019
susannamichael54

susannamichael54 commented on Nov 5, 2020

@susannamichael54

Hi, I was trying to generate the properties file for a submodule along with the parent module. I am using version 4.0.0 of the plugin. The solution of using two executions, as shown above, does not work in my case because the configuration tag is not valid within the execution tag for the version. Could you suggest an alternative?

TheSnoozer

TheSnoozer commented on Nov 7, 2020

@TheSnoozer
Collaborator

Hello, what do you mean by configuration tag is not valid within the execution tag for the version - i don't understand :-)

As a side note: please create a new issue for your problem.

susannamichael54

susannamichael54 commented on Nov 10, 2020

@susannamichael54

Hi, I am really sorry about that. I got something wrong. Sorry for the inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ktoso@andrecr12@TheSnoozer@susannamichael54

        Issue actions

          Option to accept multiple git directories · Issue #137 · git-commit-id/git-commit-id-maven-plugin