@@ -58,4 +58,134 @@ class DependencyRecommendationsPluginConfigurationCacheSpec extends IntegrationT
5858 runTasks(' --configuration-cache' , ' dependencies' )
5959 }
6060
61+ def ' strictMode property works with configuration cache' () {
62+ def repo = new MavenRepo ()
63+ repo. root = new File (projectDir, ' build/bomrepo' )
64+ def pom = new Pom (' test.nebula.bom' , ' testbom' , ' 1.0.0' , ArtifactType . POM )
65+ pom. addManagementDependency(' test.nebula' , ' foo' , ' 1.0.0' )
66+ repo. poms. add(pom)
67+ repo. generate()
68+ def graph = new DependencyGraphBuilder ()
69+ .addModule(' test.nebula:foo:1.0.0' )
70+ .build()
71+ def generator = new GradleDependencyGenerator (graph)
72+ generator. generateTestMavenRepo()
73+
74+ buildFile << """ \
75+ plugins {
76+ id 'com.netflix.nebula.dependency-recommender'
77+ id 'java'
78+ }
79+
80+ repositories {
81+ maven { url = '${ repo.root.absoluteFile.toURI()} ' }
82+ ${ generator.mavenRepositoryBlock}
83+ }
84+
85+ dependencyRecommendations {
86+ strictMode.set(false)
87+ }
88+
89+ dependencies {
90+ nebulaRecommenderBom 'test.nebula.bom:testbom:1.0.0@pom'
91+ implementation 'test.nebula:foo'
92+ }
93+ """ . stripIndent()
94+
95+ when :
96+ def result1 = runTasks(' --configuration-cache' , ' dependencies' )
97+ def result2 = runTasks(' --configuration-cache' , ' dependencies' )
98+
99+ then :
100+ result1. output. contains(' Calculating task graph' )
101+ result2. output. contains(' Reusing configuration cache' )
102+ }
103+
104+ def ' eagerlyResolve property works with configuration cache' () {
105+ def repo = new MavenRepo ()
106+ repo. root = new File (projectDir, ' build/bomrepo' )
107+ def pom = new Pom (' test.nebula.bom' , ' testbom' , ' 1.0.0' , ArtifactType . POM )
108+ pom. addManagementDependency(' test.nebula' , ' foo' , ' 1.0.0' )
109+ repo. poms. add(pom)
110+ repo. generate()
111+ def graph = new DependencyGraphBuilder ()
112+ .addModule(' test.nebula:foo:1.0.0' )
113+ .build()
114+ def generator = new GradleDependencyGenerator (graph)
115+ generator. generateTestMavenRepo()
116+
117+ buildFile << """ \
118+ plugins {
119+ id 'com.netflix.nebula.dependency-recommender'
120+ id 'java'
121+ }
122+
123+ repositories {
124+ maven { url = '${ repo.root.absoluteFile.toURI()} ' }
125+ ${ generator.mavenRepositoryBlock}
126+ }
127+
128+ dependencyRecommendations {
129+ eagerlyResolve.set(true)
130+ }
131+
132+ dependencies {
133+ nebulaRecommenderBom 'test.nebula.bom:testbom:1.0.0@pom'
134+ implementation 'test.nebula:foo'
135+ }
136+ """ . stripIndent()
137+
138+ when :
139+ def result1 = runTasks(' --configuration-cache' , ' dependencies' )
140+ def result2 = runTasks(' --configuration-cache' , ' dependencies' )
141+
142+ then :
143+ result1. output. contains(' Calculating task graph' )
144+ result2. output. contains(' Reusing configuration cache' )
145+ }
146+
147+ def ' excludedConfigurations SetProperty works with configuration cache' () {
148+ def repo = new MavenRepo ()
149+ repo. root = new File (projectDir, ' build/bomrepo' )
150+ def pom = new Pom (' test.nebula.bom' , ' testbom' , ' 1.0.0' , ArtifactType . POM )
151+ pom. addManagementDependency(' test.nebula' , ' foo' , ' 1.0.0' )
152+ repo. poms. add(pom)
153+ repo. generate()
154+ def graph = new DependencyGraphBuilder ()
155+ .addModule(' test.nebula:foo:1.0.0' )
156+ .build()
157+ def generator = new GradleDependencyGenerator (graph)
158+ generator. generateTestMavenRepo()
159+
160+ buildFile << """ \
161+ plugins {
162+ id 'com.netflix.nebula.dependency-recommender'
163+ id 'java'
164+ }
165+
166+ repositories {
167+ maven { url = '${ repo.root.absoluteFile.toURI()} ' }
168+ ${ generator.mavenRepositoryBlock}
169+ }
170+
171+ dependencyRecommendations {
172+ excludedConfigurations.add('testCompileClasspath')
173+ excludedConfigurationPrefixes.add('test')
174+ }
175+
176+ dependencies {
177+ nebulaRecommenderBom 'test.nebula.bom:testbom:1.0.0@pom'
178+ implementation 'test.nebula:foo'
179+ }
180+ """ . stripIndent()
181+
182+ when :
183+ def result1 = runTasks(' --configuration-cache' , ' dependencies' )
184+ def result2 = runTasks(' --configuration-cache' , ' dependencies' )
185+
186+ then :
187+ result1. output. contains(' Calculating task graph' )
188+ result2. output. contains(' Reusing configuration cache' )
189+ }
190+
61191}
0 commit comments