|
1 | 1 | package org.gradlex.javamodule.dependencies.test.initialization |
2 | 2 |
|
| 3 | +import org.gradle.testkit.runner.GradleRunner |
3 | 4 | import org.gradlex.javamodule.dependencies.test.fixture.GradleBuild |
4 | 5 | import spock.lang.Specification |
5 | 6 |
|
@@ -67,6 +68,135 @@ class SettingsPluginTest extends Specification { |
67 | 68 | result.task(":lib:compileJava").outcome == SUCCESS |
68 | 69 | } |
69 | 70 |
|
| 71 | + def "configurationCacheHit"() { |
| 72 | + given: |
| 73 | + settingsFile << ''' |
| 74 | + javaModules { |
| 75 | + directory(".") { plugin("java-library") } |
| 76 | + } |
| 77 | + ''' |
| 78 | + libModuleInfoFile << 'module abc.lib { }' |
| 79 | + appModuleInfoFile << ''' |
| 80 | + module org.gradlex.test.app { |
| 81 | + requires abc.lib; |
| 82 | + } |
| 83 | + ''' |
| 84 | + |
| 85 | + |
| 86 | + def runner = runner(':app:compileJava') |
| 87 | + when: |
| 88 | + def result = runner.build() |
| 89 | + |
| 90 | + then: |
| 91 | + result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava") |
| 92 | + |
| 93 | + when: |
| 94 | + result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH |
| 95 | + result = runner.build() |
| 96 | + |
| 97 | + then: |
| 98 | + result.getOutput().contains("Reusing configuration cache.") |
| 99 | + } |
| 100 | + |
| 101 | + def "configurationCacheHit"() { |
| 102 | + given: |
| 103 | + settingsFile << ''' |
| 104 | + javaModules { |
| 105 | + directory(".") { plugin("java-library") } |
| 106 | + } |
| 107 | + ''' |
| 108 | + libModuleInfoFile << 'module abc.lib { }' |
| 109 | + appModuleInfoFile << ''' |
| 110 | + module org.gradlex.test.app { |
| 111 | + requires abc.lib; |
| 112 | + } |
| 113 | + ''' |
| 114 | + |
| 115 | + |
| 116 | + def runner = runner(':app:compileJava') |
| 117 | + when: |
| 118 | + def result = runner.build() |
| 119 | + |
| 120 | + then: |
| 121 | + result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava") |
| 122 | + |
| 123 | + when: |
| 124 | + result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH |
| 125 | + result = runner.build() |
| 126 | + |
| 127 | + then: |
| 128 | + result.getOutput().contains("Reusing configuration cache.") |
| 129 | + } |
| 130 | + |
| 131 | + def "configurationCacheHitIrrelevantChange"() { |
| 132 | + given: |
| 133 | + settingsFile << ''' |
| 134 | + javaModules { |
| 135 | + directory(".") { plugin("java-library") } |
| 136 | + } |
| 137 | + ''' |
| 138 | + libModuleInfoFile << 'module abc.lib { }' |
| 139 | + appModuleInfoFile << ''' |
| 140 | + module org.gradlex.test.app { |
| 141 | + requires abc.lib; |
| 142 | + } |
| 143 | + ''' |
| 144 | + |
| 145 | + def runner = runner(':app:compileJava') |
| 146 | + when: |
| 147 | + def result = runner.build() |
| 148 | + |
| 149 | + then: |
| 150 | + result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava") |
| 151 | + |
| 152 | + when: |
| 153 | + result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH |
| 154 | + appModuleInfoFile.write(''' |
| 155 | + module org.gradlex.test.app { |
| 156 | + requires abc.lib; //This is a comment and should not break the configurationCache |
| 157 | + } |
| 158 | + ''') |
| 159 | + result = runner.build() |
| 160 | + |
| 161 | + then: |
| 162 | + result.getOutput().contains("Reusing configuration cache.") |
| 163 | + } |
| 164 | + |
| 165 | + def "configurationCacheHitRelevantChange"() { |
| 166 | + given: |
| 167 | + settingsFile << ''' |
| 168 | + javaModules { |
| 169 | + directory(".") { plugin("java-library") } |
| 170 | + } |
| 171 | + ''' |
| 172 | + libModuleInfoFile << 'module abc.lib { }' |
| 173 | + appModuleInfoFile << ''' |
| 174 | + module org.gradlex.test.app { |
| 175 | + requires abc.lib; |
| 176 | + } |
| 177 | + ''' |
| 178 | + |
| 179 | + def runner = runner(':app:compileJava') |
| 180 | + when: |
| 181 | + def result = runner.build() |
| 182 | + |
| 183 | + then: |
| 184 | + result.getOutput().contains("Calculating task graph as no cached configuration is available for tasks: :app:compileJava") |
| 185 | + |
| 186 | + when: |
| 187 | + result = runner.build() //TODO Thats a big problem with the Settings Plugin AAAAAAAAH |
| 188 | + appModuleInfoFile.write(''' |
| 189 | + module org.gradlex.test.app { |
| 190 | + //dependency removed; so thats indeed a configuration change |
| 191 | + } |
| 192 | + ''') |
| 193 | + result = runner.build() |
| 194 | + |
| 195 | + then: |
| 196 | + result.output.contains("Calculating task graph as configuration cache cannot be reused because a build logic input of type 'ValueSourceModuleInfo' has changed.\n") |
| 197 | + } |
| 198 | + |
| 199 | + |
70 | 200 | def "automatically sets module for application plugin"() { |
71 | 201 | given: |
72 | 202 | settingsFile << ''' |
|
0 commit comments