Search code examples
gradlemaven-publish

adding prefixes to libs during gradle maven publishing


I setup the next configuration for multiproject build:

allprojects {
  apply plugin: 'maven-publish'

  repositories {
    mavenCentral()        
  }
}
subprojects {
  apply plugin: 'java'

  sourceCompatibility = 1.8
  targetCompatibility = 1.8

  version = rootProject.version
  group = rootProject.group

  archivesBaseName = "PREFIX-${it.name}"
}

But prefix is applied only to built artifacts and not when i execute publish task. Is there a way to configure publishing with prefix?


Solution

  • In accordance with "Identity values in the generated POM", next configuration should works:

    subprojects { project ->
    ...
        publishing {
            publications {
                maven(MavenPublication) {
                    artifactId "PREFIX-${project.name}"
                    from components.java
                }
            }
        }  
    }