-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
159 lines (138 loc) · 5.58 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import com.youbenzi.mdtool.tool.MDTool
import java.util.stream.Collectors
buildscript {
dependencies {
classpath 'com.youbenzi:MDTool:1.2.4'
}
}
plugins {
id 'org.jetbrains.intellij' version '1.17.4'
id 'io.freefair.lombok' version '8.7.1'
// id 'application'
id 'java-library'
id 'idea'
}
// intellij 版本(编译环境版本)
var intellijVersion = findProperty("intellijVersion") ?: System.getenv("intellijVersion") ?: "2023.3"
// intellij 上传插件 Token
var intellijPublishToken = findProperty("intellijPublishToken") ?: System.getenv("intellijPublishToken")
group = "com.github.houkunlin"
version = "2.8.2-2023.3+"
println(">>> PROJECT INFO : $group --> { intellij-version = IU-$intellijVersion, plugin-version = $version }")
repositories {
mavenLocal()
maven { url = "https://repo1.maven.org/maven2" }
mavenCentral()
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
// 存放一些变量信息
ext {
set('mapstruct', "1.5.5.Final")
}
dependencies {
// implementation(kotlin("stdlib-jdk8"))
// https://mvnrepository.com/artifact/com.google.guava/guava
// implementation("com.google.guava:guava:29.0-jre")
// https://mvnrepository.com/artifact/org.freemarker/freemarker
implementation("org.freemarker:freemarker:2.3.31")
// https://mvnrepository.com/artifact/org.apache.velocity/velocity
// implementation("org.apache.velocity:velocity:1.7")
// https://mvnrepository.com/artifact/org.apache.velocity/velocity-engine-core
// implementation("org.apache.velocity:velocity-engine-core:2.2")
// https://mvnrepository.com/artifact/com.ibeetl/beetl
implementation("com.ibeetl:beetl:3.17.0.RELEASE")
implementation("joda-time:joda-time:2.10.10")
implementation("org.yaml:snakeyaml:2.1")
// 这是一个代码处理工具,在编译阶段执行,可以自动转换两个POJO对象,只需要创建一个 interface 并在方法上配合它的注解使用,
// 在项目构建的过程中,它会根据这个 interface 代码内容自动生成实际的转换代码
implementation("org.mapstruct:mapstruct:${mapstruct}")
annotationProcessor("org.mapstruct:mapstruct-processor:${mapstruct}")
testAnnotationProcessor("org.mapstruct:mapstruct-processor:${mapstruct}")
// 这是一个代码处理工具,在编译阶段执行,使用它提供的一些注解,可以减少项目中的一些不必要的代码量,例如POJO对象的getter、setter方法等,项目中的基础类大量用到了这个工具提供的功能
annotationProcessor('org.projectlombok:lombok-mapstruct-binding:0.2.0')
testAnnotationProcessor('org.projectlombok:lombok-mapstruct-binding:0.2.0')
// implementation("com.google.code.gson:gson:2.8.5")
// https://mvnrepository.com/artifact/jalopy/jalopy
// implementation("jalopy:jalopy:1.5rc3")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
}
test {
useJUnitPlatform()
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
pluginName = rootProject.name
version = "IU-${intellijVersion}"
plugins.addAll("DatabaseTools", "java")
sandboxDir = "${rootProject.rootDir}/idea-sandbox"
updateSinceUntilBuild = false
downloadSources = true
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
// 构建编译 java 时生成 java doc 的 jar
withJavadocJar()
// 构建编译 java 时生成源代码的 jar
withSourcesJar()
}
compileJava {
dependsOn("buildSyncFiles")
options.encoding = "utf-8"
options.compilerArgs = ["-Xlint:deprecation", "-Xlint:unchecked"]
}
publishPlugin {
// 在 gradle.properties 文件中设置 intellijPublishToken 属性存储 Token 信息
// https://plugins.jetbrains.com/docs/marketplace/plugin-upload.html
token.set(String.valueOf(intellijPublishToken))
}
patchPluginXml {
var notes = file("$buildDir/gen-html/changeNotes.html")
var desc = file("$buildDir/gen-html/description.html")
if (notes.exists() && notes.isFile()) {
changeNotes.set(new String(notes.readBytes(), "UTF-8"))
}
if (desc.exists() && desc.isFile()) {
pluginDescription.set(new String(desc.readBytes(), "UTF-8"))
}
outputs.upToDateWhen { false }
dependsOn("markdownToHtml")
pluginId.set("com.github.houkunlin.database.generator")
// 最小支持版本
sinceBuild.set("233")
// 最大支持版本,不写死,防止无法在插件平台动态限制最高版本
// setUntilBuild("232.*")
}
tasks.register("markdownToHtml") {
file("$buildDir/gen-html").mkdirs()
file("$buildDir/gen-html/changeNotes.html").write(MDTool.markdown2Html(file("doc/plugin/changeNotes.md")))
file("$buildDir/gen-html/description.html").write(MDTool.markdown2Html(file("doc/plugin/description.md")))
}
/**
* 生成插件运行时需要同步的模板文件列表
*/
tasks.register("buildSyncFiles") {
outputs.upToDateWhen { false }
dependsOn("markdownToHtml")
var sourcePath = "src/main/resources/"
var dir = ["config.yml", "templates/"]
var source = new File(rootProject.rootDir, sourcePath)
var start = source.getAbsolutePath().length()
var filesText = fileTree(sourcePath).asList().stream()
.map { it.getAbsolutePath().substring(start + 1).replace("\\", "/") }
.filter { path ->
dir.any { path.startsWith(it) }
}
.collect(Collectors.joining("\n"))
file("${sourcePath}/syncFiles.txt").write(filesText)
}