|
32 | 32 | import org.gradle.api.DefaultTask; |
33 | 33 | import org.gradle.api.GradleException; |
34 | 34 | import org.gradle.api.artifacts.ConfigurationContainer; |
| 35 | +import org.gradle.api.artifacts.ResolvedArtifact; |
35 | 36 | import org.gradle.api.artifacts.dsl.DependencyHandler; |
36 | 37 | import org.gradle.api.tasks.TaskAction; |
37 | 38 |
|
|
46 | 47 | * Checks the validity of a bom. |
47 | 48 | * |
48 | 49 | * @author Andy Wilkinson |
| 50 | + * @author Wick Dynex |
49 | 51 | */ |
50 | 52 | public abstract class CheckBom extends DefaultTask { |
51 | 53 |
|
@@ -207,16 +209,32 @@ private void checkDependencyManagementAlignment(Library library, List<String> er |
207 | 209 | } |
208 | 210 | } |
209 | 211 |
|
| 212 | +// private File resolveBom(Library library, String alignsWithBom) { |
| 213 | +// String coordinates = alignsWithBom + ":" + library.getVersion().getVersion() + "@pom"; |
| 214 | +// Set<File> files = this.configurations.detachedConfiguration(this.dependencies.create(coordinates)) |
| 215 | +// .getResolvedConfiguration() |
| 216 | +// .getFiles(); |
| 217 | +// if (files.size() != 1) { |
| 218 | +// throw new IllegalStateException( |
| 219 | +// "Expected a single file but '" + coordinates + "' resolved to " + files.size()); |
| 220 | +// } |
| 221 | +// return files.iterator().next(); |
| 222 | +// } |
| 223 | + |
| 224 | + |
210 | 225 | private File resolveBom(Library library, String alignsWithBom) { |
211 | 226 | String coordinates = alignsWithBom + ":" + library.getVersion().getVersion() + "@pom"; |
212 | | - Set<File> files = this.configurations.detachedConfiguration(this.dependencies.create(coordinates)) |
213 | | - .getResolvedConfiguration() |
214 | | - .getFiles(); |
215 | | - if (files.size() != 1) { |
| 227 | + |
| 228 | + Set<ResolvedArtifact> artifacts = this.configurations |
| 229 | + .detachedConfiguration(this.dependencies.create(coordinates)) |
| 230 | + .getResolvedConfiguration() |
| 231 | + .getResolvedArtifacts(); |
| 232 | + |
| 233 | + if (artifacts.size() != 1) { |
216 | 234 | throw new IllegalStateException( |
217 | | - "Expected a single file but '" + coordinates + "' resolved to " + files.size()); |
| 235 | + "Expected a single file but '" + coordinates + "' resolved to " + artifacts.size()); |
218 | 236 | } |
219 | | - return files.iterator().next(); |
220 | | - } |
221 | 237 |
|
| 238 | + return artifacts.iterator().next().getFile(); |
| 239 | + } |
222 | 240 | } |
0 commit comments