Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在init.gradle脚本中应用插件配置_Gradle_Init_Gradle Plugin - Fatal编程技术网

在init.gradle脚本中应用插件配置

在init.gradle脚本中应用插件配置,gradle,init,gradle-plugin,Gradle,Init,Gradle Plugin,我想在本地为我的所有项目安装一些软件包,例如依赖性分析。但我需要实际配置插件-也在init脚本中 initscript { repositories { jcenter() } dependencies { classpath "ca.cutterslade.gradle:gradle-dependency-analyze:1.3.0" } } allprojects { apply plugin: ca.cutterslade.gra

我想在本地为我的所有项目安装一些软件包,例如依赖性分析。但我需要实际配置插件-也在init脚本中

initscript {
    repositories {
      jcenter()
    }
    dependencies {
      classpath "ca.cutterslade.gradle:gradle-dependency-analyze:1.3.0"
    }
}
allprojects {
  apply plugin: ca.cutterslade.gradle.analyze.AnalyzeDependenciesPlugin
}
这个init脚本工作正常并应用插件,但不幸的是,默认设置是插件无法生成。我只想记录一个警告

为此,我需要添加配置:

analyzeClassesDependencies {
  justWarn = true
}

analyzeTestClassesDependencies {
  justWarn = true
}
但当我尝试将其添加到init.gradle文件中时:

initscript {
    repositories {
      jcenter()
    }
    dependencies {
      classpath "ca.cutterslade.gradle:gradle-dependency-analyze:1.3.0"
    }
}
allprojects {
  apply plugin: ca.cutterslade.gradle.analyze.AnalyzeDependenciesPlugin
  analyzeClassesDependencies {
    justWarn = true
  }

  analyzeTestClassesDependencies {
    justWarn = true
  }
}
我得到一个错误:

FAILURE: Build failed with an exception.

* Where:
Initialization script '/Users/<my-user>/.gradle/init.gradle' line: 13

* What went wrong:
Could not find method analyzeClassesDependencies() for arguments [init_2y9p9if69e8553k9fsvzz4a28$_run_closure1$_closure2@3e17c37a] on root project 'my-project' of type org.gradle.api.Project.
失败:生成失败,出现异常。
*其中:
初始化脚本'/Users/.gradle/init.gradle'行:13
*出了什么问题:
找不到参数[init_2y9p9if69e8553k9fsvzz4a28$\u run\u closure1]的方法AnalyzeClasseDependencies()$_closure2@3e17c37a]在org.gradle.api.project类型的根项目“我的项目”上。
有人知道我如何应用插件配置吗?
我尝试了,但没有得到任何答案,因此我希望在这里获得更多帮助:)

AnalyzeDependenciesPlugin
将根据应用于项目的插件添加不同的任务。例如,
analyzeClassesDependencies
analyzeTestClassesDependencies
仅在应用
java
插件时才会声明(请参见此处如何实现此插件:)

因此,在
allprojects
配置闭包中应用
AnalyzeDependenciesPlugin
之前,只需应用
java
插件即可:

allprojects {
    apply plugin: "java" // <= apply Java plugin here
    apply plugin: ca.cutterslade.gradle.analyze.AnalyzeDependenciesPlugin
    analyzeClassesDependencies {
        justWarn = true
    }
    analyzeTestClassesDependencies {
        justWarn = true
    }
}
所有项目{

apply plugin:“java”//initscript
块中也有一个错误(可能只是从您的项目中复制/粘贴):依赖项
块位于附加的/不需要的
存储库中
block@M.Ricciuti谢谢,是的,这是一个复制粘贴错误,sorryOk。我在下面的回答中解释了真正的问题