-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
180 lines (157 loc) · 5.85 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
import com.github.benmanes.gradle.versions.reporter.result.DependencyOutdated
import com.github.benmanes.gradle.versions.reporter.result.DependencyUnresolved
import com.github.benmanes.gradle.versions.reporter.result.Result
plugins {
// Apply the Java Gradle plugin development plugin to add support for developing Gradle plugins
id 'java-gradle-plugin'
// Apply the Groovy plugin to add support for Groovy
id 'groovy'
id 'ru.vyarus.quality' version '4.3.0'
id "maven-publish"
id "com.github.ben-manes.versions" version "0.28.0"
id 'net.researchgate.release' version '2.8.1'
id "name.remal.check-updates" version "1.0.191"
}
repositories {
mavenCentral()
}
dependencies {
// Use the awesome Spock testing and specification framework
testImplementation 'org.spockframework:spock-core:2.0-M2-groovy-2.5'
}
def compatibilityVersion = 1.8
sourceCompatibility = compatibilityVersion
targetCompatibility = compatibilityVersion
group = 'com.github.sources-gradle-plugin'
gradlePlugin {
// Define the plugin
plugins {
'sources-gradle-plugin' {
id = 'com.github.sources-gradle-plugin'
implementationClass = 'com.github.sourcesgradleplugin.SourcesGradlePlugin'
}
}
}
// Add a source set for the functional test suite
sourceSets {
functionalTest {
}
}
gradlePlugin.testSourceSets(sourceSets.functionalTest)
configurations.functionalTestImplementation.extendsFrom(configurations.testImplementation)
// Add a task to run the functional tests
task functionalTest(type: Test) {
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
useJUnitPlatform()
}
check {
// Run the functional tests as part of `check`
dependsOn(tasks.functionalTest)
}
jar {
manifest {
attributes 'Implementation-Title': 'Gradle sources plugin',
'Implementation-Version': archiveVersion,
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
'Built-Gradle': gradle.gradleVersion
}
}
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task groovydocJar(type: Jar, dependsOn: groovydoc) {
archiveClassifier.set('groovydoc')
from groovydoc.destinationDir
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives groovydocJar
archives javadocJar
}
publishing {
publications {
pluginMaven(MavenPublication) {
artifact sourcesJar
artifact groovydocJar
artifact javadocJar
pom.withXml {
def root = asNode()
root.appendNode('name', 'sources-gradle-plugin')
root.appendNode('description', 'Gradle plugin that downloads sources of dependencies to ' +
'comply with their licenses.')
root.appendNode('inceptionYear', '2020')
def license = root.appendNode('licenses').appendNode('license')
license.appendNode('name', 'The Apache Software License, Version 2.0')
license.appendNode('url', 'http://www.apache.org/licenses/LICENSE-2.0.txt')
license.appendNode('distribution', 'repo')
}
}
}
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
build.dependsOn publishToMavenLocal
dependencyUpdates {
boolean failOnUpdate = true
List<String> ignoredUpdates = [
]
onlyIf {
project.version && (project.version as String).endsWith('-SNAPSHOT')
}
outputFormatter = { Result result ->
Closure<Boolean> shouldIgnore = { String groupAndArtifact ->
ignoredUpdates.any { groupAndArtifact ==~ it }
}
boolean hasUpdates = false
result.outdated.dependencies.each { DependencyOutdated outdated ->
if (!shouldIgnore("${outdated.group}:${outdated.name}")) {
project.logger.warn(
"There is outdated dependency:" +
" ${outdated.group}:${outdated.name}:${outdated.version}" +
" -> ${outdated.available.release ?: outdated.available.milestone}")
hasUpdates = true
}
}
if (result.gradle.current.isUpdateAvailable && result.gradle.current > result.gradle.running) {
if (!shouldIgnore("org.gradle:gradle")) {
project.logger.warn(
"Gradle is outdated:" +
" ${result.gradle.running.version}" +
" -> ${result.gradle.current.version}")
hasUpdates = true
}
}
result.unresolved.dependencies.each { DependencyUnresolved unresolved ->
project.logger.warn(
"Could not determine latest version for" +
" ${unresolved.group}:${unresolved.name}:${unresolved.version}" +
" because ${unresolved.reason}")
}
if (hasUpdates && failOnUpdate) {
throw new GradleException("Dependencies have to be updated!")
}
}
resolutionStrategy { ResolutionStrategy strategy ->
strategy.componentSelection { rules ->
rules.all { ComponentSelection selection ->
if (selection.candidate.version =~ /redhat/ || ['alpha', 'beta', 'rc', 'cr', 'm', 'preview'].
any { qualifier -> selection.candidate.version =~ /(?i)\b${qualifier}\d*\b/ }) {
selection.reject('Release candidate')
}
}
}
}
}
check.dependsOn dependencyUpdates
quality {
consoleReporting = true
}