I have a code, which depends on the maven package. I don't want this dependency to be packaged to a resulting JAR. In fact, I want to have only the source code in the resulting package, without all dependencies (the reason for it is that all dependencies will be already available in the class path).
In rules_jvm_external there is a neverlink
option to mark the dependency as compile-only. So in my WORKSPACE file I have:
maven_install(
artifacts = [
maven.artifact("org.example.package", "my-dependency", "1.0.0", neverlink=True),
],
...
)
It works, but the problem is that tests use the same WORKSPACE file definitions and, as dependency is not available during the runtime, they're failing with java.lang.NoClassDefFoundError
.
So I want to achieve both:
- Make the dependency available in tests
- Do not include the dependency in the JAR for deploy
How can I do this?