Sreenivas
04/10/2025, 1:47 PMbuildSrc/my-java-conventions.groovy
plugin and this is applied to all modules to have some common stuff like dependencies, publishing etc..Sreenivas
04/10/2025, 1:51 PMmy-java-conventions.groovy
plugins {
id 'java-library'
id 'maven-publish'
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
and my web's build.gradle..
plugins {
id 'my.java-conventions'
id 'war'
}
publishing {
publications {
myWar(MavenPublication) {
from components.web
}
}
}
but this approach publishing both jar and war for my web component..Sreenivas
04/10/2025, 1:53 PMjar {
enabled=false }
for web module, but its failing at plugin saying
jar is not generated for this module
as plugin also trying to publish this module's artifact..
can we do conditional publishing at plugin side? if jar task is disabled, can we skip publishing it?Thomas Broyer
04/10/2025, 1:57 PMThomas Broyer
04/10/2025, 1:59 PMSreenivas
04/10/2025, 2:03 PMThomas Broyer
04/10/2025, 2:10 PMtasks.withType(PublishToMavenRepository).configureEach {
onlyIf { publication == publishing.publications.myWar }
}
(to only enable tasks for your myWar publication, and disable everything else ; or you could instead != publishing.publications.mavenJava
)Sreenivas
04/10/2025, 2:14 PMThomas Broyer
04/10/2025, 2:20 PMThomas Broyer
04/10/2025, 2:20 PMSreenivas
04/10/2025, 2:24 PMLaura Kassovic
04/10/2025, 4:45 PMSreenivas
04/10/2025, 5:28 PMbuild.gradle.
.
tasks.matching { it.name.startsWith('publishMavenJavaPublicationTo') }.configureEach {
enabled = false
}
Vampire
04/10/2025, 5:53 PMSreenivas
04/10/2025, 5:55 PMVampire
04/10/2025, 7:14 PM