title: Gradle : Assembling jar and getting "annot change dependencies of configuration ':compile' after it has been included in dependency resolution"
body: <p>I have simple gradle project</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'application'
  
  repositories {
      mavenCentral()
      jcenter()
  }
  
  task copyToLib(type: Copy) {
      into "$buildDir/libs/lib"
      from configurations.runtime
  }
  
  jar {
      dependsOn copyToLib
      manifest {
          attributes (
              "Class-Path": configurations.compile.collect { it.getName() }.join(' ')
          )
      }
  }
  
  dependencies {
      compile 'org.slf4j:slf4j-api:1.7.21'
      compile 'org.antlr:antlr4:4.0'
  }
  </code></pre>
  
  <p>I am getting an error telling me that </p>
  
  <pre><code>Cannot change dependencies of configuration ':compile' after it has been included in dependency resolution
  </code></pre>
  
  <p>whenever I try <code>gradle jar</code> command.</p>
  
  <p>What's wrong? How do I fix this?</p>