Skip to content

Commit

Permalink
Merge pull request #145 from nebula-plugins/add-archive-configuration…
Browse files Browse the repository at this point in the history
…s-to-ignored-list

Add archives and bootArchives configurations to list of configuration…
  • Loading branch information
OdysseusLives committed Apr 13, 2023
2 parents c9d442c + bfcb483 commit 06c702c
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package nebula.plugin.resolutionrules

import nebula.test.IntegrationSpec
import org.codehaus.groovy.runtime.StackTraceUtils
import nebula.test.IntegrationTestKitSpec

class IgnoredConfigurationsWithRulesSpec extends IntegrationSpec {
class IgnoredConfigurationsWithRulesSpec extends IntegrationTestKitSpec {
File rulesJsonFile

def setup() {
rulesJsonFile = new File(projectDir, "${moduleName}.json")
definePluginOutsideOfPluginBlock = true

buildFile << """
apply plugin: 'java'
Expand Down Expand Up @@ -61,11 +61,70 @@ class IgnoredConfigurationsWithRulesSpec extends IntegrationSpec {
""".stripIndent()

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

then:
!result.standardOutput.contains('com.google.guava:guava:19.0-rc2 -> 19.0-rc1')
!result.standardOutput.contains('bouncycastle:bcmail-jdk16:1.40 -> org.bouncycastle:bcmail-jdk16:')
!result.output.contains('com.google.guava:guava:19.0-rc2 -> 19.0-rc1')
!result.output.contains('bouncycastle:bcmail-jdk16:1.40 -> org.bouncycastle:bcmail-jdk16:')
}


def 'does not apply for configurations housing only built artifacts'() {
given:
forwardOutput = true
keepFiles = true
def intermediateBuildFileText = buildFile.text
buildFile.delete()
buildFile.createNewFile()
buildFile << """
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.+")
}
}""".stripIndent()
buildFile << intermediateBuildFileText
buildFile << """
apply plugin: 'org.springframework.boot'
dependencies {
implementation 'com.google.guava:guava:19.0-rc2'
implementation 'bouncycastle:bcmail-jdk16:1.40'
}
tasks.named("bootJar") {
mainClass = 'com.test.HelloWorldApp'
}
project.tasks.register("viewSpecificConfigurations").configure {
it.dependsOn project.tasks.named('bootJar')
it.dependsOn project.tasks.named('assemble')
doLast {
project.configurations.matching { it.name == 'bootArchives' || it.name == 'archives' }.each {
println "Dependencies for \${it}: " + it.allDependencies
println "Artifacts for \${it}: " + it.allArtifacts
}
}
}
""".stripIndent()
writeJavaSourceFile("""
package com.test;
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World");
}
}""".stripIndent())

when:
def result = runTasks( 'bootJar', 'assemble')
def resolutionResult = runTasks( 'viewSpecificConfigurations')

then:
!result.output.contains('FAIL')
!resolutionResult.output.contains('FAIL')
resolutionResult.output.contains(':jar')
}

}
14 changes: 12 additions & 2 deletions src/main/kotlin/nebula/plugin/resolutionrules/plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,16 @@ class ResolutionRulesPlugin : Plugin<Project> {
private lateinit var project: Project
private lateinit var configurations: ConfigurationContainer
private lateinit var extension: NebulaResolutionRulesExtension
private val ignoredConfigurationPrefixes = listOf(RESOLUTION_RULES_CONFIG_NAME, SPRING_VERSION_MANAGEMENT_CONFIG_NAME,
NEBULA_RECOMMENDER_BOM_CONFIG_NAME, SCALA_INCREMENTAL_ANALYSIS_CONFIGURATION_PREFIX, KTLINT_CONFIGURATION_PREFIX, REPOSITORY_CONTENT_DESCRIPTOR_CONFIGURATION_PREFIX)
private val ignoredConfigurationPrefixes = listOf(
RESOLUTION_RULES_CONFIG_NAME,
SPRING_VERSION_MANAGEMENT_CONFIG_NAME,
NEBULA_RECOMMENDER_BOM_CONFIG_NAME,
SCALA_INCREMENTAL_ANALYSIS_CONFIGURATION_PREFIX,
KTLINT_CONFIGURATION_PREFIX,
REPOSITORY_CONTENT_DESCRIPTOR_CONFIGURATION_PREFIX,
BOOT_ARCHIVES_CONFIGURATION_NAME,
ARCHIVES_CONFIGURATION_NAME,
)
private val ignoredConfigurationSuffixes = listOf(PMD_CONFIGURATION_SUFFIX)

companion object {
Expand All @@ -55,6 +63,8 @@ class ResolutionRulesPlugin : Plugin<Project> {
const val PMD_CONFIGURATION_SUFFIX = "PmdAuxClasspath"
const val SCALA_INCREMENTAL_ANALYSIS_CONFIGURATION_PREFIX = "incrementalScalaAnalysis"
const val REPOSITORY_CONTENT_DESCRIPTOR_CONFIGURATION_PREFIX = "repositoryContentDescriptor"
const val BOOT_ARCHIVES_CONFIGURATION_NAME = "bootArchives"
const val ARCHIVES_CONFIGURATION_NAME = "archives"
const val JSON_EXT = ".json"
const val JAR_EXT = ".jar"
const val ZIP_EXT = ".zip"
Expand Down

0 comments on commit 06c702c

Please sign in to comment.