-
Notifications
You must be signed in to change notification settings - Fork 89
/
build.gradle
207 lines (184 loc) · 7.49 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
/*
* Copyright 2014-2019 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
buildscript {
repositories {
maven {
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'org.ajoberstar.grgit:grgit-core:4.1.1'
}
}
plugins {
id 'com.netflix.nebula.plugin-plugin' version '21.2.1'
id "org.jetbrains.kotlin.jvm" version '2.1.0'
id("com.gradleup.shadow") version "9.0.0-beta1"
id 'java-gradle-plugin'
}
description 'Pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts'
contacts {
moniker 'Nebula Plugins Maintainers'
github 'nebula-plugins'
}
}
configurations {
plugin.description = 'The compile dependencies for the plugin, excluding the local dependencies to avoid problems with Shadow'
compileClasspath.extendsFrom shadow
runtimeClasspath.extendsFrom shadow
testCompileClasspath.extendsFrom shadow
testRuntimeClasspath.extendsFrom shadow
compileClasspath.extendsFrom plugin
runtimeClasspath.extendsFrom plugin
testCompileClasspath.extendsFrom plugin
testRuntimeClasspath.extendsFrom plugin
}
def jgitVersion = '5.0.1.201806211838-r'
configurations.all {
resolutionStrategy {
force "org.eclipse.jgit:org.eclipse.jgit:$jgitVersion"
}
}
dependencies {
compileOnly 'dev.gradleplugins:gradle-api:7.6'
shadow 'com.netflix.nebula:nebula-gradle-interop:latest.release'
shadow 'org.apache.maven:maven-model-builder:3.8.3'
shadow 'org.codehaus.gpars:gpars:1.2.1'
plugin 'com.google.guava:guava:19.0'
plugin('org.ow2.asm:asm:9.+') {
version {
reject '7.2-beta'
because 'avoid getting prerelease versions'
}
}
plugin('org.ow2.asm:asm-commons:9.+') {
version {
reject '7.2-beta'
because 'avoid getting prerelease versions'
}
}
plugin('org.codenarc:CodeNarc:2.0.0') {
transitive = false
}
plugin 'commons-lang:commons-lang:2.6'
plugin ("org.eclipse.jgit:org.eclipse.jgit:$jgitVersion") {
transitive = false
}
plugin 'org.eclipse.jdt:core:3.1.1'
compileOnly "com.netflix.nebula:nebula-test:10.+"
testImplementation 'org.ow2.asm:asm-util:9.7.1'
testImplementation 'joda-time:joda-time:latest.release'
testImplementation 'com.netflix.nebula:gradle-info-plugin:latest.release'
}
afterEvaluate {
configurations.named("implementation") {
dependencies.remove(project.dependencies.gradleApi())
}
}
gradlePlugin {
plugins {
legacyNebulaLint {
id = 'nebula.lint'
displayName = 'Nebula Lint plugin'
description = 'Pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts'
implementationClass = 'com.netflix.nebula.lint.plugin.GradleLintPlugin'
tags.set(['nebula', 'lint'])
}
nebulaLint {
id = 'com.netflix.nebula.lint'
displayName = 'Nebula Lint plugin'
description = 'Pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts'
implementationClass = 'com.netflix.nebula.lint.plugin.GradleLintPlugin'
tags.set(['nebula', 'lint'])
}
}
}
// Relocate jgit dependency not available in Maven Central
// Replaces the main artifact by removing the classifier for the shadow jar, and replacing jar with shadowJar
// Relocated dependencies are removed from the generated pom
shadowJar {
configurations = [project.configurations.plugin]
archiveClassifier.set(null)
dependencies {
include(dependency('com.google.guava:guava'))
include(dependency('org.eclipse.jdt:core'))
include(dependency('org.eclipse.jgit:org.eclipse.jgit'))
include(dependency('commons-lang:commons-lang'))
include(dependency('org.codenarc:CodeNarc'))
include(dependency('org.ow2.asm:asm'))
include(dependency('org.ow2.asm:asm-commons'))
}
relocate 'com.google', 'com.netflix.nebula.lint.com.google'
relocate 'org.eclipse.jdt', 'com.netflix.nebula.lint.jdt'
relocate 'org.eclipse.jgit', 'com.netflix.nebula.lint.jgit'
relocate 'org.apache.commons.lang', 'com.netflix.nebula.lint.commons.lang'
relocate 'org.codenarc', 'com.netflix.nebula.lint.org.codenarc'
relocate 'org.objectweb.asm', 'com.netflix.nebula.lint.org.objectweb.asm'
relocate 'org.objectweb.asm.commons', 'com.netflix.nebula.lint.org.objectweb.asm.commons'
// powerassert is packed inside codenarc without relocation for some reason
relocate 'org.codehaus.groovy.transform.powerassert', 'com.netflix.nebula.lint.org.codehaus.groovy.transform.powerassert'
}
jar.enabled = false
jar.dependsOn shadowJar
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
tasks.withType(Test).configureEach {
maxHeapSize = '512m'
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
testLogging {
events "PASSED", "FAILED", "SKIPPED"
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}
// Kotlin compiles first, stubbing Java dependencies, however it can't stub Groovy and we need to call Groovy code from Kotlin. For details see:
// https://discuss.gradle.org/t/kotlin-groovy-and-java-compilation/14903/10
tasks.named('compileGroovy').configure {
classpath = sourceSets.main.compileClasspath
}
tasks.named('compileKotlin') {
// Kotlin also depends on the result of Groovy compilation
// which automatically makes it depend of compileGroovy
libraries.from(files(sourceSets.main.groovy.classesDirectory))
}
['compileClasspath', 'runtimeClasspath', 'testCompileClasspath', 'testRuntimeClasspath'].each { confName ->
tasks.register("dependencyReport${confName.capitalize()}", DependencyReportTask) {
configurations = [project.configurations.getByName(confName)] as Set
outputFile = new File(project.projectDir, "build/reports/project/${confName}-dependencies.txt")
}
check.dependsOn("dependencyReport${confName.capitalize()}")
assemble.dependsOn("dependencyReport${confName.capitalize()}")
}
test.dependsOn 'shadowJar', 'generatePomFileForNebulaPublication'
nebulaRelease {
releaseBranchPatterns.add("beta")
}
validatePlugins {
enableStricterValidation = false
}
javaCrossCompile {
disableKotlinSupport = true
}