當通過Gradle運行PMD任務時,我得到NoClassDefFoundError
。從Gradle運行PMD任務時獲取NoClassDefFoundError
我有pmd-5.1.1.jar
,commons-io-1.4.jar
以及WebContent/WEB-INF/lib
目錄中的所有其他jars
。我的Java文件在目錄src\com\company\project
搖籃構建文件
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'pmd'
sourceSets.main.java.srcDirs = ['src']
webAppDirName = 'WebContent'
repositories {
flatDir { dirs "WebContent/WEB-INF/lib" }
}
dependencies {
providedCompile fileTree(dir: "WebContent/WEB-INF/lib", include: '*.jar')
}
war {
archiveName "ROOT.war"
}
錯誤日誌
C:\MyWorkspace\MyProject>gradle build
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:war UP-TO-DATE
:assemble UP-TO-DATE
:pmdMain FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':pmdMain'.
> java.lang.NoClassDefFoundError: org/apache/commons/io/IOUtils
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 5.275 secs
這是第一次我想搖籃。我能夠構建以及生成WAR,但PMD讓我失望。有人可以告訴我我做錯了什麼嗎?在此先感謝:)
是的,這是問題所在。您不應該在'WEB-INF/lib'下放置依賴關係。 – Opal