diff --git a/changelog/@unreleased/pr-717.v2.yml b/changelog/@unreleased/pr-717.v2.yml new file mode 100644 index 00000000..f56221b4 --- /dev/null +++ b/changelog/@unreleased/pr-717.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Add debug logs for ./gradlew printVersion + links: + - https://github.com/palantir/gradle-git-version/pull/717 diff --git a/src/main/java/com/palantir/gradle/gitversion/Git.java b/src/main/java/com/palantir/gradle/gitversion/Git.java index fcc417eb..c637c637 100644 --- a/src/main/java/com/palantir/gradle/gitversion/Git.java +++ b/src/main/java/com/palantir/gradle/gitversion/Git.java @@ -58,6 +58,7 @@ private String runGitCmd(Map envvars, String... commands) throws List cmdInput = new ArrayList<>(); cmdInput.add("git"); cmdInput.addAll(Arrays.asList(commands)); + log.debug("Running command: {}", cmdInput); ProcessBuilder pb = new ProcessBuilder(cmdInput); Map environment = pb.environment(); environment.putAll(envvars); @@ -80,7 +81,9 @@ private String runGitCmd(Map envvars, String... commands) throws return ""; } - return builder.toString().trim(); + String ret = builder.toString().trim(); + log.debug("Command returned value: {}", ret); + return ret; } public String runGitCommand(Map envvar, String... command) { diff --git a/src/main/java/com/palantir/gradle/gitversion/GitVersionPlugin.java b/src/main/java/com/palantir/gradle/gitversion/GitVersionPlugin.java index 4ecec13e..dac5b0f9 100644 --- a/src/main/java/com/palantir/gradle/gitversion/GitVersionPlugin.java +++ b/src/main/java/com/palantir/gradle/gitversion/GitVersionPlugin.java @@ -22,9 +22,13 @@ import org.gradle.api.Project; import org.gradle.api.Task; import org.gradle.api.provider.Provider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class GitVersionPlugin implements Plugin { + private static final Logger log = LoggerFactory.getLogger(GitVersionPlugin.class); + @Override public void apply(final Project project) { project.getRootProject().getPluginManager().apply(GitVersionRootPlugin.class); @@ -50,7 +54,9 @@ public VersionDetails doCall(Object args) { @Override @SuppressWarnings("BanSystemOut") public void execute(Task _task) { - System.out.println(project.getVersion()); + Object version = project.getVersion(); + log.debug("Determined version for project {} is {}", project.getName(), version); + System.out.println(version); } }); printVersionTask.setGroup("Versioning");