@@ -30,50 +30,40 @@ class FcliJavaConventionsPlugin: Plugin<Project> {
3030 }
3131
3232 // Dependencies leveraging BOM project if present
33- afterEvaluate {
34- val bomRef = findProperty(" fcliBomRef" ) as String?
35- if (bomRef != null ) {
36- dependencies.apply {
37- add(" implementation" , platform(project(bomRef)))
38- add(" annotationProcessor" , platform(project(bomRef)))
39- }
40- }
33+ val bomRef = findProperty(" fcliBomRef" ) as String?
34+ if (bomRef != null ) {
4135 dependencies.apply {
42- // Exclude slf4j transitive dependency for io.modelcontextprotocol
43- add(" implementation" , " io.modelcontextprotocol.sdk:mcp-core" ) {
44- exclude(group = " org.slf4j" , module = " slf4j-api" )
45- }
46- add(" implementation" , " io.modelcontextprotocol.sdk:mcp-json-jackson2" ) {
47- exclude(group = " org.slf4j" , module = " slf4j-api" )
48- }
49- add(" annotationProcessor" , " info.picocli:picocli-codegen" )
50- add(" compileOnly" , " com.formkiq:graalvm-annotations" )
51- add(" annotationProcessor" , " com.formkiq:graalvm-annotations-processor" )
52- add(" implementation" , " com.konghq:unirest-java" )
53- add(" implementation" , " com.konghq:unirest-objectmapper-jackson" )
54- add(" implementation" , " org.springframework:spring-expression" )
55- add(" implementation" , " org.springframework:spring-context" )
56- add(" compileOnly" , " com.google.code.findbugs:jsr305" )
57- add(" implementation" , " org.slf4j:slf4j-api" )
58- add(" implementation" , " org.slf4j:jcl-over-slf4j" )
59- add(" implementation" , " ch.qos.logback:logback-classic" )
60- add(" implementation" , " com.fasterxml.jackson.dataformat:jackson-dataformat-yaml" )
61- add(" implementation" , " com.fasterxml.jackson.dataformat:jackson-dataformat-csv" )
62- add(" implementation" , " com.fasterxml.jackson.dataformat:jackson-dataformat-xml" )
63- add(" implementation" , " com.fasterxml.jackson.datatype:jackson-datatype-jsr310" )
64- add(" implementation" , " com.fasterxml.jackson.datatype:jackson-datatype-jdk8" )
65- add(" implementation" , " com.github.freva:ascii-table" )
66- add(" implementation" , " org.jasypt:jasypt" )
67- add(" testImplementation" , " org.junit.jupiter:junit-jupiter-api" )
68- add(" testImplementation" , " org.junit.jupiter:junit-jupiter-params" )
69- add(" testRuntimeOnly" , " org.junit.jupiter:junit-jupiter-engine" )
70- add(" testRuntimeOnly" , " org.junit.platform:junit-platform-launcher" )
71- add(" implementation" , " org.apache.commons:commons-lang3:3.18.0" )
72- add(" implementation" , " org.apache.commons:commons-compress" )
73- add(" implementation" , " org.jsoup:jsoup" )
74- add(" implementation" , " org.eclipse.jgit:org.eclipse.jgit" );
36+ add(" implementation" , platform(project(bomRef)))
37+ add(" annotationProcessor" , platform(project(bomRef)))
7538 }
7639 }
40+ dependencies.apply {
41+ add(" compileOnly" , " com.formkiq:graalvm-annotations" )
42+ add(" annotationProcessor" , " com.formkiq:graalvm-annotations-processor" )
43+ add(" implementation" , " com.konghq:unirest-java" )
44+ add(" implementation" , " com.konghq:unirest-objectmapper-jackson" )
45+ add(" implementation" , " org.springframework:spring-expression" )
46+ add(" implementation" , " org.springframework:spring-context" )
47+ add(" compileOnly" , " com.google.code.findbugs:jsr305" )
48+ add(" implementation" , " org.slf4j:slf4j-api" )
49+ add(" implementation" , " org.slf4j:jcl-over-slf4j" )
50+ add(" implementation" , " ch.qos.logback:logback-classic" )
51+ add(" implementation" , " com.fasterxml.jackson.dataformat:jackson-dataformat-yaml" )
52+ add(" implementation" , " com.fasterxml.jackson.dataformat:jackson-dataformat-csv" )
53+ add(" implementation" , " com.fasterxml.jackson.dataformat:jackson-dataformat-xml" )
54+ add(" implementation" , " com.fasterxml.jackson.datatype:jackson-datatype-jsr310" )
55+ add(" implementation" , " com.fasterxml.jackson.datatype:jackson-datatype-jdk8" )
56+ add(" implementation" , " com.github.freva:ascii-table" )
57+ add(" implementation" , " org.jasypt:jasypt" )
58+ add(" testImplementation" , " org.junit.jupiter:junit-jupiter-api" )
59+ add(" testImplementation" , " org.junit.jupiter:junit-jupiter-params" )
60+ add(" testRuntimeOnly" , " org.junit.jupiter:junit-jupiter-engine" )
61+ add(" testRuntimeOnly" , " org.junit.platform:junit-platform-launcher" )
62+ add(" implementation" , " org.apache.commons:commons-lang3:3.18.0" )
63+ add(" implementation" , " org.apache.commons:commons-compress" )
64+ add(" implementation" , " org.jsoup:jsoup" )
65+ add(" implementation" , " org.eclipse.jgit:org.eclipse.jgit" );
66+ }
7767
7868 tasks.withType(org.gradle.api.tasks.compile.JavaCompile ::class ).configureEach {
7969 if (name == " compileJava" ) {
@@ -173,41 +163,50 @@ class FcliJavaConventionsPlugin: Plugin<Project> {
173163 }
174164 }
175165
176- // Resource-config generation incremental
177- tasks.register(" generateResourceConfig" ) {
178- group = " build resources"
179- description = " Generate GraalVM resource-config.json"
180- dependsOn(ensureGeneratedDirs)
181- dependsOn(generateZipResources, buildTimeActions)
182- val srcResDir = project.file(" src/main/resources" )
183- if (srcResDir.isDirectory) { inputs.dir(srcResDir) }
184- inputs.dir(generatedZipResourcesDir)
185- inputs.dir(generatedActionOutputResourcesDir)
186- val outputDirProvider = generatedResourceConfigDir.map { it.dir(" META-INF/native-image/fcli-generated/${project.name} " ) }
187- outputs.dir(outputDirProvider)
188- doLast {
189- val entries = mutableListOf<String >()
190- // Helper to add files from a base directory
191- fun addFiles (baseDir : java.io.File , tree : org.gradle.api.file.FileTree ) {
192- tree.files.filter { it.isFile }.sorted().forEach { f ->
193- val rel = f.relativeTo(baseDir).invariantSeparatorsPath
194- entries + = " \n {\" pattern\" :\" $rel \" }"
166+ // Resource-config generation — only register when module has resources to index
167+ val srcResDir = project.file(" src/main/resources" )
168+ val hasSourceResources = srcResDir.isDirectory &&
169+ project.fileTree(srcResDir) { exclude(" **/i18n/**" , " META-INF/**" , " **/zip/**" ) }.files.any()
170+ val hasActionZips = project.file(" src/main/resources/com/fortify/cli" ).let { cliRoot ->
171+ cliRoot.isDirectory && (cliRoot.listFiles()?.any { dir ->
172+ dir.isDirectory && File (dir, " actions/zip" ).isDirectory
173+ } ? : false )
174+ }
175+ if (hasSourceResources || hasActionZips) {
176+ tasks.register(" generateResourceConfig" ) {
177+ group = " build resources"
178+ description = " Generate GraalVM resource-config.json"
179+ dependsOn(ensureGeneratedDirs)
180+ dependsOn(generateZipResources, buildTimeActions)
181+ if (srcResDir.isDirectory) { inputs.dir(srcResDir) }
182+ inputs.dir(generatedZipResourcesDir)
183+ inputs.dir(generatedActionOutputResourcesDir)
184+ val outputDirProvider = generatedResourceConfigDir.map { it.dir(" META-INF/native-image/fcli-generated/${project.name} " ) }
185+ outputs.dir(outputDirProvider)
186+ doLast {
187+ val entries = mutableListOf<String >()
188+ // Helper to add files from a base directory
189+ fun addFiles (baseDir : java.io.File , tree : org.gradle.api.file.FileTree ) {
190+ tree.files.filter { it.isFile }.sorted().forEach { f ->
191+ val rel = f.relativeTo(baseDir).invariantSeparatorsPath
192+ entries + = " \n {\" pattern\" :\" $rel \" }"
193+ }
195194 }
196- }
197- val srcBase = project.layout.projectDirectory.dir( " src/main/resources " ).asFile
198- if (srcBase.isDirectory ) {
199- addFiles(srcBase, project.fileTree(srcBase) { exclude( " **/i18n/** " , " META-INF/** " , " **/zip/** " ) })
200- }
201- val genZipBase = generatedZipResourcesDir.get().asFile
202- addFiles(genZipBase, project.fileTree(genZipBase))
203- val genActionBase = generatedActionOutputResourcesDir.get().asFile
204- addFiles(genActionBase, project.fileTree(genActionBase))
205- if ( entries.isNotEmpty()) {
206- val contents = " { " + " \" resources \" :[ " + entries.joinToString( " , " ) + " \n ]} "
207- val outputDir = outputDirProvider.get().asFile. apply { mkdirs() }
208- val outFile = File (outputDir, " resource-config.json " )
209- if ( ! outFile.exists() || outFile.readText() != contents) {
210- outFile.writeText(contents)
195+ val srcBase = project.layout.projectDirectory.dir( " src/main/resources " ).asFile
196+ if (srcBase.isDirectory) {
197+ addFiles (srcBase, project.fileTree(srcBase ) { exclude( " **/i18n/** " , " META-INF/** " , " **/zip/** " ) })
198+ }
199+ val genZipBase = generatedZipResourcesDir.get().asFile
200+ addFiles(genZipBase, project.fileTree(genZipBase))
201+ val genActionBase = generatedActionOutputResourcesDir.get().asFile
202+ addFiles(genActionBase, project.fileTree(genActionBase))
203+ if (entries.isNotEmpty()) {
204+ val contents = " { " + " \" resources \" :[ " + entries.joinToString( " , " ) + " \n ]} "
205+ val outputDir = outputDirProvider.get().asFile. apply { mkdirs() }
206+ val outFile = File (outputDir, " resource-config.json " )
207+ if ( ! outFile.exists() || outFile.readText() != contents) {
208+ outFile.writeText( contents)
209+ }
211210 }
212211 }
213212 }
@@ -217,7 +216,9 @@ class FcliJavaConventionsPlugin: Plugin<Project> {
217216 named(" main" ) {
218217 output.dir(generatedZipResourcesDir, " builtBy" to generateZipResources.getName())
219218 output.dir(generatedActionOutputResourcesDir, " builtBy" to buildTimeActions.getName())
220- output.dir(generatedResourceConfigDir, " builtBy" to " generateResourceConfig" )
219+ if (hasSourceResources || hasActionZips) {
220+ output.dir(generatedResourceConfigDir, " builtBy" to " generateResourceConfig" )
221+ }
221222 }
222223 }
223224
0 commit comments