Gradle 你可以';t更改配置';提供运行时';因为它已经解决了

Gradle 你可以';t更改配置';提供运行时';因为它已经解决了,gradle,Gradle,我将Gradle2.0与Groovy 2.3.3一起使用。 当我运行下面的构建时,我得到错误>您无法更改配置“ProviderRuntime”,因为它已被解决 另外,我建议它与+=有关,但是,我没有使用该运算符,所以我有点困惑 apply plugin: 'war' repositories { mavenCentral() } //We don't want transitive dependencies added as we are matching a third-party

我将Gradle2.0与Groovy 2.3.3一起使用。 当我运行下面的构建时,我得到错误
>您无法更改配置“ProviderRuntime”,因为它已被解决

另外,我建议它与
+=
有关,但是,我没有使用该运算符,所以我有点困惑

apply plugin: 'war'

repositories {
    mavenCentral()
}

//We don't want transitive dependencies added as we are matching a third-party build
configurations.all {
    transitive = false
}

war  {
    archiveName='gradle.war'

    from(configurations.providedRuntime.files) {
      into "app-jars"
    }
    classpath fileTree('webinf-libs') // adds a file-set to the WEB-INF/lib dir.
}

dependencies {
  providedRuntime group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.2'
}

将war配置更改为:

war  {
    archiveName='gradle.war'

    from(configurations.providedRuntime) {
      into "app-jars"
    }
    classpath fileTree('webinf-libs') // adds a file-set to the WEB-INF/lib dir.
}
这将解决问题

出现此问题的原因是在
war
配置块中调用了
文件
,然后将依赖项添加到providedRuntime。由于调用
文件
可以解析配置(并且
war
块在配置阶段进行评估),因此以后无法修改

您还可以更改
依赖项
war
的顺序,它们将是相同的