I'm trying to migrate Maven project to Bazel and having troubles with Datanucleus enhancement.
After jar
-file is build, Datanucleus looks inside it and does some byte-code manipulation to enhance persistable classes. The way to perform this in Bazel is by defining a rule that takes the *.jar
output of java_library
rule and creates a new enhanced version of the library.
The problem that I have is that for my rule I need datanucleus-core
package from external libraries. When I try to access it from a genrule
by $(location //third_party:datanucleus_core)
it point to a jar which has no classes:
(genrule) cmd = "echo $(location //third_party:datanucleus_core)"
bazel-out/local-fastbuild/bin/third_party/liborg_datanucleus_datanucleus_core.jar
(genrule) cmd = "jar tf $(location //third_party:datanucleus_core)"
META-INF/
META-INF/MANIFEST.MF
The jar
-file resolved by Bazel in genrule
from $(location //third_party:datanucleus_core)
contains only META-INF/MANIFEST.MF
with the following content:
Manifest-Version: 1.0
Created-By: blaze
I tried to use java_binary
rule that adds a correct datanucleus_core.jar
into classpath, but Datanucleus enhances my libary in-place and fails to write its changes on disk (rewrite the rule's input file). Also java_binary
rule is not supposed to be used for building.
So the question is what is the best way to enhance jar
library in Bazel running Datanucleus utility, which is provided as a third-party dependency in Maven repository?
Bazel build label: 0.3.2-homebrew
, OS: OS X El Capitan (10.11.6)
, java: 1.8.0_92
Update
Datanucleus dependency declaration:
# WORKSPACE
maven_jar(
name = "org_datanucleus_datanucleus_core",
artifact = "org.datanucleus:datanucleus-core:5.0.3",
)
# third_party/BUILD
java_library(
name = "org_datanucleus_datanucleus_core",
visibility = ["//visibility:public"],
exports = ["@org_datanucleus_datanucleus_core//jar"],
)
(in my question I shortened org_datanucleus_datanucleus_core
to datanucleus_core
)