【问题标题】:how to write project information in gradle?如何在gradle中写项目信息?
【发布时间】:2020-07-30 16:19:56
【问题描述】:

我正在将一个示例 maven 项目转换为 Gradle。在 maven 项目中,有许可证、组织、开发人员等标签。我只想在 Gradle 项目中提供这些细节。我尝试在build.gradle 文件中添加以下内容,

licenses {
    license {
        name = 'Apache 1'
        url = 'http://www.apache.org/licenses/LICENSE-1.0.txt'
        distribution = 'repo'
        comments = 'OSS license'
    }
}

organization {
    name = 'Sonatype'
    url = 'http://www.sonatype.com'
}

但它给出了一个错误。

> Could not find method licenses() for arguments [build_aa7z0myalt7c30hobty4ylab$_run_closure1@227a2f2] on root project 'simple-weather' of type org.gradle.api.Project.

怎么做,我是否必须添加一些插件?

【问题讨论】:

    标签: maven gradle build.gradle gradle-plugin


    【解决方案1】:

    自定义发布到 Maven 存储库的 POM 取决于 maven-publish 插件。

    例子:

    plugins {
        id 'maven-publish'
    }
    
    publishing {
        publications {
            mavenJava(MavenPublication) {
                pom {
                    licenses {
                        license {
                            name = 'Apache 1'
                            url = 'http://www.apache.org/licenses/LICENSE-1.0.txt'
                            distribution = 'repo'
                            comments = 'OSS license'
                        }
                    }
    
                    organization {
                        name = 'Sonatype'
                        url = 'http://www.sonatype.com'
                    }
                }
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-12-03
      • 2017-08-16
      • 1970-01-01
      • 2016-04-21
      • 1970-01-01
      • 2023-03-30
      • 2023-04-02
      • 1970-01-01
      • 2019-03-03
      相关资源
      最近更新 更多