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

Option to accept multiple git directories #137

Closed
andrecr12 opened this issue Nov 21, 2014 · 5 comments
Closed

Option to accept multiple git directories #137

andrecr12 opened this issue Nov 21, 2014 · 5 comments
Labels
Milestone

Comments

@andrecr12
Copy link

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

@ktoso ktoso added the feature label Dec 13, 2014
@ktoso
Copy link
Collaborator

ktoso commented Dec 13, 2014

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

@TheSnoozer TheSnoozer added this to the 3.0 milestone Sep 3, 2018
TheSnoozer pushed a commit to TheSnoozer/git-commit-id-maven-plugin that referenced this issue May 1, 2019
…skip for reactor projects with injectAllReactorProjects=true also works properly when a user specifies multiple execution with a different prefix
@susannamichael54
Copy link

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

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
Labels
Projects
None yet
Development

No branches or pull requests

4 participants