-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build isolated jar files out of projects by changing the top namespace #212
Comments
Is it possible to go forward with this in any way without the custom command being finished? |
Yes, it is. It could for example be added as an alias in the root |
Hi, I would start working on it if you don't mind. So you would imagine to have an alias similar to I took a quick look into the build function and would implement it quite similar but amended somehow like this:
where What do you think? |
Hi @TimoKramer! Sorry for late answer. Maybe @seancorfield or @furkan3ayraktar have ideas around this? |
I think the idea of publishing library JARs built from a Polylith repo that are not published in lock step with each other goes against the whole idea of using a monorepo in the first place, since you're reintroducing the "version hell" problems that separate libraries cause. I don't think shading components (renaming nses) is a good idea -- getting it right in all cases is non-trivial and you're likely to end up your users depending on the "same" code through different ns paths since if you put component I would lean toward releasing component |
That's an interesting approach. Just thinking if I got it all right... Given we have a database released with different APIs like a library, an http- and a cli-API, the http- and cli-API rely on the library. When we changed e.g. the http-API then we would release the library and the http-base as well as the cli-base in lock-step with the library, correct? Would that mean we treat the library as a base? |
Yes, my approach would be to release 1.100.1 of all artifacts, then 1.100.2, etc (or whatever version scheme you prefer). But cut new releases of all of them whenever you cut a new release of any of them. That way, it's clear for users what versions of everything should be used together -- and the transitive dependencies would all match too. That's not going to prevent dependency conflicts overall, because a third-party library Q could depend on your A 1.100.1, and then a user might depend on both Q and B 1.100.2, and they'll get C 1.100.1 or 1.100.2 depending on whether they're using All this is to say that I think shading is a worse solution -- in general -- than keeping things simple and leveraging existing tooling and knowledge around transitive dependencies. Regarding One thing that Polylith provides that you couldn't leverage in a "lock-step library" model is swappable implementations: if your A and B both depend on C's interface but the actual shipped JARs were built with A + C1 and B + C2, then you're going to have a problem since you will end up with two C (interface) namespaces on the classpath (for someone using both A and B) but only one can get picked so you'll get implementation C1 or C2 depending on which C is first (on the classpath). So that's a situation where shading might be worth the pain in order to use swappable implementations (but at that point, I'd probably just use separate C1 / C2 interfaces as well to avoid that). The other place where shading can be worth the pain is if you are providing low-level tooling that must operate in process with arbitrary user code but a) that's not just "libraries" and b) you probably will need to shade all of your dependencies, not just those within your monorepo. An example of b) can be seen here https://github.com/xtdb/xtdb/blob/master/modules/jdbc/src/xtdb/jdbc/mysql.clj where XTDB depends on a shaded version of Bottom line: I don't think this is a problem that Polylith should be trying to solve.
|
Is there any additional discussion to be had, or can this issue be closed? (no action for over a year) |
I think you can close it. I didn't go forward with it but have a proper idea of what to do. Thanks again! |
Yes, let's close this issue. |
I think I have a potential solution to this problem. My idea is that we include a number in the top namespace, e.g.
The next time we release the libraries, we increase the version to 2 for all top namespaces:
The So the difference here from my previous suggestion, is that we actually update the source code. That will allow us to run our tests to validate the change. |
I'm not sure I follow what you're suggesting here. If you change the name of a namespace that users might rely on, they can't upgrade without changing their code, which means those changes are "breaking". (I'm also strongly against commands changing source code by default, as you know) |
And, just to reiterate: I think this problem is out of scope for Polylith. |
Yes, I agree that this is out of scope of Polylith. And yes, changing all namespaces every time you release a new version isn't optimal, and it also requires all users of the libraries to update their source code. It also allows different versions to run in parallell, which can both be good and bad. I just wanted to discuss this topic a bit more. I think we leave it as it is, without actions. |
I updated the Artifacts page where I explains all this. |
Is your feature request related to a problem? Please describe.
Polylith is not well suited for building libraries as it is today. The problem is that if we for example build two libraries (as jar files) out of two project, then the user of these libraries can get into trouble if the same brick is used in both projects.
One example is when we build version 1 of library
a
andb
and then modify a shared componentc
and build version 2 of both libraries. If we now includea
andb
in our class path, we will get different versions ofc
depending on which of the librariesa
orb
comes first in the classpath.Describe the solution you'd like
To guarantee that version 1 of a library only uses bricks from version 1, we need to change the top namespace of all bricks in the project we build from, e.g.
com.mycompany
tocom.mycompany.mylib
(by copying the code and rename all namespaces and references to them in the code) before we build the jar.This functionality is probably best implemented as a custom command when we have support for that.
The text was updated successfully, but these errors were encountered: