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

Fixed to handle git submodules #65

Closed
wants to merge 1 commit into from

Conversation

unluckypixie
Copy link

Hi,

I have a project which heavily uses git submodules (around 80) and I wanted the branch name from each submodule to use in the name of the package for the submodule. I got this working many months back with an old version of your plugin but the recent changes to git have changed the way .git directories work for git submodules (they are now a file with a path to where the actual directory is), I have been putting off upgrading the version of git my team was using but it has now become an issue so I have updated your plugin to support the new git submodule format.

That was the primary purpose of my commit but I have also done a couple of other things (hope you don't mind!) ...

  1. Slightly changed the logging so that there is a "alwaysLog" and "log" function. The always log function logs messages even when verbose is false and the "log" only when verbose is true. I have made the path to the git directory and the loaded properties always log now (thought it's easy to change if you disagree).
  2. The new feature to inject the properties into reactor projects really slows down my build (I have 80 is projects and have to run the plugin on each one). So I have added a "injectAllReactorProjects" parameter (which defaults to the current behaviour of "true"). If you set that to false it only injects into the current project like it used to.
  3. As part of the git submodule fix I discovered that the searching of the heirarchy of projects for the .git directory simply does not work (I have a couple of poms in a heirarchy of directories that share one .git project and it didn't work with them). This seems to be down to project.getProject() always returning NULL. I have added some code so that if getParent() returns NULL but getParentArtifact() does not then I search the reactor projects for the one that matches the parentArtifact and use that. I think the fact that getParent() returns NULL is a bug in Maven so this is kinda a workaround and if it did return a project that one would be used.

All of the changes (apart from the log verbosity change) should give the same current behaviour with their default settings. I have tested the plugin with git 1.7 and git 1.9 (between those two the git directory format was changed) and it works fine for me with both. If you accept this plugin I would appreciate if you could get it up into the maven repos (as 2.15?) asap so I can update my projects to use this version!

…d corrected .git directory searching to work with git submodules.
@ghost ghost assigned ktoso Feb 22, 2013
@ktoso
Copy link
Collaborator

ktoso commented Feb 22, 2013

Neat pull request 👍 I'll look into it ASAP = today, or sunday.
Out of curiosity, how big of a build time difference is it for you with and without injectAllReactorProjects?

Cheers, Konrad

@unluckypixie
Copy link
Author

Testing with "mvn generate-sources", with injectAllReactorProjects set to "true":

[INFO] Total time: 1 minute 31 seconds

With injectAllReactorProjects set to "false":

[INFO] Total time: 19 seconds

That's with the verbose set to "false" - It would be slightly longer with verbose true because of the large amount of extra logging output.

@unluckypixie
Copy link
Author

To give you an idea here is a (slightly redacted) list of what it does in my project for each one of the projects in this list it prints this list!:

[info] [GitCommitIdMojo] Appending git properties to all reactor projects:
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Data" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Data : Common" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Data : Company" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Data : Test" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Foundation" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Modules" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Account" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Advertising" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Authentication" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Button Config" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Campaign" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Core" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : CreditCall" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : creditcard" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Film" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Hardware Config" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Internet" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Management UI" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Media" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Pricing" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Profile" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Proxy Config" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Radio" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Rental" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : SmartCard" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Survey" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Telephony" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Terminal UI" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : TV" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Upsell" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Url Config" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Module : Wallet" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : Callcentre Api" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : CreditCall" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : Film" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : Log" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : Management UI" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : Media" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : Service" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : TV" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : Whitelist Retrieval" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central App : Telephony" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central UI Apps" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central UI App : Assist" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central UI App : Authentication" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central UI App : Campaign" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central UI App : Model" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central UI App : Radio" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central UI App : Internet" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central UI App : Logs" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Central UI App : Organisation" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site PHP : Terminal UI" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site Apps" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Account" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Advertising" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Button Config" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Film" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Heartbeat" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Hardware Config" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Card" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Location" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Internet" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Media" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Pricing" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Profile" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Proxy" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Publish" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Radio" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Rental System" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : SAP Listener" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Service" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : SmartCard Reader" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Startup" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Survey" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Telephony System" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Terminal UI Menu" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : TV" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Upsell" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : UrlConfig" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Site App : Wallet" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Call Centre" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Call Centre PHP : Call Centre UI" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Call Centre Apps" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Call Centre App : Location" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Call Centre App : Central" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Call Centre UI Apps" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Call Centre UI App : Authentication" project
[info] [GitCommitIdMojo] Injecting Git properties to "MyProject Installer" project

@ktoso ktoso closed this in 01b3fbd Mar 25, 2013
@ktoso
Copy link
Collaborator

ktoso commented Mar 25, 2013

Finally pushed this ;) Will test a bit more though before releasing a stable version with it.

@kwin
Copy link

kwin commented Mar 9, 2015

This should definitely not be the default (i.e. it should be disabled by default, because that will propagate all(!) properties to all maven modules). See #108.

@sfisque
Copy link

sfisque commented Aug 14, 2015

there appears to be an edge case bug. i have a project that is originally PHP, and in a sub directory under the root of the original sandbox, we have a new spring-boot conversion, that is pom driven. the original project (being php) has no pom and is not "built" but merely deployed "as is". i found that i had to set injectAllReactorProjects to true, otherwise the properties were not expanded during resource filtering (vars remained ${git.var.name} rather than the expanded value). this seems counter intuitive since the project only has a single pom, even though it is located in a subdirectory below the git repository root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants