plugins { id 'com.github.johnrengelman.shadow' version '7.1.2' } dependencies { shadow implementation('io.gitlab.jfronny:gson:2.9.2-20220914.175359-3') } shadowJar { configurations = [ project.configurations.shadow ] archiveClassifier = '' relocate 'com.google.gson', 'io.gitlab.jfronny.gson' } publishing { publications { mavenJava(MavenPublication) { groupId = 'io.gitlab.jfronny' artifactId = 'commons-gson' project.shadow.component(it) pom.withXml { asNode().dependencies.dependency.each { dep -> if(dep.artifactId.last().value() in ["gson"]) { assert dep.parent().remove(dep) } } } } } }