|
1 | 1 | package nebula.plugin.resolutionrules |
2 | 2 |
|
3 | | -import nebula.test.IntegrationSpec |
4 | | -import org.codehaus.groovy.runtime.StackTraceUtils |
| 3 | +import nebula.test.IntegrationTestKitSpec |
5 | 4 |
|
6 | | -class IgnoredConfigurationsWithRulesSpec extends IntegrationSpec { |
| 5 | +class IgnoredConfigurationsWithRulesSpec extends IntegrationTestKitSpec { |
7 | 6 | File rulesJsonFile |
8 | 7 |
|
9 | 8 | def setup() { |
10 | 9 | rulesJsonFile = new File(projectDir, "${moduleName}.json") |
| 10 | + definePluginOutsideOfPluginBlock = true |
11 | 11 |
|
12 | 12 | buildFile << """ |
13 | 13 | apply plugin: 'java' |
@@ -61,11 +61,70 @@ class IgnoredConfigurationsWithRulesSpec extends IntegrationSpec { |
61 | 61 | """.stripIndent() |
62 | 62 |
|
63 | 63 | when: |
64 | | - def result = runTasksSuccessfully('dependencies', '--configuration', 'compileClasspath', '-PresolutionRulesIgnoredConfigurations=myIgnoredConfiguration,myExtraIgnoredConfiguration') |
| 64 | + def result = runTasks('dependencies', '--configuration', 'compileClasspath', '-PresolutionRulesIgnoredConfigurations=myIgnoredConfiguration,myExtraIgnoredConfiguration') |
65 | 65 |
|
66 | 66 | then: |
67 | | - !result.standardOutput.contains('com.google.guava:guava:19.0-rc2 -> 19.0-rc1') |
68 | | - !result.standardOutput.contains('bouncycastle:bcmail-jdk16:1.40 -> org.bouncycastle:bcmail-jdk16:') |
| 67 | + !result.output.contains('com.google.guava:guava:19.0-rc2 -> 19.0-rc1') |
| 68 | + !result.output.contains('bouncycastle:bcmail-jdk16:1.40 -> org.bouncycastle:bcmail-jdk16:') |
| 69 | + } |
| 70 | + |
| 71 | + |
| 72 | + def 'does not apply for configurations housing only built artifacts'() { |
| 73 | + given: |
| 74 | + forwardOutput = true |
| 75 | + keepFiles = true |
| 76 | + def intermediateBuildFileText = buildFile.text |
| 77 | + buildFile.delete() |
| 78 | + buildFile.createNewFile() |
| 79 | + buildFile << """ |
| 80 | + buildscript { |
| 81 | + repositories { |
| 82 | + maven { |
| 83 | + url = uri("https://plugins.gradle.org/m2/") |
| 84 | + } |
| 85 | + } |
| 86 | + dependencies { |
| 87 | + classpath("org.springframework.boot:spring-boot-gradle-plugin:2.+") |
| 88 | + } |
| 89 | + }""".stripIndent() |
| 90 | + buildFile << intermediateBuildFileText |
| 91 | + buildFile << """ |
| 92 | + apply plugin: 'org.springframework.boot' |
| 93 | + dependencies { |
| 94 | + implementation 'com.google.guava:guava:19.0-rc2' |
| 95 | + implementation 'bouncycastle:bcmail-jdk16:1.40' |
| 96 | + } |
| 97 | + tasks.named("bootJar") { |
| 98 | + mainClass = 'com.test.HelloWorldApp' |
| 99 | + } |
| 100 | + project.tasks.register("viewSpecificConfigurations").configure { |
| 101 | + it.dependsOn project.tasks.named('bootJar') |
| 102 | + it.dependsOn project.tasks.named('assemble') |
| 103 | + doLast { |
| 104 | + project.configurations.matching { it.name == 'bootArchives' || it.name == 'archives' }.each { |
| 105 | + println "Dependencies for \${it}: " + it.allDependencies |
| 106 | + println "Artifacts for \${it}: " + it.allArtifacts |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | + """.stripIndent() |
| 111 | + writeJavaSourceFile(""" |
| 112 | + package com.test; |
| 113 | + |
| 114 | + class HelloWorldApp { |
| 115 | + public static void main(String[] args) { |
| 116 | + System.out.println("Hello World"); |
| 117 | + } |
| 118 | + }""".stripIndent()) |
| 119 | + |
| 120 | + when: |
| 121 | + def result = runTasks( 'bootJar', 'assemble') |
| 122 | + def resolutionResult = runTasks( 'viewSpecificConfigurations') |
| 123 | + |
| 124 | + then: |
| 125 | + !result.output.contains('FAIL') |
| 126 | + !resolutionResult.output.contains('FAIL') |
| 127 | + resolutionResult.output.contains(':jar') |
69 | 128 | } |
70 | 129 |
|
71 | 130 | } |
0 commit comments