问题描述
项目-这是bundle.gradle和settings.gradle所在的地方。
bundle1
bundle2
bundle3
.
.
.
每个捆绑包中没有build.gradle。每个捆绑软件都是Osgi捆绑软件,由bnd插件构建。
settings.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.3.1'
}
}
apply plugin: 'biz.aQute.bnd.workspace'
build.gradle
subprojects {
apply plugin: 'pmd'
apply plugin: 'maven-publish'
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
def bndplugin = files(configurations.classpath.files)
}
pmd {
consoleOutput = true
toolVersion = "6.27.0"
reportsDir = file("pmd/reports")
ruleSets = ["${sbDir}/pmd/rules/Custom.xml"]
ignoreFailures = true
}
}
构建过程很好。它可以编译并生成jar,没有任何问题。似乎bnd插件会从每个捆绑包中的每个bnd文件配置类路径,并且可以毫无问题地编译Java文件。
问题出在PMD代码分析上。它从多个包中抛出java.lang.NoClassDefFoundError。当我为抛出PMDException错误的包运行“依赖项”时。因此,当我从引发错误的捆绑包中打开报告文件时,看到“原因:java.lang.TypeNotPresentException:键入com.xx.xx.xxx.ISynergy不存在”。捆绑软件似乎没有明确引用此接口,但捆绑软件似乎已隐式引用了该接口。
我注意到它说'没有依赖'。
annotationProcessor - Annotation processors and their dependencies for source set 'main'.
No dependencies
apiElements - API elements for main. (n)
No dependencies
archives - Configuration for archive artifacts.
No dependencies
compileClasspath - Compile classpath for source set 'main'.
No dependencies
compileOnly - Compile only dependencies for source set 'main'. (n)
No dependencies
default - Configuration for default artifacts.
No dependencies
implementation - Implementation only dependencies for source set 'main'. (n)
No dependencies
pmd - The PMD libraries to be used for this project.
\--- net.sourceforge.pmd:pmd-java:6.27.0
+--- net.sourceforge.pmd:pmd-core:6.27.0
| +--- org.antlr:antlr4-runtime:4.7
| +--- com.beust:jcommander:1.48
| +--- commons-io:commons-io:2.6
| +--- net.sourceforge.saxon:saxon:9.1.0.8
| +--- org.apache.commons:commons-lang3:3.8.1
| +--- org.ow2.asm:asm:9.0-beta
| \--- com.google.code.gson:gson:2.8.5
+--- net.sourceforge.saxon:saxon:9.1.0.8
+--- org.ow2.asm:asm:9.0-beta
+--- commons-io:commons-io:2.6
\--- org.apache.commons:commons-lang3:3.8.1
runtimeClasspath - Runtime classpath of source set 'main'.
No dependencies
我猜想那是因为每个捆绑软件中都没有'build.gradle'吗?我不确定。我读到PMD使用java类的字节码而不是Java源文件。 PMD无法以某种方式看到类路径。我打算用一些简单的捆绑包来复制这个问题,但是由于复杂的类路径,我无法做到。
我不确定我对PMD对类路径的可见性分析是否正确。有人对这个问题有任何想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)