forked from nebula-plugins/gradle-lint-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
180 lines (157 loc) · 6.63 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
/*
* 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.
*/
plugins {
id 'nebula.plugin-plugin' version '15.4.1'
id 'nebula.kotlin' version '1.3.70'
id 'com.github.johnrengelman.shadow' version '7.0.0'
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 plugin
runtimeClasspath.extendsFrom plugin
testCompileClasspath.extendsFrom plugin
testRuntimeClasspath.extendsFrom plugin
}
facets {
gradle6Test {
parentSourceSet = 'main'
}
}
gradle6Test {
useJUnit()
}
dependencies {
compileOnly 'dev.gradleplugins:gradle-api:6.8.3'
api 'com.netflix.nebula:nebula-gradle-interop:latest.release'
api 'org.apache.maven:maven-model-builder:3.+'
api 'com.google.guava:guava:19.0'
api 'org.codehaus.gpars:gpars:1.2.1'
plugin('org.ow2.asm:asm:7.+') {
version {
reject '7.2-beta'
because 'avoid getting prerelease versions'
}
}
plugin('org.ow2.asm:asm-commons:7.+') {
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:5.0.1.201806211838-r') {
transitive = false
}
plugin 'org.eclipse.jdt:core:3.1.1'
compileOnly "com.netflix.nebula:nebula-test:9.+"
testImplementation 'org.ow2.asm:asm-util:5.2'
testImplementation 'joda-time:joda-time:latest.release'
testImplementation 'com.netflix.nebula:gradle-info-plugin:latest.release'
gradle6TestImplementation "com.netflix.nebula:nebula-test:9.+"
gradle6TestRuntimeOnly project.getLayout().files(pluginUnderTestMetadata)
gradle6TestImplementation "dev.gradleplugins:gradle-test-kit:6.8.3"
}
afterEvaluate {
configurations.named("implementation") {
dependencies.remove(project.dependencies.gradleApi())
}
}
pluginBundle {
website = 'https://github.com/nebula-plugins/gradle-lint-plugin'
vcsUrl = 'https://github.com/nebula-plugins/gradle-lint-plugin.git'
description = 'Pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts'
plugins {
gradeLint {
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'
tags = ['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]
classifier = null
dependencies {
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 '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
tasks.withType(Test) {
maxHeapSize = '512m'
maxParallelForks = 4
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') {
classpath = sourceSets.main.compileClasspath
}
tasks.named('compileKotlin') {
classpath += files(sourceSets.main.groovy.classesDirectory)
}
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8
['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")
}