Skip to content

Commit baa9733

Browse files
committed
properly wire task dependency with processResources instead of Java source dir
Changed from incorrectly setting the output file as a Java source directory to properly wiring the task dependency with processResources. This ensures the generated git.properties is correctly included as a resource in the final artifact instead of being treated as Java source code.
1 parent 537696a commit baa9733

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,14 @@ public void apply(Project project) {
179179
classesTask -> classesTask.dependsOn(taskProvider));
180180

181181
project.getPlugins().withType(JavaPlugin.class, javaPlugin -> {
182-
SourceSetContainer sourceSets =
183-
project.getExtensions().getByType(SourceSetContainer.class);
184-
SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
185-
main.getJava().setSrcDirs(Arrays.asList(task.getOutput().getAsFile().get()));
182+
// Configure processResources to include the generated git.properties
183+
project.getTasks().named(JavaPlugin.PROCESS_RESOURCES_TASK_NAME).configure(
184+
processResourcesTask -> {
185+
processResourcesTask.dependsOn(taskProvider);
186+
// Add the output directory as a source for resources
187+
processResourcesTask.getInputs().file(taskProvider.get().getOutput());
188+
}
189+
);
186190
});
187191

188192
// Expose the generated properties

0 commit comments

Comments
 (0)