Skip to content

Commit 6f1efea

Browse files
author
John Burns
committed
baseline java 17 and Gradle 9
mark non-testkit base test classes for removal mark spock-based testkit base classes as deprecated remove automatic terms of use agreement
1 parent fbfdda0 commit 6f1efea

File tree

15 files changed

+70
-47
lines changed

15 files changed

+70
-47
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ jobs:
2424
with:
2525
distribution: 'zulu'
2626
java-version: |
27-
11
2827
17
2928
21
3029
${{ matrix.java }}
@@ -33,6 +32,9 @@ jobs:
3332
uses: gradle/actions/setup-gradle@v5
3433
with:
3534
cache-overwrite-existing: true
35+
build-scan-publish: true
36+
build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service'
37+
build-scan-terms-of-use-agree: 'yes'
3638
- name: Gradle build
3739
run: ./gradlew --stacktrace build
3840
env:

.github/workflows/publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
uses: gradle/actions/setup-gradle@v5
3939
with:
4040
cache-overwrite-existing: true
41+
build-scan-publish: true
42+
build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service'
43+
build-scan-terms-of-use-agree: 'yes'
4144
- name: Gradle build
4245
run: ./gradlew --stacktrace build
4346
- name: Publish candidate

build.gradle.kts

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import nebula.plugin.contacts.Contact
2-
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
32
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
4-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
53

