Comments (5)
yeah, I don't think bazel will allow us to compose workspace.bzl
loads in this way.
The way we do it at stripe is to merge the yaml files and then regenerate the workspace.bzl from there.
I added a merge
command to deal with this case, sadly, I think it can create some errors on merge and not quite ready to use.
from bazel-deps.
Hello,
thank you for your answer.
I don't think bazel will allow us to compose workspace.bzl loads in this way.
Do you mean that conceptually this approach does not makes sense ? My intention was to introduce an "App" based approach following the microservice patterns (share nothing principle). That means that each xyz.app is self-contained and is executed in a docker/kubernetes environment. Further, it is a fully valid case where two apps are using the same maven artifact, but in different versions.
The way we do it at stripe is to merge the yaml files and then regenerate the workspace.bzl from there
Ok, means there is a kind of preprocessing step that parses the different yaml files, generates the "final.yaml" that is then used to generate the bazel 3rdparty dependencies. Hmm, see the point.
I would expect that there is a kind isolation/visibility pattern included in bazel where packages can manage they own dependency, e.g. @a_app//:jar/junit/junit.
Regards,
jj
from bazel-deps.
Hi,
I could solve the issue with support given by the bazel community. The simple trick is to verify if a rule (maven_jar) is already defined in the repository.
That means, the one can build two workspaces, e.g. ~/tmp/bazel-multiworkspace-sampler/profile$ bazel build @a_app//... @b_app//...
The load.bzl looks as follow:
if native.existing_rule(item["name"]) == None:
if sha != None:
native.maven_jar(name = item["name"], artifact = item["artifact"], sha1 = sha)
else:
native.maven_jar(name = item["name"], artifact = item["artifact"])
native.bind(name = item["bind"], actual = item["actual"])
See full sample at https://github.com/ramtej/bazel-multiworkspace-sampler
The issue is still, that two different maven_jar artifacts can have the same maven_jar rule name.
Evtl. the "bind": "jar/junit/junit"
definition in the generated dependencies.bzl can contain the version and the maven_jar rule as well, e.g. "bind": "jar/junit/junit_4_12
.
That means also that the BUILD files has to reference the version number :
java_test(
name = "hello",
srcs = ["TestHello.java"],
test_class = "com.example.myproject.TestHello",
deps = [
"//src/main/java/com/example/myproject:hello-lib",
"//external:jar/junit/junit_4_12",
],
)
alternatively the current workspace name can be used for binding e.g. "//external:a_app_jar/junit/junit",
Cheers,
jj
from bazel-deps.
this is a nice solution!
Thanks for sharing.
from bazel-deps.
this may have been due to the bug we tried to fix with #51
from bazel-deps.
Related Issues (20)
- set up github actions based CI HOT 1
- Migrate to using only java_import HOT 1
- Add "latest" or automatic updating support
- ability to consume deps and locks from other systems
- Improper Resolution of Transitive Dependency
- Maven classifier is not generated correctly in artifact URL HOT 1
- Faiure due to indirect depency on expired zlib url HOT 1
- update_dependencies.sh broken due to usage of deprecated command line args HOT 4
- scala 3 support HOT 4
- setup github actions HOT 1
- migrate to scala 2.12 or 2.13
- use cats-effect and remove the homegrown IO system
- make sure the check-only option checks everything
- README update HOT 3
- writing gzip is not reproducible
- Is it even possible to template your dependencies yaml file? HOT 1
- Creating Pom leaves ":" in artifactId leading to Maven issues HOT 3
- debug failed example from ParseGeneratedDocTest
- Surprising resolution behavior when fixing versions (bug?) HOT 8
- Preserve version signifier in the file name HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bazel-deps.