Skip to content

Commit 08c5f33

Browse files
author
TheSnoozer
committed
instead of having some 'internal' git properties file, just drop the idea of having the properties optional so the closure to expose them to the project can remain working
1 parent 6157eba commit 08c5f33

4 files changed

Lines changed: 6 additions & 55 deletions

File tree

src/main/java/io/github/git/commit/id/gradle/plugin/GitCommitIdPlugin.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ public String toString() {
9292
private Properties getProps() {
9393
try {
9494
final Properties p = GenericFileManager.readPropertiesAsUtf8(
95-
// task.getGitCommitIdPluginOutputSettingsExtension().getOutputFormat().get(),
96-
CommitIdPropertiesOutputFormat.PROPERTIES,
97-
task.getInternalOutput().getAsFile()
95+
task.getGitCommitIdPluginOutputSettingsExtension().getOutputFormat().get(),
96+
task.getOutput().getAsFile().get()
9897
);
9998
return p;
10099
} catch (GitCommitIdExecutionException e) {

src/main/java/io/github/git/commit/id/gradle/plugin/GitCommitIdPluginGenerationTask.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import javax.annotation.Nullable;
3030
import org.gradle.api.DefaultTask;
3131
import org.gradle.api.file.DirectoryProperty;
32-
import org.gradle.api.file.RegularFile;
3332
import org.gradle.api.file.RegularFileProperty;
3433
import org.gradle.api.plugins.ExtensionAware;
3534
import org.gradle.api.tasks.CacheableTask;
@@ -46,7 +45,6 @@
4645
import pl.project13.core.git.GitDescribeConfig;
4746
import pl.project13.core.log.LogInterface;
4847
import pl.project13.core.util.BuildFileChangeListener;
49-
import pl.project13.core.util.GenericFileManager;
5048

5149
/**
5250
* The task that generates the "git" information.
@@ -125,11 +123,6 @@ public RegularFileProperty getOutput() {
125123
return getGitCommitIdPluginOutputSettingsExtension().getOutputFile();
126124
}
127125

128-
@OutputFile
129-
public RegularFile getInternalOutput() {
130-
return getProject().getLayout().getBuildDirectory().file("internal_git.properties").get();
131-
}
132-
133126
/**
134127
* The task action that ties it all together and runs the underlying logic of gathering the data
135128
* and exporting it to the relevant locations.
@@ -287,8 +280,7 @@ public File getDotGitDirectory() {
287280

288281
@Override
289282
public boolean shouldGenerateGitPropertiesFile() {
290-
return getGitCommitIdPluginOutputSettingsExtension()
291-
.getShouldGenerateOutputFile().get();
283+
return true;
292284
}
293285

294286
@Override
@@ -355,17 +347,6 @@ public boolean shouldPropertiesEscapeUnicode() {
355347
try {
356348
Properties properties = new Properties();
357349
pl.project13.core.GitCommitIdPlugin.runPlugin(cb, properties);
358-
359-
GenericFileManager.dumpProperties(
360-
null,
361-
CommitIdPropertiesOutputFormat.PROPERTIES,
362-
getInternalOutput().getAsFile(),
363-
StandardCharsets.UTF_8,
364-
false,
365-
null,
366-
properties
367-
);
368-
369350
// When we want to use it as TaskInput or something,
370351
// it should be convert to a hashmap, excluding build_time
371352
/*

src/main/java/io/github/git/commit/id/gradle/plugin/GitCommitIdPluginOutputSettingsExtension.java

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public abstract class GitCommitIdPluginOutputSettingsExtension {
4949
* <pre>
5050
* gitCommitId {
5151
* outputSettings {
52-
* shouldGenerateOutputFile.set(true)
52+
* outputFile.set(project.getLayout().buildDirectory.file("git.properties"))
5353
* }
5454
* }
5555
* </pre>
@@ -58,23 +58,11 @@ public abstract class GitCommitIdPluginOutputSettingsExtension {
5858
*/
5959
public static final String NAME = "outputSettings";
6060

61-
/**
62-
* Configuration option to enable or disable the generation of an output file.
63-
* To enable such generation, set this to {@code true}.
64-
* By default, this setting is disabled (set to {@code false}).
65-
*
66-
* <p>To configure the location of the output file refer to
67-
* {@link #getOutputFile()}, to configure the format (json, properties, ...)
68-
* of this file refer to {@link #getOutputFormat()}.
69-
*/
70-
public abstract Property<Boolean> getShouldGenerateOutputFile();
71-
7261
/**
7362
* Configuration location of an output file that can be generated by the plugin.
7463
* Defaults to {@code ${project.getBuildDir()}/git.properties}, formatted as "properties" file.
7564
*
76-
* <p>To enable or disable the generation of such output file refer to
77-
* {@link #getShouldGenerateOutputFile()}, to configure the format (json, properties, ...)
65+
* <p>To configure the format (json, properties, ...)
7866
* of this file refer to {@link #getOutputFormat()}.
7967
*/
8068
// @OutputFile
@@ -107,9 +95,7 @@ public abstract class GitCommitIdPluginOutputSettingsExtension {
10795
/**
10896
* Allows to configure the format (json, properties, ...) in which the output file
10997
* should be saved in.
110-
* To enable or disable the generation of such properties file refer to
111-
* {@link #getShouldGenerateOutputFile()} and to configure the location
112-
* of the properties file refer to {@link #getOutputFile()}.
98+
* To configure the location of the properties file refer to {@link #getOutputFile()}.
11399
*
114100
* <p>By default will assume that the desired format is "properties".
115101
*/
@@ -125,8 +111,6 @@ public ProjectLayout getProjectLayout() {
125111
*/
126112
@Inject
127113
public GitCommitIdPluginOutputSettingsExtension() {
128-
getShouldGenerateOutputFile()
129-
.convention(false);
130114
getOutputFile().convention(
131115
getProjectLayout().getBuildDirectory().file("git.properties"));
132116
getShouldEscapedUnicodeForPropertiesOutput().convention(false);

src/test/groovy/io.github.git.commit.id.gradle.plugin/GradleIntegrationTest.groovy

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,6 @@ class GradleIntegrationTest extends AbstractGradleTest {
8181
// https://docs.gradle.org/current/userguide/build_cache.html#sec:build_cache_enable
8282
new File(projectDir, "gradle.properties") << "org.gradle.caching=true"
8383

84-
and: "we produce a git properties file"
85-
new File(projectDir, "build.gradle").withWriterAppend("UTF-8") {
86-
it.write(
87-
"""
88-
${GitCommitIdPluginExtension.NAME} {
89-
outputSettings {
90-
shouldGenerateOutputFile.set(true)
91-
}
92-
}
93-
""".stripIndent()
94-
)
95-
}
96-
9784
when: "running the plugin"
9885
def runner = createRunner(projectDir)
9986

0 commit comments

Comments
 (0)