Weird error when trying to add dependency "Cannot change configuration after it has been resolved"

When I try to compile my project with a dependency, it refused to compile with the message “Cannot change configuration ‘:Client:compile’ after it has been resolved”.
My build.gradle is

ext {
   VERSION = "no-dev0.0.0"
}

subprojects {
   apply plugin: 'java'

   jar {
      manifest {
         attributes(
            "Class-Path": project.configurations.compile.collect { it.getName() }.join(' ')
         )
      }
   }
   
   task libs(type: Copy) {
      into 'build/libs/'
      from configurations
    }
    jar.dependsOn(libs)

   repositories {
      mavenCentral()

      flatDir {
         dirs "libraries"
      }
   }
}

project("Client") {
   jar.baseName += "-" + VERSION
   jar {
      manifest {
         attributes(
            "Main-Class": "com.vidrago.client.Main"
         )
      }
   }

   dependencies {
      compile name: "lwjgl-3.0.0.a-with-natives"
      compile "com.google.code.gson:gson:2.3.1"
   }
}

It works with neither of those libraries (I just took Google Gson as example), and I am sure that the local jar exist and I don’t understand what the error is, or how I can fix it. I think I initialize the libraries to late in the live cycle, but where else?
I posted this in bugs because it is “not working as expected”, although I won’t consider it a bug., I probably just did something wrong…

Ok, nevermind: I fixed it by moving the first manifest modification into a second subproject block at the end, somehow that already resolved the dependencies and blocked them from modification. But when you think about it it makes sense…