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?
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' } Follow this answer to receive notifications.
In Gradle, the groupId is known just as group , the artifactId is known as name , and the version is identically version .
To convert Maven to Gradle, the only step is to run gradle init in the directory containing the POM. This will convert the Maven build to a Gradle build, generating a settings. gradle file and one or more build.
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' }
Related to the root settings.gradle
file, you can change the name of the root project with:
rootProject.name = 'myproject'
But if you want to change the name of a sub-project (for example, the default "app" sub-project of an AndroidStudio project), you can do something like this, still in the root settings.gradle
file:
rootProject.children.each { it.name = ('app' == it.name ? 'MyAppName' : it.name) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With