无法获取 org.gradle.api.internal.artifacts.configurations 类型的配置容器的未知属性“runtime”
当我按照如何使用gradle复制所有源jars的答案时,我得到了错误(无法为org.gradle.api.internal.artifacts.configurations.类型的配置容器获取未知属性“runtime”),并在IJ IDEA中运行该任务:
task copySourceJars( type: Copy ) {
def sources = configurations.runtime.resolvedConfiguration.resolvedArtifacts.collect { artifact ->
project.dependencies.create( [
group: artifact.moduleVersion.id.group,
name: artifact.moduleVersion.id.name,
version: artifact.moduleVersion.id.version,
classifier: 'sources'
] )
}
from configurations.detachedConfiguration( sources as Dependency[] )
.resolvedConfiguration.lenientConfiguration.getFiles( Specs.SATISFIES_ALL )
into file( 'some-directory/' )
}
我对错误进行了网络搜索,但在stackoverflow上只找到了Gradle - 无法为配置容器获取未知属性“scm”,建议像我在阅读该帖子后所做的那样添加配置:
configurations {
runtime
}
之后,在任务运行时,它写了构建成功,但没有文件出现在硬盘驱动器上的特定目录中。由于某种原因,构建输出未列出:copySourceJars
copySourceJars
Executing tasks: [:app:generateDebugSources]
Gradle Daemon started in 1 s 427 ms
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:checkDebugManifest UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:prepareLintJar UP-TO-DATE
> Task :app:generateDebugSources UP-TO-DATE
BUILD SUCCESSFUL in 9s
4 actionable tasks: 4 up-to-date
然后我再次从IDEA菜单中选择,并得到另一个错误:run
无法打开 dulrvlqnmf04w7h3gseaejvhm 的 init remapped class cache (/Users/user/.gradle/caches/5.2.1/scripts-remapped/ijresolvers_8btlazswoejgb1uwugudd695x/dulrvlqnmf04w7h3gseaejvhm/init3ca90766b0adfce53d4b035e7e9dc5fe).
无法为初始化脚本 '/private/var/folders/g7/2zrjv4hd04v4vkhkbm3stchjwwbz27/T/ijresolvers.gradle' (/Users/user/.gradle/caches/5.2.1/scripts/dulrvlqnmf04w7h3gseaejvhm/init/init3ca90766b0adfce53d4b035e7e9dc5fe) 打开 init 泛型类缓存。错误!源单元“BuildScript”中的“语义分析”阶段中的异常 不支持的类文件主要版本 57
我是否正确地使用IJ IDEA下载依赖项?也许添加配置没有正确完成?runtime