From 6f6b7a220fb3867382d8063a17b934528f528778 Mon Sep 17 00:00:00 2001 From: Cory Klein Date: Wed, 27 Aug 2025 14:58:38 -0600 Subject: [PATCH] feat: move extra logging to info level Currently the plugin prints out 5 separate log messages describing refs, configurations, versions, and describeTagFirstParent, plus a newline. This is in addition to printing out the actual fully resolved version. The vast majority of the time this information is not valuable, but it gets printed even when running other gradle tasks (like compile!) in a project that uses this plugin. This commit moves these messages to the info log level so they are not printed by default all the time, and instead only become visible if you add the --info (or lower) log level. --- README.md | 2 ++ .../GitVersioningPluginExtension.java | 23 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2484be7..418b8e2 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,8 @@ gitVersioning.apply { } ``` +**Controlling Verbosity:** Use Gradle's `--info` flag to see detailed versioning configuration output. + ### Configuration Options - `disable` global disable(`true`)/enable(`false`) extension, default is `false`. diff --git a/src/main/java/me/qoomon/gradle/gitversioning/GitVersioningPluginExtension.java b/src/main/java/me/qoomon/gradle/gitversioning/GitVersioningPluginExtension.java index 46751ed..c669022 100644 --- a/src/main/java/me/qoomon/gradle/gitversioning/GitVersioningPluginExtension.java +++ b/src/main/java/me/qoomon/gradle/gitversioning/GitVersioningPluginExtension.java @@ -123,33 +123,34 @@ private void apply() throws IOException { return; } - project.getLogger().lifecycle("matching ref: " + gitVersionDetails.getRefType().name() + " - " + gitVersionDetails.getRefName()); + + project.getLogger().info("matching ref: " + gitVersionDetails.getRefType().name() + " - " + gitVersionDetails.getRefName()); final RefPatchDescription patchDescription = gitVersionDetails.getPatchDescription(); - project.getLogger().lifecycle(" ref configuration: " + gitVersionDetails.getRefType().name() + " - pattern: " + patchDescription.pattern); + project.getLogger().info(" ref configuration: " + gitVersionDetails.getRefType().name() + " - pattern: " + patchDescription.pattern); if (patchDescription.version != null) { - project.getLogger().lifecycle(" version: " + patchDescription.version); + project.getLogger().info(" version: " + patchDescription.version); } if (!patchDescription.properties.isEmpty()) { - project.getLogger().lifecycle(" properties:"); - patchDescription.properties.forEach((key, value) -> project.getLogger().lifecycle(" " + key + ": " + value)); + project.getLogger().info(" properties:"); + patchDescription.properties.forEach((key, value) -> project.getLogger().info(" " + key + ": " + value)); } if (patchDescription.describeTagPattern != null) { - project.getLogger().lifecycle(" describeTagPattern: " + patchDescription.describeTagPattern); + project.getLogger().info(" describeTagPattern: " + patchDescription.describeTagPattern); gitSituation.setDescribeTagPattern(patchDescription.getDescribeTagPattern()); } if (patchDescription.describeTagFirstParent != null) { - project.getLogger().lifecycle(" describeTagFirstParent: " + patchDescription.describeTagFirstParent); + project.getLogger().info(" describeTagFirstParent: " + patchDescription.describeTagFirstParent); gitSituation.setFirstParent(patchDescription.describeTagFirstParent); } boolean updateGradleProperties = getUpdateGradlePropertiesOption(patchDescription); if (updateGradleProperties) { - project.getLogger().lifecycle(" updateGradleProperties: true"); + project.getLogger().info(" updateGradleProperties: true"); } globalFormatPlaceholderMap = generateGlobalFormatPlaceholderMap(gitSituation, gitVersionDetails, project); Map gitProjectProperties = generateGitProjectProperties(gitSituation, gitVersionDetails); - project.getLogger().lifecycle(""); + project.getLogger().info(""); project.getAllprojects().forEach(project -> { final String originalProjectVersion = project.getVersion().toString(); @@ -157,9 +158,9 @@ private void apply() throws IOException { if (versionFormat != null) { updateVersion(project, versionFormat); if(project == project.getRootProject()) { - project.getLogger().lifecycle("project version: " + project.getVersion()); + project.getLogger().info("project version: " + project.getVersion()); } else if (!project.getVersion().equals(project.getRootProject().getVersion())) { - project.getLogger().lifecycle(project.getName()+ " > project version: " + project.getVersion()); + project.getLogger().info(project.getName()+ " > project version: " + project.getVersion()); } }