文章阅读
gradle使用org.jetbrains.changelog在markdown中编写更新日志
2025/12/1686 次阅读4 分钟
1.引入依赖
plugins {
id("org.jetbrains.changelog") version "2.2.0"
}
2.编写配置
changelog {
version = project.version as String
path = file("CHANGELOG.md").canonicalPath
groups.empty()
}
3. 解析日志
val myChangeLog = provider {
changelog.renderItem(
changelog
.getOrNull(project.version as String) ?: changelog.getUnreleased()
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML
)
}
添加文件
在项目的根目录下添加文件CHANGELOG.md
文件的内容格式如下
替换[1.6.0] - 2024-05-13这里为最新版本号,和日期
# Changelog
## Unreleased
## [1.6.0] - 2024-05-13
使用示例
import org.jetbrains.changelog.Changelog
plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.22"
id("org.jetbrains.intellij") version "1.17.2"
id("org.jetbrains.changelog") version "2.2.0"
}
group = "shop.itbug"
version = "1.6.0"
repositories {
mavenCentral()
}
intellij {
version.set("LATEST-EAP-SNAPSHOT")
type.set("RR")
plugins.set(listOf("com.jetbrains.rust", "JavaScriptBase"))
}
val pushToken: String? = System.getenv("PUBLISH_TOKEN")
tasks {
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
val myChangeLog = provider {
changelog.renderItem(
changelog
.getOrNull(project.version as String) ?: changelog.getUnreleased()
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML
)
}
val descText = projectDir.resolve("DESCRIPTION.md").readText()
patchPluginXml {
sinceBuild.set("232")
untilBuild.set("242.*")
changeNotes.set(myChangeLog)
pluginDescription.set(descText)
}
signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
publishPlugin {
if (pushToken != null) {
token.set(pushToken)
}
}
runIde {
jvmArgs = listOf("-XX:+AllowEnhancedClassRedefinition")
}
}
changelog {
version = project.version as String
path = file("CHANGELOG.md").canonicalPath
groups.empty()
}