-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
136 lines (118 loc) · 4.54 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
plugins {
id 'com.gradle.plugin-publish' version '1.3.0'
id 'eclipse'
id 'dk.mada.style' version '1.0.4'
id 'dk.mada.reproducible' version '1.0.2'
}
ext {
mavenDisplayName = 'Plugin for enforcing java dk.mada coding style'
mavenDescription = 'A plugin that sets up null-checking and code formatting style for dk.mada development.'
def configDir = layout.getProjectDirectory().dir('src/main/resources/config')
eclipseFormatterConfigFiles = [configDir.file('spotless/eclipse-formatter-mada.xml')]
checkstyleConfigFiles = [configDir.file('checkstyle/checkstyle-mada.xml'),
configDir.file('checkstyle/suppressions-mada.xml')]
errorProneDependencies = project.getProviders().provider(() -> getErrorProneDependencies())
}
group = 'dk.mada.style'
repositories {
repositories {
maven { url = uri("https://plugins.gradle.org/m2/") }
}
mavenCentral()
mavenLocal()
}
configurations {
addedDependencies
}
dependencies {
// Depending on these plugins
implementation (libs.errorpronePlugin)
implementation (libs.sonarPlugin)
implementation (libs.spotlessPlugin)
// Dependencies added by this plugin to its clients
// These are not used in this plugin code, but here Dependabot will keep them up to date.
// The versions are stored in config/datafile-dependencies.properties read by ErrorProneConfigurator.
addedDependencies (libs.nullaway) {
transitive = false
}
addedDependencies (libs.errorproneCore) {
transitive = false
}
compileOnly (libs.jspecify)
}
tasks.named('processResources').configure {
inputs.files(eclipseFormatterConfigFiles)
inputs.files(checkstyleConfigFiles)
inputs.property('errorProneDeps', errorProneDependencies)
// Checksum each configuration file so it is easy for the plugin to reason about their state
filesMatching('config/datafile-checksums.properties') {
filter { l -> l.replace('@ECLIPSE_FORMATTER_MADA@', digestFiles(eclipseFormatterConfigFiles))
.replace('@CHECKSTYLE_MADA@', digestFiles(checkstyleConfigFiles)) }
}
// Provide the plugin with versions for the dependencies it adds to the client build
filesMatching('config/datafile-dependencies.properties') {
filter { l -> l.replace('@DEPENDENCIES@', errorProneDependencies) }
}
}
gradlePlugin {
website = 'https://github.com/jskov/mada-style-gradle'
vcsUrl = 'https://github.com/jskov/mada-style-gradle'
plugins {
stylePlugin {
id = 'dk.mada.style'
displayName = mavenDisplayName
description = mavenDescription
tags.set(['error-prone', 'nullaway', 'checkstyle', 'spotless', 'style'])
implementationClass = 'dk.mada.style.MadaStylePlugin'
}
}
}
publishing {
repositories {
maven {
name = "dist"
url = "file://${project.rootProject.file("build/dist").getAbsolutePath()}"
}
}
}
project.afterEvaluate { p ->
tasks.withType(GenerateMavenPom).all {
getPom().url = 'https://github.com/jskov/mada-style-gradle'
getPom().name = mavenDisplayName
getPom().description = mavenDescription
getPom().developers {
developer {
id = 'jskov'
name = 'Jesper Skov'
email = '[email protected]'
}
}
getPom().licenses {
license {
name = 'Licensed under the EUPL-1.2-or-later'
url = 'https://joinup.ec.europa.eu/sites/default/files/custom-page/attachment/2020-03/EUPL-1.2%20EN.txt'
}
}
getPom().scm {
connection = 'scm:git:git://github.com/jskov/mada-style-gradle.git'
developerConnection = 'scm:git:ssh://github.com:jskov/mada-style-gradle.git'
url = 'https://github.com/jskov/mada-style-gradle/'
}
}
}
tasks.named('eclipse').configure {
doLast { project.mkdir("build/pluginUnderTestMetadata") }
}
String digestFiles(List<RegularFile> files) {
def digester = java.security.MessageDigest.getInstance("MD5")
for (RegularFile f : files) {
byte[] b = f.getAsFile().readBytes()
digester.update(b)
}
return java.util.HexFormat.of().formatHex(digester.digest())
}
String getErrorProneDependencies() {
return project.configurations.addedDependencies.collect { f ->
f.toString().replaceAll(".*files-2.1/", "").replaceFirst("/", "\\\\:").replaceFirst("/", "=").replaceAll("/.*", "")
}.join('\n')
}