'artifactId equivalent in Gradle?

I see in my default build.gradle, generated by IDEA, that group and version were set with:

group 'com.mycompany.mytopic'
version '1.0-SNAPSHOT'

How to set artifact id?

In Maven I would write:

<groupId>com.mycompany.mytopic</groupId>
<artifactId>my-snippets</artifactId>
<version>1.0-SNAPSHOT</version>

How to do the same in Gradle?

I saw advise to write

rootProject.name = 'my-snippets'

but why?

Why don't we write

rootProject.group 'com.inthemoon.snippets'
rootProject.version '1.0-SNAPSHOT'

then?



Solution 1:[1]

the default of artifactId is the project name in setting.gradle you can set the project name like below:

rootProject.name = "something"

or you can change it by putting below code in your build.gradle file

publishing {
publications {
    mavenJava(MavenPublication) {
       artifactId 'your_desired_name'
       from components.java
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1