Gradle:组装罐子并获得;不能更改配置的依赖项';:编译';将其包含在依赖项解决方案中后;
我有一个简单的gradle项目Gradle:组装罐子并获得;不能更改配置的依赖项';:编译';将其包含在依赖项解决方案中后;,gradle,jar,Gradle,Jar,我有一个简单的gradle项目 apply plugin: 'java' apply plugin: 'application' repositories { mavenCentral() jcenter() } task copyToLib(type: Copy) { into "$buildDir/libs/lib" from configurations.runtime } jar { dependsOn copyToLib manif
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'
}
我告诉我那件事是个错误
Cannot change dependencies of configuration ':compile' after it has been included in dependency resolution
每当我尝试gradlejar
命令时
怎么了?我该如何解决这个问题?我也遇到了同样的问题,经过一些研究,我发现您需要先将代码放入DOP中
jar {
doFirst
{
dependsOn copyToLib
manifest {
attributes (
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
)
}
}
}