我正在尝试使用以下链接中的dependency.check,并且在按照给出的说明操作时无法正常运行(根本没有)。
https://github.com/jeremylong/DependencyCheck/tree/master/dependency-check-gradle
尝试使用apply插件和其他依赖项进行构建时,启动时失败,并引发以下错误。
其中: 构建文件' /Users/aaron/work/backups/eiss/build.gradle'行:25
出了什么问题: 评估根项目'时出现问题。 无法应用插件[id' dependency.check'] 带有id' dependency.check'的插件没找到。
我在做出一些改变时取得了一些进展,但最终仍未成功。
首先,我注释了apply plugin line。
接下来,我换了:
classpath "com.thoughtworks.tools:dependency-check:0.0.7"
到:
compile "com.thoughtworks.tools:dependency-check:0.0.7"
在这两次更改之后,它开始识别路径,并且我能够看到它从存储库中抓取项目。
即使路径正确,我仍然遇到应用插件行的问题,每当我将其放入脚本时甚至尝试更改'时都会抛出同样的错误。在它里面 - ' - ' (两者都在说明和不同的存储库示例中使用)。
对此问题的任何帮助将不胜感激!感谢
最后这里是build.gradle脚本。我不想把这个blob留在帖子的中心。
defaultTasks 'assemble'
// For third party libs that are widely used, keep versions in one place
ext {
MONGO_JAVA_DRIVER = "org.mongodb:mongo-java-driver:2.12.3"
RABBITMQ_VERSION = "com.rabbitmq:amqp-client:3.4.3"
LOG4J = "log4j:log4j:1.2.16"
// For groovy there are multiple libs, just capture version number and use lib-name-$GROOVY_VERSION
GROOVY_VERSION = "2.3.6"
}
//
// Common settings for all projects
//
subprojects {
defaultTasks 'assemble'
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'codenarc'
apply plugin: 'dependency.check'
targetCompatibility = "1.6"
sourceCompatibility = "1.6"
repositories {
mavenCentral()
}
dependencies {
compile LOG4J
compile "org.codehaus.groovy:groovy:${GROOVY_VERSION}"
compile "org.codehaus.groovy:groovy-json:${GROOVY_VERSION}"
compile "org.codehaus.groovy:groovy-templates:${GROOVY_VERSION}"
compile "com.thoughtworks.tools:dependency-check:0.0.7"
testCompile group: 'junit', name: 'junit', version: '4.+'
testCompile "org.codehaus.groovy:groovy-test:${GROOVY_VERSION}"
testCompile "org.hamcrest:hamcrest-core:1.3"
}
clean.doLast {
// The archive path is configured via the jar tasks. Can't use
// delete jar.archivePath because that will configure the delete with
// the wrong (default) path of build/libs/<component.jar>
jar.archivePath.delete()
jarSources.archivePath.delete()
}
//--------------------------------------------------------------------
// Run and test
//--------------------------------------------------------------------
test {
// Uncomment to see standard output when running tests
testLogging.showStandardStreams = true
// This causes tests to run even when nothing has changed
outputs.upToDateWhen { false }
maxParallelForks = 1
}
task runClass(dependsOn: 'classes', type: JavaExec) {
if (project.hasProperty('classToRun')) {
if (project.hasProperty('arguments')) {
args(arguments.split(','))
}
classpath = sourceSets.main.runtimeClasspath
main=classToRun
}
}
//run this task to create source jars
task jarSources(type:Jar){
destinationDir = new File(projectDir.parent + "/sourcelibs")
from sourceSets.main.allSource
classifier 'sources'
}
}
答案 0 :(得分:0)
您在错误的位置添加了插件依赖项,而不是构建脚本本身,它将使用它。尝试添加buildscript依赖项,就像它在插件安装的例子中所做的那样
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.thoughtworks.tools:dependency-check:0.0.7'
}
}
然后返回您的apply插件
apply plugin: 'dependency.check'