Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

maven

gradle

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?

like image 501
Armand Avatar asked Jul 18 '14 14:07

Armand


People also ask

What is artifact ID in Gradle?

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.

What is group ID and artifact ID in Gradle?

In Gradle, the groupId is known just as group , the artifactId is known as name , and the version is identically version .

How do I change from Maven to Gradle?

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.


2 Answers

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' } 
like image 94
Peter Niederwieser Avatar answered Sep 28 '22 03:09

Peter Niederwieser


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) } 
like image 21
Alex Dommasch Avatar answered Sep 28 '22 02:09

Alex Dommasch