mavengradlemaven-publish

How do you set the maven artifact ID of a Gradle project?


From the gradle maven-publish plugin's documentation, it's clear that you set the groupId and version of the project directly in build.gradle:

group = 'org.gradle.sample'
version = '1.0'

However, the artifactId appears to be taken from the name of the folder you are working within. Is there a way to set the artifactId explicitly?


Solution

  • From 36.2.3. Identity values in the generated POM

    publishing {
        publications {
            maven(MavenPublication) {
                groupId 'org.gradle.sample'
                artifactId 'project1-sample'
                version '1.1'
    
                from components.java
            }
        }
    }
    

    The artifact ID defaults to the project name configured in settings.gradle, which in turn defaults to the project directory's name.

    You'll need the appropriate plugin.

    plugins {
        id 'maven-publish'
    }