@@ -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,11 +99,13 @@ 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()
103106 }
107+ assertThat(result.task(" :sub1:checkArchRulesMain" ))
108+ .hasOutcome(TaskOutcome .SUCCESS , TaskOutcome .FROM_CACHE )
104109 assertThat(result.output)
105110 .contains(" deprecatedForRemoval MEDIUM (2 failures)" )
106111 .contains(" deprecated LOW (4 failures)" )
@@ -110,8 +115,9 @@ class ArchrulesAggregateConsoleReportPluginTest {
110115 fun `test passing skip` () {
111116 val runner = testProject(projectDir) {
112117 setup(withFailures = false )
113- rootProject{
114- rawBuildScript("""
118+ rootProject {
119+ rawBuildScript(
120+ """
115121archRulesAggregate {
116122 skipPassingSummaries = true
117123}
@@ -132,8 +138,9 @@ archRulesAggregate {
132138 fun `test details threshold` () {
133139 val runner = testProject(projectDir) {
134140 setup()
135- rootProject{
136- rawBuildScript("""
141+ rootProject {
142+ rawBuildScript(
143+ """
137144archRulesAggregate {
138145 consoleDetailsThreshold("LOW")
139146}
@@ -147,4 +154,29 @@ archRulesAggregate {
147154 assertThat(result.output)
148155 .contains(" Method <com.example.consumer.FailingCode1.aMethod()> calls method <com.example.library.LibraryClass.deprecatedApi()>" )
149156 }
157+
158+ @Test
159+ fun `test empty subproject` () {
160+ val runner = testProject(projectDir) {
161+ setup()
162+ subProject(" empty" ) {
163+ plugins {
164+ id(" base" )
165+ }
166+ rawBuildScript(
167+ // language=kotlin
168+ """
169+ val jarTask = tasks.register<Jar>("someJar")
170+ artifacts {
171+ add("default", jarTask)
172+ }
173+ """
174+ )
175+ }
176+ }
177+ val result = runner.run (" archRulesAggregateConsoleReport" )
178+ assertThat(result.task(" :archRulesAggregateConsoleReport" ))
179+ .hasOutcome(TaskOutcome .SUCCESS )
180+ assertThat(result.output).doesNotContain(" Archrules data read failed" )
181+ }
150182}
0 commit comments