neoforged / GradleUtils

Gradle buildscript utility library for NeoForged projects
GNU Lesser General Public License v2.1
1 stars 5 forks source link

Add support for using `git` CLI when available #1

Open sciwhiz12 opened 1 year ago

sciwhiz12 commented 1 year ago

JGit has some feature holes/defects -- in particular, it lacks support for git work-trees and has so for a long time.

This PR adds support for using the git CLI when it is available, with support for falling back to JGit when not. This means features like work-trees are recognized and work properly.

TODO

marchermans commented 11 months ago

This might need a toggle/override. If the configuration cache is enabled, then we are not allowed to execute commands like git for versioning.

zml2008 commented 11 months ago

you can run external processes by using ExecOperations - and/or a custom ValueSource on a Provider

marchermans commented 11 months ago

You can't at the moment because the projects version property does not support it.....

Even jgit currently throws up the error as it turns out. Because it invokes git as well

sciwhiz12 commented 11 months ago

I'm not fully sure what you mean by what isn't supported by the Project.version property?

Although the project version property isn't a full Property<String>, it is somewhat flexible because it's actually stored as an Object which is toStringed on use. I don't remember where I did it, but I recall having using that flexibility to set the project version to a GitVersion object, which lazily calculates the version when it's toStringed.

lukebemish commented 5 months ago

This might need a toggle/override. If the configuration cache is enabled, then we are not allowed to execute commands like git for versioning.

If the configuration cache is enabled, using the git cli is isn't that hard - just use a ValueSource or two that takes an ExecOperations and call it a day. I'd recommend switching entirely to the git cli - if you use jgit sometimes and the git cli other times you risk inconsistent behavior causing weirdness