@@ -26,6 +26,28 @@ configurations {
2626 testPlugins
2727}
2828
29+ dependencies {
30+ /* Project's Shared library code dependencies */
31+ implementation ' org.codehaus.groovy:groovy-all:2.4.21'
32+ implementation " org.jenkins-ci.main:jenkins-core:${ JenkinsPlugins.get().jenkinsVersion} "
33+ implementationDependencies delegate
34+
35+ /* JUnit5 dependencies */
36+ testImplementation platform(' org.junit:junit-bom:5.9.2' )
37+ testImplementation ' org.junit.jupiter:junit-jupiter'
38+ testRuntimeOnly ' org.junit.vintage:junit-vintage-engine'
39+
40+ /* Jenkins plugins dependencies */
41+ JenkinsPlugins . get(). each { String dependency ->
42+ testPlugins dependency
43+ }
44+
45+ /* Dependencies of tests of Shared library and pipeline code */
46+ testImplementation ' com.lesfurets:jenkins-pipeline-unit:1.19'
47+ testImplementation ' org.spockframework:spock-core:1.3-groovy-2.4'
48+ testImplementationDependencies delegate
49+ }
50+
2951tasks. named(' test' ) {
3052 dependsOn tasks. resolveTestPlugins
3153 inputs. files sourceSets. main. allSource. files
@@ -83,3 +105,52 @@ tasks.named('wrapper') {
83105 gradleVersion = project. gradleVersion
84106 distributionType = Wrapper.DistributionType . BIN
85107}
108+
109+
110+ /* Dependency helpers */
111+
112+ static void implementationDependencies (DependencyHandler context ) {
113+ List<String > dependencies = [
114+ JenkinsPlugins . get()[' job-dsl-core' ],
115+ ]
116+
117+ switch (JenkinsPlugins . get(). jenkinsVersion) {
118+ case ' 2.277.4' :
119+ dependencies << ' com.cloudbees:groovy-cps:1.22'
120+ break
121+ case ' 2.346.3' :
122+ dependencies << JenkinsPlugins . get()[' workflow-cps' ]
123+ break
124+ default :
125+ throw new IllegalArgumentException (" Unrecognized Jenkins version: ${ JenkinsPlugins.get().jenkinsVersion} " )
126+ }
127+
128+ dependencies. each { String dependency ->
129+ context. implementation dependency
130+ }
131+ }
132+
133+ static void testImplementationDependencies (DependencyHandler context ) {
134+ List<String > dependencies = [
135+ " org.jenkins-ci.main:jenkins-test-harness:${ JenkinsPlugins.get().testHarnessVersion} " ,
136+ " org.jenkins-ci.main:jenkins-war:${ JenkinsPlugins.get().jenkinsVersion} " ,
137+ JenkinsPlugins . get()[' job-dsl' ],
138+ " ${ JenkinsPlugins.get()['job-dsl']} @jar" ,
139+ " ${ JenkinsPlugins.get()['structs']} @jar" ,
140+ ]
141+
142+ switch (JenkinsPlugins . get(). jenkinsVersion) {
143+ case ' 2.277.4' :
144+ dependencies << ' cglib:cglib-nodep:2.2.2'
145+ dependencies << " ${ JenkinsPlugins.get()['script-security']} @jar"
146+ break
147+ case ' 2.346.3' :
148+ break
149+ default :
150+ throw new IllegalArgumentException (" Unrecognized Jenkins version: ${ JenkinsPlugins.get().jenkinsVersion} " )
151+ }
152+
153+ dependencies. each { String dependency ->
154+ context. testImplementation dependency
155+ }
156+ }
0 commit comments