你如何设置Gradle项目的Maven工件ID? [英] How do you set the maven artifact ID of a gradle project?

查看:899
本文介绍了你如何设置Gradle项目的Maven工件ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从gradle maven-publish插件的文档中,很明显你可以设置<$直接位于 build.gradle 中的项目的c $ c> groupId 和版本 / p>

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'

然而, artifactId 似乎取自您正在工作的文件夹的名称中。有没有明确设置 artifactId 的方法?

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?

推荐答案

a href =https://docs.gradle.org/current/userguide/publishing_maven.html#sec:identity_values_in_the_generated_pom =noreferrer> 36.2.3。生成的POM中的身份值

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
        }
    }
}

工件标识默认为在<$ c中配置的工程名称$ c> settings.gradle ,这又默认为项目目录的名称。

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

这篇关于你如何设置Gradle项目的Maven工件ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