|
| 1 | +// Hermetic fixture for ../smoke-test-failures.sh: each configuration fails to resolve in one way, |
| 2 | +// against a generated local Maven repo (see ../../make-stub-repo.sh). |
| 3 | +allprojects { |
| 4 | + repositories { |
| 5 | + maven { url rootProject.file('localrepo').toURI() } |
| 6 | + } |
| 7 | +} |
| 8 | + |
| 9 | +configurations { |
| 10 | + forced |
| 11 | + shadowing |
| 12 | + verified |
| 13 | + walkAborted |
| 14 | + quiet |
| 15 | +} |
| 16 | +configurations.forced.resolutionStrategy.force 'demo:c:9.9' |
| 17 | + |
| 18 | +dependencies { |
| 19 | + forced 'demo:a:1.0' |
| 20 | + // Shares the group:name of project :lib, but is an external module. |
| 21 | + shadowing 'demo:lib:7.7' |
| 22 | + verified 'demo:a:1.0' |
| 23 | + verified 'demo:tampered:1.0' |
| 24 | + walkAborted 'demo:a:1.0' |
| 25 | + walkAborted 'demo:boom:1.0' |
| 26 | + quiet 'demo:quiet:1.0' |
| 27 | +} |
| 28 | + |
| 29 | +// Artifact transforms and dependency verification exist only on newer Gradle. |
| 30 | +if (org.gradle.util.GradleVersion.current() >= org.gradle.util.GradleVersion.version('6.2')) { |
| 31 | + apply from: 'transforms.gradle' |
| 32 | +} |
| 33 | + |
| 34 | +// No build throws from the walk's own reads on demand, so make two of them throw for one module |
| 35 | +// each: boom's children, and quiet's file with an empty message. |
| 36 | +tasks.matching { it.name == 'socketFactsCollect' }.all { t -> |
| 37 | + t.doFirst { |
| 38 | + def boom = configurations.walkAborted.resolvedConfiguration.firstLevelModuleDependencies.find { it.moduleName == 'boom' } |
| 39 | + def depMeta = boom.getClass().metaClass |
| 40 | + def children = depMeta.getMetaMethod('getChildren', [] as Object[]) |
| 41 | + depMeta.getChildren = { -> |
| 42 | + if (delegate.moduleName == 'boom') { |
| 43 | + throw new IllegalStateException('walk aborted by the fixture') |
| 44 | + } |
| 45 | + children.invoke(delegate) |
| 46 | + } |
| 47 | + def quiet = configurations.quiet.resolvedConfiguration.resolvedArtifacts.find { it.name == 'quiet' } |
| 48 | + def artifactMeta = quiet.getClass().metaClass |
| 49 | + def file = artifactMeta.getMetaMethod('getFile', [] as Object[]) |
| 50 | + artifactMeta.getFile = { -> |
| 51 | + if (delegate.name == 'quiet') { |
| 52 | + throw new RuntimeException('') |
| 53 | + } |
| 54 | + file.invoke(delegate) |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments