Created by: strangemonad
NOTE: this is just a sketch of the fix but has issues. There are no tests and the generated IJModule includes the transitive jars (IjLibraries) as compile time dependencies rather than runtime dependencies. I've tested that this allows running main() and junit tests from inside Ij on a moderate size personal project (~70 buck targets, ~140 mvn dependencies, ~60k lines of .java excluding comments and 1k lines of .proto)
Summary: The classpath Ij generates when trying to run a module is incorrect because the IjModule doesn't include runtime dependencies of the libraries it depends on.
Prebuilt jars are often not fat (shaded) jars. The build targets listed in the 'deps' option of the 'prebuilt_jar' must be jars included on the runtime classpath. For example, imagine a java_app 'myapp' that depends on jetcd (https://github.com/justinsb/jetcd) a java / netty client for etcd. The jar might look something like:
prebuilt_jar(
name = 'jetcd',
deps = [
'//lib:jackson-core',
'//lib:jackson-databind',
'//lib:netty-all',
'//lib:slf4j-api',
],
binary_jar = ':jetcd_lib',
visibility = ['PUBLIC'],
)
Both buck run
and buck audit classpath
produce the correct result, including jackson, netty and slf4j on the classpath.
Bug: ExportedDepsClosureResolver#getExportedDepsClosure called by IjModuleGraph.from doesn't handle the PrebuildJar node type.