-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
292 lines (241 loc) · 10.5 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java library project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/7.5.1/userguide/building_java_projects.html
*/
import java.util.regex.Pattern
String properties(String key) { return project.findProperty(key).toString() }
plugins {
id 'idea'
id 'java-library'
// To publish to maven, including maven local: https://www.jetbrains.com/help/idea/add-a-gradle-library-to-the-maven-repository.html#publish
id 'maven-publish'
// To fully automate publishing to OSSRH: https://github.com/gradle-nexus/publish-plugin
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id 'signing'
id 'org.jetbrains.changelog' version '2.2.1'
// Add IJ gradle plugin in order to allow us to pull a dependency on IntelliJ platform.
id "org.jetbrains.intellij" version "1.17.4"
id 'jacoco'
// provides `taskTree` task (e.g. `./gradlew build taskTree`; docs: https://github.com/dorongold/gradle-task-tree)
id "com.dorongold.task-tree" version "4.0.0"
}
//apply plugin: 'maven'
apply plugin: 'maven-publish'
// NOTE: For JitPack to allow a custom group (ie, `com.chriscarini.jetbrains`, and not the default of
// 'com.github.ChrisCarini') we need to setup a DNS TXT record (`dig txt git.jetbrains.chriscarini.com`).
//group = 'com.github.ChrisCarini'
group properties("libraryGroup")
version properties("libraryVersion")
ext.isSnapshot = version.endsWith('-SNAPSHOT')
sourceCompatibility = properties("javaVersion")
targetCompatibility = properties("javaVersion")
/**
* #####################################################################################################################
* #####################################################################################################################
*
* BELOW SECTION TAKEN FROM https://github.com/intellij-dlanguage/intellij-dlanguage (`:utils`, `:errorreporting`, and `:debugger` modules).
*
* Ultimately, this just disables all the gradle tasks provided by the 'org.jetbrains.intellij' gradle plugin, as we only
* want this plugin for the dependencies.
*/
// Disable all Gradle Tasks for the gradle-intellij-plugin as we only use the plugin for the dependencies
project.gradle.taskGraph.whenReady { graph ->
graph.allTasks.findAll { it.group == 'intellij' }.each {
if (it.name in [
// This task is required for this library's tests to work
'initializeIntelliJPlugin',
// This task is required for the UI tests to run. Without these, we can not run tests that
// subclass off of {@link BasePlatformTestCase}.
'downloadRobotServerPlugin',
'instrumentedJar',
'prepareUiTestingSandbox',
'runIdeForUiTests',
]) {
logger.info('Skipping disabling \'org.jetbrains.intellij\' task: ' + it.name)
return
}
logger.info('Disabling \'org.jetbrains.intellij\' task: ' + it.name)
it.enabled = false
}
}
intellij {
version.set(properties("platformVersion"))
downloadSources.set(properties("platformDownloadSources").toBoolean())
plugins.set(['org.jetbrains.plugins.github']) // Needed for the AuthenticatedGitHubErrorReportSubmitter
// Note: This gradle task is only needed if `SearchableConfigurable` is used, not `Configurable`. In this
// library, we don't use that at all. Therefore, we disable this task.
// See https://github.com/ChrisCarini/environment-variable-settings-summary-intellij-plugin/issues/9 for details.
buildSearchableOptions.enabled = false
}
/**
* END ABOVE SECTION TAKEN FROM https://github.com/intellij-dlanguage/intellij-dlanguage (`:utils`, `:errorreporting`, and `:debugger` modules).
*
* #####################################################################################################################
* #####################################################################################################################
*/
final String repoUrl = "https://github.com/ChrisCarini/jetbrains-error-utils"
// Configure CHANGELOG.md - https://github.com/JetBrains/gradle-changelog-plugin
// Note: Use all the defaults.
changelog {
repositoryUrl = repoUrl
// Custom regex to match the header of the changelog for 4-part versions
// NOTE: The addition is `(\.(0|[1-9]\d*))*` to allow for an optional 4th
// part of the version.
headerParserRegex = Pattern.compile(/^((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(\.(0|[1-9]\d*))*(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)${'$'}/)
}
idea {
module {
jdkName = '17'
}
}
repositories {
mavenCentral()
}
publishing {
publications.create("mavenJava", MavenPublication) {
groupId = group
artifactId = rootProject.name
version = version
from components.java
withoutBuildIdentifier()
pom {
name.set("JetBrains Error Utilities")
description.set("A java library, intended to be consumed by plugins for JetBrains IDEs, providing utilities for handling errors from plugins.")
url.set(repoUrl)
inceptionYear.set("2022")
packaging = "jar"
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("$repoUrl/blob/main/LICENSE")
distribution.set("repo")
}
}
developers {
developer {
id.set("ChrisCarini")
name.set("Chris Carini")
email.set("6374067+ChrisCarini@users.noreply.github.com")
url.set("https://github.com/ChrisCarini")
}
}
scm {
url.set(repoUrl)
connection.set("scm:git:${repoUrl}.git")
developerConnection.set(connection)
}
issueManagement {
system.set("GitHub Issues")
url.set("$repoUrl/issues")
}
ciManagement {
system.set('GitHub Actions')
url.set("$repoUrl/actions")
}
}
}
repositories {
maven {
name = 'ChrisCarini_LocalMaven'
def snapshotsRepoUrl = layout.buildDirectory.dir('repos/snapshots')
def releasesRepoUrl = layout.buildDirectory.dir('repos/releases')
url = isSnapshot ? snapshotsRepoUrl : releasesRepoUrl
}
// https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-gradle#publishing-packages-to-the-maven-central-repository
if (System.getenv("OSSRH_MAVEN_USERNAME")) {
maven {
name = "OSSRH"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
url = isSnapshot ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv("OSSRH_MAVEN_USERNAME")
password = System.getenv("OSSRH_MAVEN_PASSWORD")
}
}
}
// https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-gradle#publishing-packages-to-github-packages
if (System.getenv("GITHUB_TOKEN")) {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/ChrisCarini/jetbrains-error-utils"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
}
signing {
useGpgCmd()
if (System.getenv('PGP_KEY')) {
useInMemoryPgpKeys(System.getenv('PGP_KEY'), System.getenv('PGP_PWD'))
}
sign configurations.archives
sign publishing.publications.mavenJava
}
tasks {
sourceCompatibility = properties("javaVersion")
targetCompatibility = properties("javaVersion")
// Set the respective compiler arguments to fail the build if there are warnings.
tasks.withType(JavaCompile).configureEach {
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
}
runIdeForUiTests {
systemProperty("robot-server.port", "8082")
systemProperty("ide.mac.message.dialogs.as.sheets", "false")
systemProperty("jb.privacy.policy.text", "<!--999.999-->")
systemProperty("jb.consents.confirmation.enabled", "false")
}
}
tasks.named('jar') {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version
)
}
}
//// Uncomment to see the paths of where the `publish*PublicationToChrisCarini_LocalMavenRepository` tasks are publishing to.
//project.tasks.withType(PublishToMavenRepository).all { task ->
// task.doLast {
// def baseUrl = "${task.repository.url}/${task.publication.groupId.replace('.', '/')}/${task.publication.artifactId}/${task.publication.version}/${task.publication.artifactId}"
// task.publication.artifacts.each { artifact ->
// println "${baseUrl}${artifact.classifier ? '-' + artifact.classifier : ''}.${artifact.extension}"
// }
// }
//}
java {
withSourcesJar()
withJavadocJar()
}
test {
useTestNG()
useJUnit()
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
}
dependencies {
// Use JUnit test framework.
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-core:5.+"
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:33.3.1-jre'
}