@@ -14,6 +14,7 @@ import nebula.test.dsl.subProject
1414import nebula.test.dsl.testProject
1515import org.gradle.kotlin.dsl.findByType
1616import org.gradle.testfixtures.ProjectBuilder
17+ import org.gradle.testkit.runner.TaskOutcome
1718import org.junit.jupiter.api.Test
1819import org.junit.jupiter.api.io.TempDir
1920import java.io.File
@@ -22,9 +23,11 @@ class ArchrulesAggregateConsoleReportPluginTest {
2223 @TempDir
2324 lateinit var projectDir: File
2425
25- private fun TestProjectBuilder.setup (withFailures : Boolean = true) {
26+ private fun TestProjectBuilder.setup (withFailures : Boolean = true) {
2627 properties {
2728 buildCache(true )
29+ configurationCache(true )
30+ property(" org.gradle.unsafe.isolated-projects" ," true" )
2831 }
2932 rootProject {
3033 plugins {
@@ -55,7 +58,7 @@ class ArchrulesAggregateConsoleReportPluginTest {
5558 )
5659 src {
5760 main {
58- if (withFailures) {
61+ if (withFailures) {
5962 exampleDeprecatedUsage(" FailingCode1" )
6063 }
6164 }
@@ -66,7 +69,7 @@ class ArchrulesAggregateConsoleReportPluginTest {
6669 id(" java" )
6770 id(" com.netflix.nebula.archrules.runner" )
6871 }
69- repositories{
72+ repositories {
7073 mavenCentral()
7174 }
7275 dependencies(
@@ -75,7 +78,7 @@ class ArchrulesAggregateConsoleReportPluginTest {
7578 )
7679 src {
7780 main {
78- if (withFailures) {
81+ if (withFailures) {
7982 exampleDeprecatedUsage(" FailingCode2" )
8083 }
8184 }
@@ -96,7 +99,7 @@ class ArchrulesAggregateConsoleReportPluginTest {
9699 @Test
97100 fun test () {
98101 val runner = testProject(projectDir) {
99- setup()
102+ setup()
100103 }
101104 val result = runner.run (" archRulesAggregateConsoleReport" ) {
102105 forwardOutput()
@@ -110,8 +113,9 @@ class ArchrulesAggregateConsoleReportPluginTest {
110113 fun `test passing skip` () {
111114 val runner = testProject(projectDir) {
112115 setup(withFailures = false )
113- rootProject{
114- rawBuildScript("""
116+ rootProject {
117+ rawBuildScript(
118+ """
115119archRulesAggregate {
116120 skipPassingSummaries = true
117121}
@@ -132,8 +136,9 @@ archRulesAggregate {
132136 fun `test details threshold` () {
133137 val runner = testProject(projectDir) {
134138 setup()
135- rootProject{
136- rawBuildScript("""
139+ rootProject {
140+ rawBuildScript(
141+ """
137142archRulesAggregate {
138143 consoleDetailsThreshold("LOW")
139144}
@@ -147,4 +152,29 @@ archRulesAggregate {
147152 assertThat(result.output)
148153 .contains(" Method <com.example.consumer.FailingCode1.aMethod()> calls method <com.example.library.LibraryClass.deprecatedApi()>" )
149154 }
155+
156+ @Test
157+ fun `test empty subproject` () {
158+ val runner = testProject(projectDir) {
159+ setup()
160+ subProject(" empty" ) {
161+ plugins {
162+ id(" base" )
163+ }
164+ rawBuildScript(
165+ // language=kotlin
166+ """
167+ val jarTask = tasks.register<Jar>("someJar")
168+ artifacts {
169+ add("default", jarTask)
170+ }
171+ """
172+ )
173+ }
174+ }
175+ val result = runner.run (" archRulesAggregateConsoleReport" )
176+ assertThat(result.task(" :archRulesAggregateConsoleReport" ))
177+ .hasOutcome(TaskOutcome .SUCCESS )
178+ assertThat(result.output).doesNotContain(" Archrules data read failed" )
179+ }
150180}
0 commit comments