64
/*
75
* Copyright 2014-2019 Netflix, Inc.
@@ -49,34 +47,26 @@ dependencies {
4947
testImplementation("org.spockframework:spock-core:2.3-groovy-4.0")
5048
testImplementation("org.spockframework:spock-junit4:2.3-groovy-4.0")
5149
testImplementation("uk.org.webcompere:system-stubs-junit4:2.0.1")
52-
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.13.4")
53-
testImplementation("org.junit.jupiter:junit-jupiter-params:5.13.4")
5450

5551
archRulesImplementation("com.netflix.nebula:archrules-common:0.+")
5652
archRulesTestImplementation("org.spockframework:spock-junit4:2.3-groovy-4.0")
53+
archRulesTestImplementation(gradleTestKit())
5754
}
5855

59-
tasks.withType<Test> {
60-
useJUnitPlatform()
61-
maxParallelForks = 2
62-
finalizedBy(tasks.named("jacocoTestReport"))
63-
javaLauncher = javaToolchains.launcherFor {
64-
languageVersion = JavaLanguageVersion.of(17)
65-
}
66-
}
67-
tasks.named<JavaCompile>("compileTestJava") {
68-
javaCompiler.set(
69-
javaToolchains.compilerFor {
70-
languageVersion = JavaLanguageVersion.of(17)
56+
testing {
57+
suites {
58+
named<JvmTestSuite>("test") {
59+
useJUnitJupiter()
60+
targets {
61+
all {
62+
testTask.configure {
63+
maxParallelForks = 3
64+
finalizedBy(tasks.named("jacocoTestReport"))
65+
}
66+
}
67+
}
7168
}
72-
)
73-
}
74-
tasks.named<KotlinCompile>("compileTestKotlin") {
75-
kotlinJavaToolchain.toolchain.use(
76-
javaToolchains.launcherFor {
77-
languageVersion = JavaLanguageVersion.of(17)
78-
}
79-
)
69+
}
8070
}
8171

8272
tasks.named("build") {
@@ -85,13 +75,12 @@ tasks.named("build") {
8575

8676
java {
8777
toolchain {
88-
languageVersion = JavaLanguageVersion.of(8)
78+
languageVersion = JavaLanguageVersion.of(17)
8979
}
9080
}
9181

9282
kotlin {
9383
compilerOptions {
94-
jvmTarget.set(JvmTarget.JVM_1_8)
9584
languageVersion.set(KotlinVersion.KOTLIN_2_0)
9685
apiVersion.set(KotlinVersion.KOTLIN_2_0)
9786
}

gradle.lockfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This file is expected to be part of source control.
44
cglib:cglib-nodep:3.2.2=archRulesTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
55
com.netflix.nebula:archrules-common:0.9.0=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath
6-
com.netflix.nebula:nebula-archrules-core:0.14.1=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath
6+
com.netflix.nebula:nebula-archrules-core:0.15.1=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath
77
com.tngtech.archunit:archunit:1.4.1=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath
88
junit:junit:4.13.2=archRulesTestCompileClasspath,archRulesTestRuntimeClasspath,compileClasspath,testCompileClasspath,testRuntimeClasspath
99
net.bytebuddy:byte-buddy-agent:1.11.13=testCompileClasspath,testRuntimeClasspath
@@ -19,9 +19,9 @@ org.jetbrains.kotlin:kotlin-stdlib:2.2.0=archRulesCompileClasspath,archRulesRunt
1919
org.jetbrains:annotations:13.0=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath,compileClasspath,embeddedKotlin,testCompileClasspath,testRuntimeClasspath
2020
org.jspecify:jspecify:1.0.0=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
2121
org.junit.jupiter:junit-jupiter-api:5.14.3=archRulesTestCompileClasspath,archRulesTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
22-
org.junit.jupiter:junit-jupiter-engine:5.14.3=archRulesTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
22+
org.junit.jupiter:junit-jupiter-engine:5.14.3=archRulesTestRuntimeClasspath,testRuntimeClasspath
2323
org.junit.jupiter:junit-jupiter-params:5.14.3=archRulesTestCompileClasspath,archRulesTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
24-
org.junit.jupiter:junit-jupiter:5.14.3=archRulesTestCompileClasspath,archRulesTestRuntimeClasspath
24+
org.junit.jupiter:junit-jupiter:5.14.3=archRulesTestCompileClasspath,archRulesTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
2525
org.junit.platform:junit-platform-commons:1.14.3=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
2626
org.junit.platform:junit-platform-engine:1.14.3=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
2727
org.junit.platform:junit-platform-launcher:1.14.3=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath,compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath

settings.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ plugins {
88
id 'com.gradle.develocity' version '4.2'
99
}
1010

11-
develocity {
12-
buildScan {
13-
termsOfUseUrl = 'https://gradle.com/terms-of-service'
14-
termsOfUseAgree = 'yes'
15-
}
16-
}
17-
1811
rootProject.name = 'nebula-test'
1912

2013
includeBuild(".") // allows included build to depend on root project

src/archRules/java/com/netflix/nebula/test/archrules/NebulaTestArchRules.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.netflix.nebula.test.archrules;
22

33
import com.netflix.nebula.archrules.core.ArchRulesService;
4+
import com.tngtech.archunit.core.domain.JavaClass;
45
import com.tngtech.archunit.lang.ArchRule;
56
import com.tngtech.archunit.lang.Priority;
67
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition;
@@ -13,8 +14,7 @@
1314
import static com.netflix.nebula.archrules.common.CanBeAnnotated.Predicates.deprecatedForRemoval;
1415
import static com.tngtech.archunit.core.domain.JavaAccess.Predicates.target;
1516
import static com.tngtech.archunit.core.domain.JavaAccess.Predicates.targetOwner;
16-
import static com.tngtech.archunit.core.domain.JavaClass.Predicates.resideInAPackage;
17-
import static com.tngtech.archunit.core.domain.JavaClass.Predicates.resideOutsideOfPackages;
17+
import static com.tngtech.archunit.core.domain.JavaClass.Predicates.*;
1818
import static com.tngtech.archunit.lang.conditions.ArchPredicates.are;
1919
import static com.tngtech.archunit.lang.conditions.ArchPredicates.is;
2020

@@ -38,11 +38,26 @@ public class NebulaTestArchRules implements ArchRulesService {
3838
.allowEmptyShould(true)
3939
.because("deprecated for removal APIs will be removed in the next major version of nebula-test");
4040

41+
static final ArchRule SPOCK = ArchRuleDefinition.priority(Priority.MEDIUM)
42+
.noClasses().that(resideOutsideOfPackages("nebula.test.."))
43+
.should()
44+
.beAssignableTo("nebula.test.IntegrationBase")
45+
.orShould().dependOnClassesThat(assignableTo("nebula.test.IntegrationBase"))
46+
.orShould().beAssignableTo("nebula.test.IntegrationTestKitBase")
47+
.orShould().dependOnClassesThat(assignableTo("nebula.test.IntegrationTestKitBase"))
48+
.orShould().beAssignableTo("nebula.test.IntegrationTestKitSpec")
49+
.orShould().dependOnClassesThat(assignableTo("nebula.test.IntegrationTestKitSpec"))
50+
.orShould().beAssignableTo("nebula.test.AbstractIntegrationTestKitBase")
51+
.orShould().dependOnClassesThat(assignableTo("nebula.test.AbstractIntegrationTestKitBase"))
52+
.allowEmptyShould(true)
53+
.because("spock base classes will eventually be deprecated in favor of TestKit DSL");
54+
4155
@Override
4256
public Map<String, ArchRule> getRules() {
4357
Map<String, ArchRule> rules = new HashMap<>();
4458
rules.put("noDeprecatedNebulaTest", DEPRECATED);
4559
rules.put("noDeprecatedForRemovalNebulaTest", DEPRECATED_FOR_REMOVAL);
60+
rules.put("don't use spock base classes", SPOCK);
4661
return rules;
4762
}
4863
}

src/archRulesTest/java/com/netflix/nebula/test/archrules/NebulaTestArchRulesTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.netflix.nebula.archrules.core.Runner;
44
import com.tngtech.archunit.lang.EvaluationResult;
55
import nebula.test.Integration;
6+
import nebula.test.IntegrationTestKitSpec;
67
import org.junit.jupiter.api.Test;
78

89
import static org.assertj.core.api.Assertions.assertThat;
@@ -18,4 +19,14 @@ public void testNebulaTestArchRule() {
1819
static abstract class Failing implements Integration {
1920

2021
}
22+
23+
@Test
24+
public void test_spock() {
25+
EvaluationResult result = Runner.check(NebulaTestArchRules.SPOCK, Failing.class);
26+
assertThat(result.hasViolation()).isTrue();
27+
}
28+
29+
static abstract class SpockFailing extends IntegrationTestKitSpec {
30+
31+
}
2132
}

src/main/groovy/nebula/test/BaseIntegrationSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import spock.lang.Specification
3030
*
3131
* This will be removed in the next nebula-test major version
3232
*/
33-
@Deprecated
33+
@Deprecated(forRemoval = true)
3434
abstract class BaseIntegrationSpec extends Specification implements IntegrationBase {
3535
@Rule
3636
TestName testName = new TestName()

src/main/groovy/nebula/test/Integration.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import java.util.function.Predicate
3333
* @deprecated in favor of Gradle TestKit-based tests
3434
*/
3535
@CompileStatic
36-
@Deprecated
36+
@Deprecated(forRemoval = true)
3737
abstract trait Integration extends IntegrationBase {
3838
private static final String DEFAULT_REMOTE_DEBUG_JVM_ARGUMENTS = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
3939
private static final Integer DEFAULT_DAEMON_MAX_IDLE_TIME_IN_SECONDS_IN_MEMORY_SAFE_MODE = 15;

src/main/groovy/nebula/test/IntegrationBase.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.gradle.api.logging.LogLevel
2525
*
2626
* <p>This is testing framework agnostic and can be either extended (see {@link BaseIntegrationSpec}) or composed, by
2727
* including it inside a test class as field.
28+
* Prefer <a href="https://github.com/nebula-plugins/nebula-test/wiki/TestKit-DSL">TestKit DSL</a> instead
2829
*/
2930
@CompileStatic
3031
abstract trait IntegrationBase {

0 commit comments

Comments
 (0)