-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
165 lines (137 loc) · 6.47 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
import java.util.stream.Collectors
import org.jetbrains.changelog.ExtensionsKt
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel
String properties(String key) { return project.findProperty(key).toString() }
plugins {
id 'idea'
id 'java'
id 'org.jetbrains.intellij' version '1.3.1'
id 'org.jetbrains.changelog' version '1.3.1'
id 'org.jetbrains.qodana' version '0.1.13'
}
apply plugin: 'org.jetbrains.changelog'
group properties("pluginGroup")
version properties("pluginVersion")
repositories {
mavenCentral()
}
intellij {
pluginName.set(properties("pluginName"))
version.set(properties("platformVersion"))
type.set(properties("platformType"))
downloadSources.set(properties("platformDownloadSources").toBoolean())
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file.
plugins.set(properties("platformPlugins").length() == 0 ? [] : Arrays.asList(properties("platformPlugins").split(',')))
// TODO (https://youtrack.jetbrains.com/issue/IDEA-252693) - Disabled this task because it was failing. See my
// comment on the above YouTrack issue, and thread here: https://jetbrains-platform.slack.com/archives/C5U8BM1MK/p1604722479347300?thread_ts=1602338567.267100&cid=C5U8BM1MK
// Note: This gradle task is only needed if `SearchableConfigurable` is used,
// not `Configurable`.
// See the following comment for details: https://jetbrains-platform.slack.com/archives/C5U8BM1MK/p1606813009234800?thread_ts=1606794793.231900&cid=C5U8BM1MK
buildSearchableOptions.enabled = false
}
changelog {
version = properties("pluginVersion")
header = "[${-> version.get()}] - ${new Date().format('yyyy-MM-dd')}"
}
// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
qodana {
cachePath.set(project.file(".qodana").canonicalPath)
reportPath.set(project.file("build/reports/inspections").canonicalPath)
saveReport.set(true)
showReport.set(System.getenv("QODANA_SHOW_REPORT") == null ? true : System.getenv("QODANA_SHOW_REPORT").toBoolean())
}
tasks {
sourceCompatibility = properties("javaVersion")
targetCompatibility = properties("javaVersion")
wrapper {
gradleVersion = properties("gradleVersion")
}
patchPluginXml {
version.set(properties("pluginVersion"))
// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
ExtensionsKt.markdownToHTML(
project.file("README.md").text.lines()
.dropWhile({ String sx -> !sx.equals("<!-- Plugin description -->") })
.skip(1)
.takeWhile({ String sx -> !sx.equals("<!-- Plugin description end -->") })
.collect(Collectors.joining('\n'))
)
)
def changeLogForVersion = changelog.getOrNull(properties("pluginVersion"))
changeNotes.set((changeLogForVersion != null ? changeLogForVersion : changelog.getLatest()).toHTML())
}
runPluginVerifier {
ideVersions = Arrays.asList(properties("pluginVerifierIdeVersions").split(','))
failureLevel = [FailureLevel.NOT_DYNAMIC]
}
// Set the respective compiler arguments to fail the build if there are warnings.
tasks.withType(JavaCompile) {
options.compilerArgs.addAll([
'-Xlint:all',
'-Xlint:-options',
'-Xlint:-rawtypes',
'-Xlint:-processing',
'-Xlint:-path', // Ignore JBR SDK manifest element warnings
'-proc:none',
'-Werror',
'-Xlint:-classfile'
]) //ignore warnings from dependencies
}
if (System.getenv('CI') != "true") {
// The below file (jetbrainsCredentials.gradle) should contain the below:
// project.ext.set("intellijSignPluginCertificateChain", new File('./chain.crt').getText('UTF-8'))
// project.ext.set("intellijSignPluginPrivateKey", new File('./private.pem').getText('UTF-8'))
// project.ext.set("intellijSignPluginPassword", "YOUR_PRIV_KEY_PASSWORD_HERE")
// project.ext.set("intellijPluginPublishToken", "YOUR_TOKEN_HERE")
//
// Because this contains credentials, this file is also included in .gitignore file.
apply from: 'jetbrainsCredentials.gradle'
}
def signPluginCertificateChain = System.getenv('CI') != "true" ? intellijSignPluginCertificateChain : System.getenv("CERTIFICATE_CHAIN")
def signPluginPrivateKey = System.getenv('CI') != "true" ? intellijSignPluginPrivateKey : System.getenv("PRIVATE_KEY")
def signPluginPassword = System.getenv('CI') != "true" ? intellijSignPluginPassword : System.getenv("PRIVATE_KEY_PASSWORD")
def publishPluginToken = System.getenv('CI') != "true" ? intellijPluginPublishToken : System.getenv("PUBLISH_TOKEN")
signPlugin {
dependsOn('checkJetBrainsSecrets')
certificateChain.set(signPluginCertificateChain)
privateKey.set(signPluginPrivateKey)
password.set(signPluginPassword)
}
publishPlugin {
dependsOn('checkJetBrainsSecrets')
token.set(publishPluginToken)
// pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3
// Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more:
// https://plugins.jetbrains.com/docs/intellij/deployment.html#specifying-a-release-channel
def pluginVersionArray = properties("pluginVersion").split('-')
def releaseChannelArray = (pluginVersionArray.length > 1 ? pluginVersionArray[1] : "default").split('\\.').first()
channels.set(List.of(releaseChannelArray))
}
// Sanity check task to ensure necessary variables are set.
task checkJetBrainsSecrets {
doLast {
println "signPluginCertificateChain: " + (signPluginCertificateChain ? "IS" : "is NOT") + " set."
println "signPluginPrivateKey: " + (signPluginPrivateKey ? "IS" : "is NOT") + " set."
println "signPluginPassword: " + (signPluginPassword ? "IS" : "is NOT") + " set."
println "publishPluginToken: " + (publishPluginToken ? "IS" : "is NOT") + " set."
}
}
}
test {
useTestNG()
useJUnit()
}
configurations {
provided
}
dependencies {
provided localGroovy()
provided gradleApi()
testCompile 'org.testng:testng:7.5'
testCompile "org.mockito:mockito-core:4.3.1"
}
// Configure IntelliJ to be aware of Groovy and Gradle APIs to allow resolution and code completion of symbols in build.gradle
idea.module {
scopes.PROVIDED.plus += [configurations.provided]
}