Skip to content

Commit 1e8d0be

Browse files
John Burnswakingrufus
authored andcommitted
add support for non-java sources to TestKitDsl
add support for configuration cache property in TestKitDsl remove old cache setup (don't use caching for now)
1 parent 34caecb commit 1e8d0be

File tree

14 files changed

+185
-50
lines changed

14 files changed

+185
-50
lines changed

.github/workflows/nebula.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,6 @@ jobs:
4040
21
4141
${{ matrix.java }}
4242
java-package: jdk
43-
- uses: actions/cache@v4
44-
id: gradle-cache
45-
with:
46-
path: ~/.gradle/caches
47-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }}
48-
restore-keys: |
49-
- ${{ runner.os }}-gradle-
50-
- uses: actions/cache@v4
51-
id: gradle-wrapper-cache
52-
with:
53-
path: ~/.gradle/wrapper
54-
key: ${{ runner.os }}-gradlewrapper-${{ hashFiles('gradle/wrapper/*') }}
55-
restore-keys: |
56-
- ${{ runner.os }}-gradlewrapper-
5743
- name: Gradle build
5844
run: ./gradlew --stacktrace build
5945
env:
@@ -86,20 +72,6 @@ jobs:
8672
17
8773
21
8874
java-package: jdk
89-
- uses: actions/cache@v4
90-
id: gradle-cache
91-
with:
92-
path: ~/.gradle/caches
93-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle/dependency-locks/*.lockfile') }}
94-
restore-keys: |
95-
- ${{ runner.os }}-gradle-
96-
- uses: actions/cache@v4
97-
id: gradle-wrapper-cache
98-
with:
99-
path: ~/.gradle/wrapper
100-
key: ${{ runner.os }}-gradlewrapper-${{ hashFiles('gradle/wrapper/*') }}
101-
restore-keys: |
102-
- ${{ runner.os }}-gradlewrapper-
10375
- name: Verify plugin publication
10476
if: |
10577
startsWith(github.ref, 'refs/tags/v') &&

gradle.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Manual edits can break the build and are not advised.
33
# This file is expected to be part of source control.
44
cglib:cglib-nodep:3.2.2=archRulesTestRuntimeClasspath,integTestRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
5-
com.netflix.nebula:nebula-archrules-core:0.5.2=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath
5+
com.netflix.nebula:nebula-archrules-core:0.5.3=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath
66
com.tngtech.archunit:archunit:1.4.1=archRulesCompileClasspath,archRulesRuntimeClasspath,archRulesTestCompileClasspath,archRulesTestRuntimeClasspath
77
junit:junit:4.13.2=compileClasspath,integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath
88
net.bytebuddy:byte-buddy-agent:1.11.13=integTestCompileClasspath,integTestRuntimeClasspath,testCompileClasspath,testRuntimeClasspath

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
systemProp.nebula.features.coreLockingSupport=true
2-
2+
org.gradle.configuration-cache=true
33
org.gradle.caching=true
4+
org.gradle.parallel=true

src/main/groovy/nebula/test/dsl/GroovyDsl.groovy

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ class GroovyDsl {
7171
self.test().with(config)
7272
}
7373

74-
static void java(SourceSetBuilder self, String name, Supplier<String> source) {
75-
self.java(name, source.get())
76-
}
77-
7874
/**
7975
* Run a build with expectation of success.
8076
* This method will throw an exception if the build fails.

src/main/java/nebula/test/TestKitOutputUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package nebula.test;
22

3+
import org.jspecify.annotations.NullMarked;
4+
35
import java.util.List;
46
import java.util.Objects;
57
import java.util.concurrent.atomic.AtomicBoolean;
68
import java.util.stream.Collectors;
79
import java.util.stream.Stream;
810

11+
@NullMarked
912
public class TestKitOutputUtil {
1013
private TestKitOutputUtil() {
1114
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package nebula.test.dsl;
22

3+
import org.jspecify.annotations.NullMarked;
4+
5+
@NullMarked
36
public enum BuildscriptLanguage {
47
GROOVY, KOTLIN
58
}

src/main/java/nebula/test/dsl/ProjectProperties.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package nebula.test.dsl;
22

33
import org.jetbrains.annotations.Contract;
4+
import org.jspecify.annotations.NullMarked;
45

56
import java.io.File;
67
import java.io.IOException;
@@ -11,6 +12,7 @@
1112
import java.util.List;
1213

1314
@NebulaTestKitDsl
15+
@NullMarked
1416
public class ProjectProperties {
1517
private final File projectDir;
1618

@@ -27,12 +29,29 @@ public ProjectProperties property(String property, String value) {
2729
return this;
2830
}
2931

32+
/**
33+
*
34+
* @deprecated Use {@link #buildCache(boolean)} instead
35+
*/
3036
@NebulaTestKitDsl
3137
@Contract("_ -> this")
38+
@Deprecated
3239
public ProjectProperties gradleCache(boolean enabled) {
3340
return property("org.gradle.caching", String.valueOf(enabled).toLowerCase());
3441
}
3542

