Nathan Kulzer
10/05/2025, 5:10 AMVampire
10/05/2025, 5:40 AMartifact(...) to the publication.
But most often it is better to define a feature variant, so that a Gradle consumer can resolve it using attribute-aware resolutionNathan Kulzer
10/05/2025, 5:40 AMartifact() seems to rename the file unconditionallyNathan Kulzer
10/05/2025, 5:40 AMTheGoesen
10/05/2025, 8:58 AMorg.gradle.api.publish.maven.internal.publication.MavenPublicationInternal#publishWithOriginalFileNameVampire
10/05/2025, 11:20 AM<artifact>-<version>Vampire
10/05/2025, 11:26 AM(this as MavenPublicationInternal).publishWithOriginalFileName()
artifact(layout.projectDirectory.file("gradlew.bat"))
artifact(layout.projectDirectory.file("gradlew"))
but there was not any change, the names are like before.
Or does it not work with publishToMavenLocal?Vampire
10/05/2025, 11:27 AMpublish it does not have any effectTheGoesen
10/05/2025, 11:28 AMprivate void addPublicationsFromVariants(final Project project, final SoftwareComponentContainer components) {
project.getPluginManager().withPlugin("maven-publish", plugin -> {
components.withType(PublicationAwareComponent.class, component -> {
project.getExtensions().configure(PublishingExtension.class, publishing -> {
final ComponentWithVariants mainVariant = component.getMainPublication();
publishing.getPublications().create("main", MavenPublication.class, publication -> {
MavenPublicationInternal publicationInternal = (MavenPublicationInternal) publication;
publicationInternal.getPom().getCoordinates().getArtifactId().set(component.getBaseName());
publicationInternal.from(mainVariant);
publicationInternal.publishWithOriginalFileName();
});TheGoesen
10/05/2025, 11:32 AMVampire
10/05/2025, 11:36 AMbase {
archivesName.set("foo")
}
and
from(components["java"])
still no luck to get anything but the standard names in the repo 😕TheGoesen
10/05/2025, 11:37 AMVampire
10/05/2025, 11:38 AMTheGoesen
10/05/2025, 11:41 AMVampire
10/05/2025, 11:42 AMmaven-publish? 🤷♂️Vampire
10/05/2025, 11:47 AMVampire
10/05/2025, 11:47 AMVampire
10/05/2025, 11:48 AMVampire
10/05/2025, 11:49 AMTheGoesen
10/05/2025, 11:49 AMVampire
10/05/2025, 11:51 AMartifact(...) then, because that is exactly what it says, just uploads the artifact with that classifier and extension but does not contain any metadata.
Because of that it should usually never be done.
You really need to model the file then for example by adding a variant for it so that it will be part of the GMM.