If I interpreted what you said correctly, this config:
compile 'javax.measure:unit-api:0.9'
compile 'systems.uom:systems-common-java8:0.2'
compile 'tec.uom:uom-se:0.9'
runtime 'systems.uom:systems-quantity:0.3'
produced this result upon running gradle run
:
Exception in Application start method
java.lang.reflect.InvocationTargetException
<stack trace>
Caused by: java.lang.NoClassDefFoundError: javax/measure/quantity/ElectricPermittivity
at si.uom.SI.<clinit>(SI.java:135)
at <my application>
<stack trace>
Caused by: java.lang.ClassNotFoundException: javax.measure.quantity.ElectricPermittivity
I don’t think I disabled transitive dependencies. This is the entirety of the build.gradle
file for the above invocation:
apply plugin: 'application'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
mainClassName = 'com.cres.girthweld.gui.Main'
configurations {
checkerFrameworkAnnotatedJDK {
description = 'A copy of JDK classes with Checker Framework type qualifiers inserted'
}
}
dependencies {
compile 'com.google.guava:guava:19.0'
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.slf4j:slf4j-simple:1.7.21'
compile 'javax.measure:unit-api:0.9'
compile 'systems.uom:systems-common-java8:0.2'
compile 'tec.uom:uom-se:0.9'
runtime 'systems.uom:systems-quantity:0.3'
compile 'org.checkerframework:checker-qual:2.1.0'
compile 'org.checkerframework:checker:2.1.0'
checkerFrameworkAnnotatedJDK 'org.checkerframework:jdk8:2.1.0'
testCompile 'org.testng:testng:6.9.11'
}
repositories {
jcenter()
}
test.useTestNG()
def checkerList = ['org.checkerframework.checker.nullness.NullnessChecker',
'org.checkerframework.checker.regex.RegexChecker',
'org.checkerframework.checker.signature.SignatureChecker',
'org.checkerframework.checker.guieffect.GuiEffectChecker'
]
gradle.taskGraph.whenReady {graph ->
if (graph.hasTask(tasks.buildWithCheckers)) {
compileJava {
options.debug(debugLevel: 'source,lines,vars')
options.fork = true
options.forkOptions.executable = '/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/javac'
options.compilerArgs += ['-Xlint:all',
'-Xdoclint:all',
'-Xdoclint:-missing',
'-processor',
"${checkerList.join(',')}",
'-AcheckPurityAnnotations',
'-AinvariantArrays',
'-Alint=all,-debugSpew',
'-AshowSuppressWarningKeys',
'-AcheckCastElementType',
"-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}"
]
}
}
}
task buildWithCheckers(dependsOn: build) {}
gradle dependencies --configuration runtime
gave me this:
rp:girth-weld-thermal-analysis awang$ gradle dependencies --configuration runtime
:dependencies
------------------------------------------------------------
Root project
------------------------------------------------------------
runtime - Runtime dependencies for source set 'main'.
+--- com.google.guava:guava:19.0
+--- org.slf4j:slf4j-api:1.7.21
+--- org.slf4j:slf4j-simple:1.7.21
| \--- org.slf4j:slf4j-api:1.7.21
+--- javax.measure:unit-api:0.9
+--- systems.uom:systems-common-java8:0.2
| +--- tec.uom:uom-se:0.8 -> 0.9
| | +--- javax.measure:unit-api:0.9
| | +--- tec.uom.lib:uom-lib-common:0.9
| | | \--- javax.measure:unit-api:0.9
| | \--- javax.annotation:javax.annotation-api:1.2
| +--- si.uom:si-quantity:0.4
| | \--- javax.measure:unit-api:0.8 -> 0.9
| \--- si.uom:si-units-java8:0.4
| +--- javax.measure:unit-api:0.8 -> 0.9
| \--- tec.uom:uom-se:0.8 -> 0.9 (*)
+--- tec.uom:uom-se:0.9 (*)
+--- org.checkerframework:checker-qual:2.1.0
+--- org.checkerframework:checker:2.1.0
\--- systems.uom:systems-quantity:0.3
\--- javax.measure:unit-api:0.9
(*) - dependencies omitted (listed previously)
BUILD SUCCESSFUL
Total time: 1.052 secs
The two packages I unnecessarily marked as runtime
dependencies are indeed there, but apparently not on the runtime classpath.
The build still fails after adding back either one of the two runtime
dependencies; as far as I can tell, all 3 are needed.