Skip to content

Commit 06c702c

Browse files
Merge pull request #145 from nebula-plugins/add-archive-configurations-to-ignored-list
Add archives and bootArchives configurations to list of configuration…
2 parents c9d442c + bfcb483 commit 06c702c

File tree

2 files changed

+77
-8
lines changed

2 files changed

+77
-8
lines changed

src/integTest/groovy/nebula/plugin/resolutionrules/IgnoredConfigurationsWithRulesSpec.groovy

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package nebula.plugin.resolutionrules
22

3-
import nebula.test.IntegrationSpec
4-
import org.codehaus.groovy.runtime.StackTraceUtils
3+
import nebula.test.IntegrationTestKitSpec
54

6-
class IgnoredConfigurationsWithRulesSpec extends IntegrationSpec {
5+
class IgnoredConfigurationsWithRulesSpec extends IntegrationTestKitSpec {
76
File rulesJsonFile
87

98
def setup() {
109
rulesJsonFile = new File(projectDir, "${moduleName}.json")
10+
definePluginOutsideOfPluginBlock = true
1111

1212
buildFile << """
1313
apply plugin: 'java'
@@ -61,11 +61,70 @@ class IgnoredConfigurationsWithRulesSpec extends IntegrationSpec {
6161
""".stripIndent()
6262

6363
when:
64-
def result = runTasksSuccessfully('dependencies', '--configuration', 'compileClasspath', '-PresolutionRulesIgnoredConfigurations=myIgnoredConfiguration,myExtraIgnoredConfiguration')
64+
def result = runTasks('dependencies', '--configuration', 'compileClasspath', '-PresolutionRulesIgnoredConfigurations=myIgnoredConfiguration,myExtraIgnoredConfiguration')
6565

6666
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')
69128
}
70129

71130
}

src/main/kotlin/nebula/plugin/resolutionrules/plugin.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,16 @@ class ResolutionRulesPlugin : Plugin<Project> {
4242
private lateinit var project: Project
4343
private lateinit var configurations: ConfigurationContainer
4444
private lateinit var extension: NebulaResolutionRulesExtension
45-
private val ignoredConfigurationPrefixes = listOf(RESOLUTION_RULES_CONFIG_NAME, SPRING_VERSION_MANAGEMENT_CONFIG_NAME,
46-
NEBULA_RECOMMENDER_BOM_CONFIG_NAME, SCALA_INCREMENTAL_ANALYSIS_CONFIGURATION_PREFIX, KTLINT_CONFIGURATION_PREFIX, REPOSITORY_CONTENT_DESCRIPTOR_CONFIGURATION_PREFIX)
45+
private val ignoredConfigurationPrefixes = listOf(
46+
RESOLUTION_RULES_CONFIG_NAME,
47+
SPRING_VERSION_MANAGEMENT_CONFIG_NAME,
48+
NEBULA_RECOMMENDER_BOM_CONFIG_NAME,
49+
SCALA_INCREMENTAL_ANALYSIS_CONFIGURATION_PREFIX,
50+
KTLINT_CONFIGURATION_PREFIX,
51+
REPOSITORY_CONTENT_DESCRIPTOR_CONFIGURATION_PREFIX,
52+
BOOT_ARCHIVES_CONFIGURATION_NAME,
53+
ARCHIVES_CONFIGURATION_NAME,
54+
)
4755
private val ignoredConfigurationSuffixes = listOf(PMD_CONFIGURATION_SUFFIX)
4856

4957
companion object {
@@ -55,6 +63,8 @@ class ResolutionRulesPlugin : Plugin<Project> {
5563
const val PMD_CONFIGURATION_SUFFIX = "PmdAuxClasspath"
5664
const val SCALA_INCREMENTAL_ANALYSIS_CONFIGURATION_PREFIX = "incrementalScalaAnalysis"
5765
const val REPOSITORY_CONTENT_DESCRIPTOR_CONFIGURATION_PREFIX = "repositoryContentDescriptor"
66+
const val BOOT_ARCHIVES_CONFIGURATION_NAME = "bootArchives"
67+
const val ARCHIVES_CONFIGURATION_NAME = "archives"
5868
const val JSON_EXT = ".json"
5969
const val JAR_EXT = ".jar"
6070
const val ZIP_EXT = ".zip"

0 commit comments

Comments
 (0)