Reading runtime configurations

Hello, i am working on a multiproject and i have a problem when trying to write each subproject’s dependencies into the jar’s manifests, here is my code:

configurations {
    subproject {
        transitive = true
    }
}

dependencies {
    subprojects.each { sp ->
        subproject sp
    }
}

subprojects{
        def deps=""

        configurations.compile.each{
            deps = deps + file(it).name + " ";                //just the jar name
        }
        
        configurations.runtime.each{
            deps = deps + file(it).name + " ";            //just the jar name
         }
        
        manifest {
           ... ,
           "Class-Path": deps
        }
    }
...
}

but every time when i try to build my jar files, i get an error:
"you can’t change a configuration which is not in unresolved state"
I also tried putting the the jar task’s corpse into doLast , doFirst, but either i get an empty manifest or the same error…
Please help