-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
build.gradle
214 lines (180 loc) · 5.79 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
plugins {
id "com.gradle.plugin-publish" version "1.2.1"
id "com.github.johnrengelman.shadow" version "8.1.1"
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
}
apply plugin: 'java-gradle-plugin'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply from: "gradle/integrationTest.gradle"
group = 'de.undercouch'
version = '5.7.0-SNAPSHOT'
java {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
ext {
isReleaseVersion = !version.endsWith("SNAPSHOT")
junitVersion = '5.10.3'
// on CI server, limit functional tests to major versions to avoid running
// out of open file descriptors (happens when we load the jar files of too
// many Gradle distributions into memory)
if ("true" == System.getenv("CI")) {
limitedVersionsToTest = [
"5.6.4",
"6.9.4",
"7.6.4",
"8.9"
]
} else {
limitedVersionsToTest = versionsToTest
}
}
repositories {
mavenCentral()
}
configurations {
jacocoRuntime
}
dependencies {
shadow gradleApi()
implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1'
// Disable logging. This avoids slf4j warning and might also improve download performance.
// See issue 141 (https://github.com/michel-kraemer/gradle-download-task/issues/141)
implementation 'org.slf4j:slf4j-nop:1.7.36'
testImplementation "commons-codec:commons-codec:1.17.0"
testImplementation "commons-io:commons-io:2.16.1"
testImplementation "com.github.tomakehurst:wiremock-jre8:2.35.2"
testImplementation "org.assertj:assertj-core:3.26.0"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
testImplementation "org.mockito:mockito-core:4.8.0"
testImplementation "xyz.rogfam:littleproxy:2.0.19"
jacocoRuntime "org.jacoco:org.jacoco.agent:${jacoco.toolVersion}:runtime"
}
jacocoTestReport {
reports {
xml.required = true
html.required = true
}
}
// configure functional tests
tasks.register('functionalTest')
for (v in limitedVersionsToTest) {
def vn = v.replace(".", "_")
tasks.register("functionalTest_$vn", Test) {
include "**/FunctionalDownloadTest.class"
systemProperty 'gradleVersionUnderTest', v
}
functionalTest.dependsOn("functionalTest_$vn")
}
test.finalizedBy(functionalTest)
tasks.withType(Test).configureEach {
// use junit5 for tests
useJUnitPlatform()
// improve test output on plain console (e.g. on CI server)
if (gradle.startParameter.consoleOutput == ConsoleOutput.Plain) {
testLogging {
events "standard_out", "passed", "skipped", "failed"
}
}
systemProperty 'jacocoRuntimePath', configurations.jacocoRuntime.asPath
systemProperty 'jacocoDestFile', jacoco.destinationFile
}
jar {
// include license into jar
from 'LICENSE.txt'
}
shadowJar {
archiveClassifier = ""
enableRelocation = true
relocationPrefix = "de.undercouch.gradle.tasks.download"
relocate 'mozilla', 'de.undercouch.gradle.tasks.download.mozilla'
}
// Disabling default jar task as it is overridden by shadowJar
// This also prevents us from accidentally publishing the wrong jar
tasks.named("jar").configure {
enabled = false
}
def configurePom(pom) {
pom.description = 'Adds a download task to Gradle that displays progress information'
pom.url = 'https://github.com/michel-kraemer/gradle-download-task'
pom.scm {
url = 'scm:git:git://github.com/michel-kraemer/gradle-download-task.git'
connection = 'scm:git:git://github.com/michel-kraemer/gradle-download-task.git'
developerConnection = 'scm:git:git://github.com/michel-kraemer/gradle-download-task.git'
}
pom.licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
pom.developers {
developer {
id = 'michel-kraemer'
name = 'Michel Kraemer'
email = 'michel@undercouch.de'
url = 'https://michelkraemer.com'
}
}
}
publishing {
publications {
pluginMaven(MavenPublication) {
pom { pom ->
artifactId = 'gradle-download-task'
name = 'gradle-download-task'
packaging = 'jar'
configurePom(pom)
}
}
}
afterEvaluate {
publications {
downloadPluginPluginMarkerMaven {
pom { pom ->
configurePom(pom)
}
}
}
}
}
signing {
// use GPG to sign artifacts
useGpgCmd()
}
tasks.withType(Sign).configureEach {
onlyIf {
// only sign release artifacts and not snapshots
if (!isReleaseVersion) {
return false
}
// don't attempt to sign without a key
if (!project.hasProperty('signing.keyId')) {
return false
}
return true
}
}
nexusPublishing {
repositories {
sonatype()
}
}
gradlePlugin {
website = 'https://github.com/michel-kraemer/gradle-download-task'
vcsUrl = 'https://github.com/michel-kraemer/gradle-download-task'
plugins {
downloadPlugin {
id = 'de.undercouch.download'
implementationClass = 'de.undercouch.gradle.tasks.download.DownloadTaskPlugin'
displayName = 'gradle-download-task'
description = 'Adds a download task to Gradle that displays progress information'
tags.set(['download', 'task', 'progress', 'url', 'server', 'file', 'http', 'https'])
}
}
}