Skip to content

Commit f6e9bea

Browse files
committed
feat(gradle)!: Extract initialization and defaults to jenkins-plugin-resolver plugin
1 parent 63252db commit f6e9bea

File tree

6 files changed

+67
-49
lines changed

6 files changed

+67
-49
lines changed

build.gradle

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,12 @@ import org.example.JenkinsPlugins
22

33

44
plugins {
5-
id 'groovy'
6-
id 'idea'
7-
id 'com.adarshr.test-logger'
5+
id 'jenkins-plugin-resolver'
86
}
97

108
group = 'org.example'
119
version = '1.0-SNAPSHOT'
1210

13-
JenkinsPlugins.create(project)
14-
15-
java {
16-
toolchain {
17-
setLanguageVersion JavaLanguageVersion.of(11)
18-
}
19-
}
20-
2111
sourceSets {
2212
main {
2313
groovy {
@@ -38,50 +28,20 @@ sourceSets {
3828
}
3929
}
4030

41-
configurations {
42-
testPlugins
43-
}
44-
4531
dependencies {
4632
implementationDependencies delegate
4733
testImplementationDependencies delegate
4834
jenkinsPluginDependencies delegate
4935
junit5Dependencies delegate
5036
}
5137

52-
idea {
53-
module {
54-
downloadJavadoc = true
55-
downloadSources = true
56-
}
57-
}
58-
5938
/* Tasks */
6039

6140
tasks.named('test') {
6241
dependsOn tasks.resolveTestPlugins
6342
inputs.files sourceSets.main.allSource.files
64-
// set build directory for Jenkins test harness, JENKINS-26331
65-
systemProperty 'buildDirectory', buildDir
6643

67-
useJUnitPlatform()
6844
maxParallelForks = 4
69-
70-
final String STACK_WRITE_PROPERTY = 'pipeline.stack.write'
71-
final String LOGLEVEL_PROPERTY = 'testlogger.logLevel'
72-
systemProperty STACK_WRITE_PROPERTY, System.getProperty(STACK_WRITE_PROPERTY) ?: findProperty(STACK_WRITE_PROPERTY)
73-
systemProperty LOGLEVEL_PROPERTY, System.getProperty(LOGLEVEL_PROPERTY) ?: findProperty(LOGLEVEL_PROPERTY)
74-
75-
testlogger {
76-
theme 'mocha-parallel'
77-
showStandardStreams true
78-
showFullStackTraces true
79-
}
80-
reports {
81-
junitXml {
82-
outputPerTestCase = true
83-
}
84-
}
8545
}
8646

8747
tasks.register('resolveTestPlugins', Copy) {
@@ -118,7 +78,7 @@ tasks.named('wrapper') {
11878

11979
/* Helpers */
12080

121-
void implementationDependencies(DependencyHandler context) {
81+
static void implementationDependencies(DependencyHandler context) {
12282
List<String> dependencies = [
12383
"org.codehaus.groovy:groovy-all:2.4.21",
12484
"org.jenkins-ci.main:jenkins-core:${JenkinsPlugins.get().jenkinsVersion}",

buildSrc/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
plugins {
2+
id 'groovy-gradle-plugin'
3+
}
4+
5+
repositories {
6+
gradlePluginPortal() // alias for https://plugins.gradle.org/m2/
7+
}
8+
9+
dependencies {
10+
implementation 'com.adarshr:gradle-test-logger-plugin:4.0.0'
11+
}

buildSrc/settings.gradle

Whitespace-only changes.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import org.example.JenkinsPlugins
2+
3+
4+
plugins {
5+
id 'groovy'
6+
id 'idea'
7+
id 'com.adarshr.test-logger'
8+
}
9+
10+
JenkinsPlugins.create(project)
11+
12+
java {
13+
toolchain {
14+
setLanguageVersion JavaLanguageVersion.of(11)
15+
}
16+
}
17+
18+
idea {
19+
module {
20+
downloadJavadoc = true
21+
downloadSources = true
22+
}
23+
}
24+
25+
configurations {
26+
testPlugins
27+
}
28+
29+
tasks.named('test') {
30+
final String STACK_WRITE_PROPERTY = 'pipeline.stack.write'
31+
final String LOGLEVEL_PROPERTY = 'testlogger.logLevel'
32+
final String JENKINS_TEST_HARNESS_BUILD_DIR_PROPERTY = 'buildDirectory'
33+
34+
systemProperty STACK_WRITE_PROPERTY, System.getProperty(STACK_WRITE_PROPERTY) ?: findProperty(STACK_WRITE_PROPERTY)
35+
systemProperty LOGLEVEL_PROPERTY, System.getProperty(LOGLEVEL_PROPERTY) ?: findProperty(LOGLEVEL_PROPERTY)
36+
systemProperty JENKINS_TEST_HARNESS_BUILD_DIR_PROPERTY, buildDir
37+
38+
useJUnitPlatform()
39+
40+
testlogger {
41+
theme 'mocha-parallel'
42+
showStandardStreams true
43+
showFullStackTraces true
44+
}
45+
46+
reports {
47+
junitXml {
48+
outputPerTestCase = true
49+
}
50+
}
51+
}

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jenkinsVersion = 2.277.4
1616
## Jenkins Test Harness and plugins versions for Jenkins 2.277.4
1717

1818
testHarnessVersion.2.277.4 = 2140.ve736dc2b_b_d2c
19+
# plugins can also be commented out by prepending them with '#'
1920
jenkinsPluginVersions.2.277.4 = \
2021
org.jenkins-ci.plugins.workflow:workflow-cps-global-lib: 2.21 \
2122
org.jenkins-ci.plugins.workflow:workflow-job: 2.41 \
@@ -29,10 +30,11 @@ jenkinsPluginVersions.2.277.4 = \
2930
org.jenkins-ci.plugins:script-security: 1.77 \
3031
org.jenkins-ci.plugins:structs: 1.23 \
3132
org.jenkins-ci.plugins:trilead-api: 1.0.13 \
33+
\
34+
#org.example.ignored:plugin: 1.0.0 \
3235
#
3336

3437

35-
testLoggerPluginVersion = 4.0.0
3638
# Gradle log levels: ERROR->QUIET->WARN->LIFECYCLE->INFO->DEBUG
3739
testlogger.logLevel = lifecycle
3840

settings.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
pluginManagement {
2-
plugins {
3-
id 'com.adarshr.test-logger' version testLoggerPluginVersion
4-
}
5-
}
6-
71
dependencyResolutionManagement {
82
repositories {
93
/* Alias of https://repo1.maven.org/maven2 a.k.a. https://repo.maven.apache.org/maven2/ */

0 commit comments

Comments
 (0)