gpt4 book ai didi

maven - 应用Gradle Dependency-Check插件

转载 作者:行者123 更新时间:2023-12-03 04:37:26 25 4
gpt4 key购买 nike

我正在尝试使用以下链接中的dependency.check,并且在按照给出的说明进行操作时无法(完全)正常运行。

https://github.com/jeremylong/DependencyCheck/tree/master/dependency-check-gradle

尝试使用apply插件和其他依赖项进行构建时,启动失败,并引发以下错误。

  • Where: Build file '/Users/aaron/work/backups/eiss/build.gradle' line: 25

  • What went wrong: A problem occurred evaluating root project 'eiss'. Failed to apply plugin [id 'dependency.check'] Plugin with id 'dependency.check' not found.



进行一些更改时,我取得了一些进步,但最终还是没有成功。

首先,我注释了Apply插件行。

接下来,我切换:
classpath "com.thoughtworks.tools:dependency-check:0.0.7"
到:
compile "com.thoughtworks.tools:dependency-check:0.0.7"
经过这两个更改,它开始识别路径,并且我能够看到它从存储库中获取了项目。

即使路径正确,我仍然会遇到Apply插件行的问题,每当我将其放入脚本中甚至尝试更改“。”时,它都会引发相同的错误。放入“-”(在说明和不同的存储库示例中都使用)。

在这个问题上的任何帮助,将不胜感激!谢谢

最后是build.gradle脚本。我不想只将此帖子保留在帖子的中心。
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'
}

}

最佳答案

您在错误的位置将插件依赖项添加到了项目的依赖项中,而不是将使用它的构建脚本本身中。尝试添加buildscript依赖项,如在插件安装示例中所做的那样

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.thoughtworks.tools:dependency-check:0.0.7'
}
}

然后返回您的Apply插件
apply plugin: 'dependency.check'

关于maven - 应用Gradle Dependency-Check插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32527027/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com