This message was deleted.
# community-support
s
This message was deleted.
šŸ‘€ 1
m
A
Publication
"publishes" a
SoftwareComponent
. A
SoftwareComponent
is not necessarily bound to `Configuration`: it's an abstract way to define a deliverable. So you can see a
SoftwareComponent
as the model for "something built by Gradle". There are different kinds of components, based on the different ecosystems. For the typical Java/JVM world, the easiest is to use
AdhocComponentWithVariants
, which provides a convenient way to map "outgoing" `Configuration`s to variants.
In order words,
SoftwareComponent
is the concept, there are specific implementations (for example for Gradle native (C/C++)), and a generic implementation,
AdhocComponentWithVariants
, which can be used to create custom publications: https://docs.gradle.org/current/userguide/publishing_customization.html#sec:publishing-custom-components
m
I understand that but I don't really see why the need for a different concept? C/C++ could also very well use
Configurations
that would be added to a
Publication
?
In my mind: •
Configuration
= list of artifacts + attributes •
Publication
= list of artifacts + attributes + pom information. A
Publication
could potentially publish several
Configurations
(or no Configuration at all if artifacts are added manually)
Configuration
is also "something build by Gradle", right ?
m
Configuration
is too many things at the same time. Long term, this should go away IMO, because it's confusing. It's used for declaring dependencies, carrying artifacts, publications, representing a dependency graph, etc.
šŸ‘ 1
šŸ’Æ 2
m
I see
m
the reason C/C++ has its own model is because the software component idea was explored there first
šŸ‘ 1
the adhoc component thing is really a bridge to make it easier to use existing concepts to build components
it has the advantage of making it easy
m
Can I already replace my outgoing configurations with SoftwareComponents ?
(skip the middle man) ?
m
no. I wouldn't do that. Outgoing configurations are used everywhere, especially for integration with composite builds.
also the APIs for building software components from scratch are IMHO cumbersome. It is, frankly, complicated.
m
Alright, I'll keep the middleman šŸ‘
j
As far as I remember, the intention was at some point to make the ā€œComponentā€-Concept stronger in a way that you can use it to directly declare what a project represents to the outside - what consumable configurations are today. But there is also a lot of history of ideas that were neglected /changed. Thus right now, it is a bit confusing. I think at the moment though ā€œPublicationā€ is the thing that is (almost) redundant. Ideally you would only have one Publication per project and that would be ā€œfrom(components[ā€œjavaā€])ā€œ. Without anything else. So the Java plugin could declare do that for you and then you wouldn’t have to deal with ā€œPublicationā€ at all yourself. (The plugin-publish-plugin is actually doing that.) The ā€œComponentā€ on the other hand lets you control which of your ā€œconsumable configurationsā€ you want to publish. It’s also the base from which the Gradle Metadata (and POM) metadata is created. That’s why you should add a ā€œconsumable configurationā€ to the ā€œjava componentā€ (instead of adding the artifacts to the Publication). Because then you do not only get the artifacts, but also the dependencies etc. (a full ā€˜Variant’). It’s a bit related to that other Thread where I just shared this example: https://github.com/jjohannes/gradle-demos/tree/main/extending-publications
šŸ™ 1
šŸ‘€ 1
If you know which APIs to use, it is really nice to see how well this all works. Well done CĆ©dric šŸ˜„ šŸ’Ŗ (as far as I remember a lot of this was your doing).