@@ -18,9 +18,23 @@ class KestraSpotlessConventionsPlugin implements Plugin<Project> {
1818
1919 @Override
2020 void apply (Project project ) {
21- project. plugins. apply(' com.diffplug.spotless' )
2221 ClassLoader pluginClassLoader = this . getClass(). getClassLoader()
2322
23+ // Ensure spotless-config files exist during configuration so Spotless doesn't try to read missing files
24+ File initialSpotlessDir = project. layout. buildDirectory. dir(' spotless-config' ). get(). asFile
25+ [' eclipse-kestra.importorder' , ' eclipse-java-kestra-style.xml' ]. each { fileName ->
26+ URL resource = pluginClassLoader. getResource(" spotless/${ fileName} " )
27+ if (resource != null ) {
28+ File target = new File (initialSpotlessDir, fileName)
29+ target. parentFile. mkdirs()
30+ if (! target. exists()) {
31+ target. text = resource. getText(' UTF-8' )
32+ }
33+ }
34+ }
35+
36+ project. plugins. apply(' com.diffplug.spotless' )
37+
2438 def extractSpotlessConfig = project. tasks. register(' extractSpotlessConfig' ) { task ->
2539 File spotlessDir = project. layout. buildDirectory. dir(' spotless-config' ). get(). asFile
2640 task. outputs. dir(spotlessDir)
@@ -55,6 +69,7 @@ class KestraSpotlessConventionsPlugin implements Plugin<Project> {
5569 task. commandLine(' sh' , ' -c' , ' chmod +x .github/.hooks/setup_hooks.sh .github/.hooks/pre-commit && ./.github/.hooks/setup_hooks.sh' )
5670 } else {
5771 task. enabled = false
72+ project. logger. lifecycle(' [KestraSpotless] No .git directory found; skipping hook activation to avoid executing git-related commands in non-git projects' )
5873 }
5974
6075 task. doFirst {
0 commit comments