I'm trying to use the <spdx-gradle-plugin> but I'm...
# community-support
b
I'm trying to use the spdx-gradle-plugin but I'm getting an error trying to extend it. Here's the relevant snippet:
Copy code
spdxSbom {
    targets {
        create("release") {
            configurations.set(["projectCustReleaseRuntimeClasspath"])
        }
    }
}

python.pip 'spdx_tools:0.8.3'

tasks.register("convertSpdxRelease", PythonTask) {
    ...
}
spdxSbomForRelease.finalizedBy convertSpdxRelease
convertSpdxRelease.dependsOn spdxSbomForRelease
and here is the error:
Copy code
* What went wrong:
A problem occurred evaluating root project 'CustKeyboard_Studio'.
> Could not create task ':spdxSbomForRelease'.
   > Configuration with name 'projectCustReleaseRuntimeClasspath' not found.
The task works fine if I comment out the
configurations.set(...
or if I comment out both the
finalizedBy
and
dependsOn
statements. Anyone have a clue as to why that might be?
n
The error explains that the
projectCustReleaseRuntimeClasspath
configuration does not exist. Where do you expect this configuration is being created? That's missing from the snippet you shared.
b
Where do you expect this configuration is being created?
I don't have any expectations, I don't usually work with Gradle, this is all new to me.
I've no idea where it's created
n
then how did you decide that was the configuration name to pass in to the spdxSbom target?
b
I didn't, someone else wrote that part
n
then you should probably ask that person where the configuration is supposed to come from and why it's not available in the context you're trying to use it. I don't have that insight with the limited information provided, unfortunately.
v
Did somone write this in the build you are dealing with so the build is expected to run as it is? Or did someone wrote some example or template or blog or similar that you reuse / adapt? In the latter case it might be that the configuration name was meant as a placeholder to be filled in with the "project custom release runtime classpath" that it might have, however it might be called in that project.
b
the configuration name isn't a placeholder; with it, the SPDX that's generated contains all of the dependencies, as expected; without it, it contains no dependencies
v
Can you elaborate on that please? You said that it fails to find the configuration. Now you say that only with the configuration it is working.
b
🙄
v
Why are you rolling your eyes?
Is it really too much to ask for clarification if you contradict yourself?
b
if I make it so that the task works, by removing the parts of the build file that stop it working, then I can run the task with or without the configuration specified
v
Which task?
b
:spdxSbomForRelease
n
I think somehow the
convertSpdxRelease
task might be causing some early evaluation in the spdx plugin, but that's really just guessing. As I said, I think you're not giving us enough context to really get to the bottom of this. I don't think that is because you don't want to, but you don't have enough context yourself. That's why I would urge you to contact the person that wrote the original configuration for the spdxSbom. Otherwise you'll have to share a lot more about your build (if you can share a build scan, that would be ideal: https://gradle.com/scans/gradle/)
👆 1
v
Maybe the configuration is created later on and you breaking task-configuration avoidance by using eager API might trigger this problem. Try to not do
Copy code
tasks.register("convertSpdxRelease", PythonTask) {
    ...
}
spdxSbomForRelease.finalizedBy convertSpdxRelease
convertSpdxRelease.dependsOn spdxSbomForRelease
but
Copy code
def convertSpdxRelease = tasks.register("convertSpdxRelease", PythonTask) {
    ...
    dependsOn tasks.named("spdxSbomForRelease")
}
tasks.named("spdxSbomForRelease") {
    finalizedBy convertSpdxRelease
}
☝️ 1
b
@Vampire that works, thanks
👌 1