Hi everyone! I'm currently trying to get tests run...
# community-support
p
Hi everyone! I'm currently trying to get tests running that require native components. I have a task that compiles the native stuff with cmake and produces a correct .so file as its output (technically a directory which among other things contains the .so file in the right place) and then a Jar task that takes that output and places it in a .jar. Now I want to use that .jar file as a dependency for my unit tests (testImplementation config). I'm using
artifacts.add(configurations.testImplementation.name, jarTask)
to add the jar to the configuration, but it doesn't seem to show up in the runtime classpath. ideas?
p
artifacts
defines the outgoing files, but you want to depend testimplementation as dependencyscope on another outgoing (consumable) configuration (that contains the artifacts). Do you want to support cross project publications? Then you need
artifacts
and a consumable configuration with some attributes, and a resolvable configuration with the same artifacts (and maybe an artifact transformation to make it usable from Java). In the same project, you can use it too, or just add the so file directly to your resources sourceset.
Or add the jar as normal dependency to the testimplementation.
p
it's all in the same project and that particular jar is only needed for testing, so no cross project publication here. I actually had success in using
testImplementation(files(jarTask))
, but that feels wrong
p
Why does it feel wrong? It’s absolutely a good choice.
p
not sure 😄