Well, your view is exactly perpendicular to mine.
things were easy and simple to understand (e.g. set archivesBaseName
on the project and everything works).
That was exactly not the case.
If you had plugin A which reads archivesBaseName
,
plugin B which reads archivesBaseName
,
applied plugin A, then changed the value, then applied plugin B,
then plugin A got the old value while plugin B got the new value.
Unless plugin A used afterEvaluate { ... }
to read the value then it might have gotten the new value too.
Unless you for some reason used afterEvaluate { ... }
to set it, then A and B go the old value even with plugin A using afterEvaluate { ... }
to read it.
…
With archivesName
being a Property<String>
it can be wired to other properties that need the archives name and can then at execution time - where no configuration change can be done anymore - safely read the value and know that it got the ultimate correct value.
Unfortunately not all built-in API is yet changed to Property
, but as I said in Gradle 9 this should hopefully improve extremely if not fully. But in this concrete case it is anyway a bad idea to manipulate the publishing coordinates manually.
So imho “where gradle goes” is the easier to use and understand behaviour, and the more safe and reliable behavior.
set base.archivesName
but be aware that this cannot be read back until after the lifecycle has progessed
That’s not correct, you can “read it back” any time.
You just should not do it as you might miss later changes, exactly the thing I just described in this reply.
But just as before, if you have set it, you can immediately read the value again, no problem, it is just bad practice.
If I wanted that, I would have used maven in the first place.
No, you would use maven if you would want to not have power but be forced opinion on you and having a really hard time getting the build tool to do what you need or extend it.
With Gradle you have the power to easily do what you want and need to do.
But if you don’t like the way it evolves, feel free to use any of the other alternatives.
No tool can ever satisfy the taste of every developer in the worlds unfortunately.
Would also be boring without a good holy war from time to time.
Stating that I should name the subprojects like the artifacts, else problems will simply be considered as something I have to live with because I’m not following “best practices” is not what I expect from a flexible build tool.
It’s not what the build tool is telling you, it is what I and my experience are telling you.
If Gradle would not be flexible, you couldn’t set those values.
But as I said, great flexibility and power comes with great responsibility.
Just because you can shoot with a gun at a dog if you need to because it attacks you,
doesn’t mean you should shoot at any dog just because you can do it.
Same with features in any tool. Just because they are there and could be used if really needed because of some strange edge cases doesn’t mean you should use them in normal usage.
And if you do, you have to live with the consequences like having to pay compensation to the dog’s owner and being hated by all pet-lovers.
But if you are fine with the consequences, do whatever pleases you most, I’m just sharing my experience with you as that is what you are in this forum for.
See the problem?
Not really.
I never had problems with building OSGi bundles.
And I never named any directory after an OSGi bundle name or heard that you should do that.
At least not when building it with Gradle.
You basically just apply the biz.aQute.bnd.builder
plugin and if you are not happy with the conventional bundle name, you set one property and be good.
I consider a build tool good if it allows me to use whatever naming, directory etc. schemes I think are appropriate for my project.
Well, it does.
See above.