forked from asciidoctor/asciidoctor-intellij-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
230 lines (200 loc) · 8.88 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
buildscript {
repositories {
mavenCentral()
maven { url 'https://www.jetbrains.com/intellij-repository/snapshots' }
}
}
plugins {
id "org.jetbrains.intellij" version "1.15.0"
id "org.jetbrains.grammarkit" version "2021.2.2"
id "checkstyle"
id 'org.asciidoctor.jvm.convert' version '3.3.2'
// once windows classpaths get too long, use this dependency to make them shorter again
id "com.github.ManifestClasspath" version "0.1.0-RELEASE"
// https://github.com/tbroyer/gradle-errorprone-plugin
id 'net.ltgt.errorprone' version '3.1.0' apply false
}
checkstyle {
toolVersion '8.30'
}
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'org.jetbrains.grammarkit'
apply plugin: 'java'
apply plugin: 'net.ltgt.errorprone'
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel
import org.jsoup.Jsoup
allprojects {
repositories {
mavenCentral()
mavenLocal()
}
}
intellij {
version = 'IC-232.8660.142-EAP-SNAPSHOT' // 'IC-231.8770.65'
pluginName = 'asciidoctor-intellij-plugin'
updateSinceUntilBuild = false
plugins = [
'PsiViewer:232.2-SNAPSHOT', // used for debugging
// 'PlantUML integration:6.3.0-IJ2023.2', // used to test highlighting of plantuml diagrams
// 'com.intellij.platform.images', // dependency for PlantUML plugin
'tanvd.grazi', // used for spell and grammar checking checking
'com.intellij.javafx:1.0.4',
'org.intellij.intelliLang',
'com.jetbrains.sh',
// 'com.google.ide-perf:1.2.0', // performance tracing
// see https://github.com/google/ide-perf/blob/master/docs/user-guide.md
'java', // used to integrate into the build via AsciiDocTargetScopeProvider
'yaml', // used to inject file references to Antora YAML files
// 'com.jetbrains.performancePlugin:213.5744.122' // used run YourKit CPU profiling in test IDE
// see https://intellij-support.jetbrains.com/hc/en-us/articles/207241235
// https://plugins.jetbrains.com/plugin/16136-grazie-professional/
'com.intellij.grazie.pro:0.3.230'
]
}
asciidoctor {
// this dependency is necessary as Gradle 7.x is confused that the source dir (?) leads to an implicit dependency
// https://docs.gradle.org/7.6/userguide/validation_problems.html#implicit_dependency
dependsOn = [ generateLexer, processTestResources, downloadAndroidStudioProductReleasesXml, downloadIdeaProductReleasesXml ]
sourceDir file('.')
sources {
include 'CHANGELOG.adoc'
}
outputDir file('build/docs')
}
version = System.getenv('VERSION')
patchPluginXml {
dependsOn = [ asciidoctor ]
changeNotes =
provider { Jsoup.parse(file('build/docs/CHANGELOG.html').getText('UTF-8'))
.select("#releasenotes").get(0).nextElementSibling().children()
.subList(0, 20)
.stream().map { e ->
e.html()
.replaceAll('\\(work in progress\\)', '')
.replaceAll('\\(preview, available from GitHub releases\\)', '')
.replaceAll('#([0-9]+)', '<a href="https://github.com/asciidoctor/asciidoctor-intellij-plugin/issues/$1">#$1</a>')
// regex for GitHub user names from https://github.com/shinnn/github-username-regex
.replaceAll('(?i)@([a-z\\d](?:[a-z\\d]|-(?=[a-z\\d])){0,38})', '<a href="https://github.com/$1">@$1</a>')
}
.collect().join("\n") }
pluginDescription = "${file('src/main/resources/META-INF/description.html').getText('UTF-8')}"
}
runIde {
jvmArgs = ['-Xmx1024m','-XX:+UnlockDiagnosticVMOptions']
// should not automatically reload plugin on change in IDE, as JRuby is not very good at this
systemProperty('idea.auto.reload.plugins', 'false')
systemProperty('jdk.attach.allowAttachSelf', 'true') // necessary to run plugin com.google.ide-perf
systemProperty('ide.plugins.snapshot.on.unload.fail', 'true')
}
runPluginVerifier {
// https://github.com/JetBrains/gradle-intellij-plugin/blob/master/src/main/kotlin/org/jetbrains/intellij/tasks/RunPluginVerifierTask.kt#L485
failureLevel = [FailureLevel.INVALID_PLUGIN, FailureLevel.COMPATIBILITY_PROBLEMS, FailureLevel.NOT_DYNAMIC]
ideVersions = Arrays.asList(project.properties['pluginVerifierIdeVersions'].toString().split(','))
}
publishPlugin {
token = System.getenv('PUBLISH_TOKEN')
channels = [("true" == System.getenv("PRE_RELEASE")) ? 'eap' : 'default']
}
test {
useJUnitPlatform()
testLogging {
// this show the full exception on failed tests on the build server
exceptionFormat = 'full'
}
}
dependencies {
errorprone 'com.google.errorprone:error_prone_core:2.21.1'
/* snakeyaml is s used by asciidoctorj-pdf, but is actually provided within jruby-stdlib
* a snakeyaml version in the classpath takes precedence, but IntelliJ includes a version that is too old
* therefore this plugin includes the same version of snakeyaml that is already included in jruby-stdlib
* to prevent loading the older version from IntelliJ.
* When a different version than jruby-stdlib 9.4.2.0 is used after upgrading asciidoctorj,
* double check the snakeyaml version.
* https://github.com/asciidoctor/asciidoctorj-pdf/issues/25
*/
implementation 'org.snakeyaml:snakeyaml-engine:2.6'
implementation 'org.asciidoctor:asciidoctorj:2.5.10' // WARNING: when upgrading asciidoctorj, see comment above about snakeyaml!
implementation 'commons-io:commons-io:2.13.0'
// used to be 'nl.jworks.markdown_to_asciidoc:markdown_to_asciidoc:1.1' that is only available on jcenter/bintray
implementation files('libs/markdown_to_asciidoc-1.1-p1.jar')
// explicit dependencies of markdown_to_asciidoc
implementation 'org.pegdown:pegdown:1.6.0'
implementation 'org.parboiled:parboiled-java:1.4.1'
implementation 'org.jsoup:jsoup:1.14.3'
// end of markdown_to_asciidoc
implementation 'org.apache.commons:commons-text:1.10.0'
implementation 'io.sentry:sentry:6.28.0'
// when updating the versions here, also update them in AsciiDocDownloaderUtil for dynamic download
testImplementation 'org.asciidoctor:asciidoctorj-diagram:2.2.11'
testImplementation 'org.asciidoctor:asciidoctorj-pdf:2.3.9'
testImplementation(gradleTestKit())
testRuntimeOnly('org.junit.platform:junit-platform-launcher:1.10.0')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.10.0')
testRuntimeOnly('org.junit.vintage:junit-vintage-engine:5.10.0')
testImplementation 'com.tngtech.archunit:archunit-junit4:1.1.0'
testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'org.mockito:mockito-core:5.4.0'
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.10.0")
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
def genRoot = file('gen')
sourceSets {
main {
java.srcDirs project.files(genRoot)
resources {
exclude('META-INF/description.html')
}
}
}
// to allow better incremental updates, ensure file timestamps to be always the same, also the file order
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
tasks.withType(AbstractArchiveTask).configureEach {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
grammarKit {
}
tasks.register("showLinkToContributorGuide") {
println("\nFirst time contributing to this plugin? Have a look at the IntelliJ AsciiDoc Plugin contributor's guide for coders:\n" +
"https://intellij-asciidoc-plugin.ahus1.de/docs/contributors-guide/contribute-as-a-coder.html\n")
}
tasks.register("checkJavaVersion") {
if (JavaVersion.current() != JavaVersion.VERSION_17) {
throw new GradleException("As of IntellIJ 2022.3, this build must be run with Java 17, see:\n" +
"https://intellij-asciidoc-plugin.ahus1.de/docs/contributors-guide/coder/setup-environment.html")
}
}
generateLexer {
source.set("src/main/java/org/asciidoc/intellij/lexer/asciidoc.flex")
targetDir.set("gen/org/asciidoc/intellij/lexer")
targetClass.set("_AsciiDocLexer")
}
java {
targetCompatibility = "11"
sourceCompatibility = "11"
}
compileJava {
options.errorprone.excludedPaths = '.*(_AsciiDocLexer).*'
options.errorprone.error('StreamResourceLeak') // enforce errors where there would be warning in the standard only
options.errorprone.disable('MissingSummary', 'NullableOnContainingClass', 'CanIgnoreReturnValueSuggester')
options.compilerArgs.addAll(['--release', '11'])
// will print link to contributor guide at the start of each build
dependsOn showLinkToContributorGuide
// checking that we run on JDK 11, as this is required to compile against IC 2020.3
dependsOn checkJavaVersion
dependsOn generateLexer
}
checkstyleMain {
dependsOn instrumentTestCode
}
// ensure to print hint to contributor's guide on build failures again
gradle.taskGraph.afterTask { Task task, TaskState state ->
if (state.failure) {
println("\nA build step failed. Maybe the IntelliJ AsciiDoc Plugin contributor's guide can give a hint?\n" +
"https://intellij-asciidoc-plugin.ahus1.de/docs/contributors-guide/contribute-as-a-coder.html\n")
}
}