如何在gradle中写入项目信息?
how to write project information in gradle?
我正在将示例 Maven 项目转换为 Gradle。在maven项目中,有licenses、organization、developers等标签。我只想在 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 存储库的 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'
}
}
}
}
}
我正在将示例 Maven 项目转换为 Gradle。在maven项目中,有licenses、organization、developers等标签。我只想在 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 存储库的 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'
}
}
}
}
}