43+
@NebulaTestKitDsl
44+
@Contract("_ -> this")
45+
public ProjectProperties buildCache(boolean enabled) {
46+
return property("org.gradle.caching", String.valueOf(enabled).toLowerCase());
47+
}
48+
49+
@NebulaTestKitDsl
50+
@Contract("_ -> this")
51+
public ProjectProperties configurationCache(boolean enabled) {
52+
return property("org.gradle.configuration-cache", String.valueOf(enabled).toLowerCase());
53+
}
54+
3655
void build() {
3756
Path propsFile = projectDir.toPath().resolve("gradle.properties");
3857
String fileContents = String.join("\n", properties);

src/main/java/nebula/test/dsl/SourceSetBuilder.java

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package nebula.test.dsl;
22

3+
import org.jspecify.annotations.NullMarked;
4+
35
import java.io.File;
46
import java.io.IOException;
57
import java.nio.charset.StandardCharsets;
68
import java.nio.file.Files;
79
import java.nio.file.Path;
10+
import java.util.function.Supplier;
811

12+
@NullMarked
913
public class SourceSetBuilder {
1014
private final File sourcesDir;
1115

@@ -19,8 +23,84 @@ public class SourceSetBuilder {
1923
* @param file the relative path to the java file
2024
* @param contents the contents of the file
2125
*/
26+
@NebulaTestKitDsl
2227
public void java(String file, String contents) {
23-
final Path pathToSourceFile = sourcesDir.toPath().resolve("java").resolve(file);
28+
language("java", file, contents);
29+
}
30+
31+
/**
32+
* write a java file
33+
*
34+
* @param file the relative path to the java file
35+
* @param contents the contents of the file. uses a supplier for more ideomatic DSL usage in groovy and kotlin
36+
*/
37+
@NebulaTestKitDsl
38+
public void java(String file, Supplier<String> contents) {
39+
language("java", file, contents.get());
40+
}
41+
42+
/**
43+
* write a groovy file
44+
*
45+
* @param file the relative path to the groovy file
46+
* @param contents the contents of the file
47+
*/
48+
@NebulaTestKitDsl
49+
public void groovy(String file, String contents) {
50+
language("groovy", file, contents);
51+
}
52+
53+
/**
54+
* write a groovy file
55+
*
56+
* @param file the relative path to the groovy file
57+
* @param contents the contents of the file. uses a supplier for more ideomatic DSL usage in groovy and kotlin
58+
*/
59+
@NebulaTestKitDsl
60+
public void groovy(String file, Supplier<String> contents) {
61+
language("groovy", file, contents.get());
62+
}
63+
64+
/**
65+
* write a kotlin file
66+
*
67+
* @param file the relative path to the kotlin file
68+
* @param contents the contents of the file
69+
*/
70+
public void kotlin(String file, String contents) {
71+
language("kotlin", file, contents);
72+
}
73+
74+
/**
75+
* write a kotlin file
76+
*
77+
* @param file the relative path to the kotlin file
78+
* @param contents the contents of the file. uses a supplier for more ideomatic DSL usage in groovy and kotlin
79+
*/
80+
@NebulaTestKitDsl
81+
public void kotlin(String file, Supplier<String> contents) {
82+
language("kotlin", file, contents.get());
83+
}
84+
85+
/**
86+
* write a file for specified language
87+
*
88+
* @param file the relative path to the java file
89+
* @param contents the contents of the file. uses a supplier for more ideomatic DSL usage in groovy and kotlin
90+
*/
91+
@NebulaTestKitDsl
92+
public void language(String language, String file, Supplier<String> contents) {
93+
language(language, file, contents.get());
94+
}
95+
96+
/**
97+
* write a file for specified language
98+
*
99+
* @param file the relative path to the file
100+
* @param contents the contents of the file
101+
*/
102+
public void language(String language, String file, String contents) {
103+
final Path pathToSourceFile = sourcesDir.toPath().resolve(language).resolve(file);
24104
pathToSourceFile.getParent().toFile().mkdirs();
25105
try {
26106
Files.write(pathToSourceFile, contents.getBytes(StandardCharsets.UTF_8));

src/main/kotlin/nebula/test/dsl/KotlinDsl.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ fun TestProjectBuilder.subProject(name: String, config: ProjectBuilder.() -> Uni
8888
subProject(name).apply(config)
8989
}
9090

91-
@NebulaTestKitDsl
92-
fun SourceSetBuilder.java(fileName: String, source: () -> String) {
93-
java(fileName, source())
94-
}
95-
9691
/**
9792
* Run a build with expectation of success.
9893
* This method will throw an exception if the build fails.

src/test/java/nebula/test/SupportedGradleVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package nebula.test;
22

33
public enum SupportedGradleVersion {
4-
MIN("8.14.3"), MAX("9.2.0");
4+
MIN("8.14.2"), MAX("9.2.1");
55
public final String version;
66
SupportedGradleVersion(String version) {
77
this.version = version;

0 commit comments

Comments
 (0)