有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在Gradle中添加标记

我已经将构建工具从Maven更改为Gradle,并想知道如何在build.gradle文件中定义以下标记

<developers>
    <developer>
        <email></email>
        <name></name>
        <timezone></timezone>
        <roles>
            <role></role>
        </roles>
    </developer>
</developers>

<licenses>
    <license>
        <name>Apache License, Version 2.0</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
</licenses>

共 (1) 个答案

  1. # 1 楼答案

    通过Maven Publish Plugin

    plugins {
        id 'maven-publish'
    }
    
    publishing {
        publications {
            mavenJava(MavenPublication) {
               pom {
                  licenses {
                        license {
                            name = 'The Apache License, Version 2.0'
                            url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        }
                    }
                    developers {
                        developer {
                            id = 'johnd'
                            name = 'John Doe'
                            email = 'john.doe@example.com'
                        }
                    }
               }
            }
       }
    }