Skip to content

Commit

Permalink
DependenciesInfoPlugin: remove buildscript classpath detection since …
Browse files Browse the repository at this point in the history
…this is unused. We favor build scans
  • Loading branch information
rpalcolea committed Feb 13, 2023
1 parent d1c781f commit 327c13e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package nebula.plugin.info.dependencies
import groovy.transform.CompileDynamic
import nebula.plugin.info.InfoBrokerPlugin
import nebula.plugin.info.InfoCollectorPlugin
import org.gradle.api.Action
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
Expand All @@ -38,7 +39,6 @@ class DependenciesInfoPlugin implements Plugin<Project>, InfoCollectorPlugin {
def dependencyMap = project.rootProject.property('nebulaInfoDependencies')
Map dependencies = [:]
project.plugins.withType(InfoBrokerPlugin) { InfoBrokerPlugin manifestPlugin ->
processBuildscriptClasspath(project, dependencies)
processProjectDependencies(project, dependencies)
dependencyMap["${project.name}-dependencies".toString()] = dependencies
if (project == project.rootProject) {
Expand All @@ -47,20 +47,6 @@ class DependenciesInfoPlugin implements Plugin<Project>, InfoCollectorPlugin {
}
}

private void processBuildscriptClasspath(Project project, Map dependencies) {
project.buildscript.configurations.all({ Configuration conf ->
if (canBeResolved(conf)) {
if(conf.getState() == Configuration.State.UNRESOLVED) {
conf.incoming.afterResolve { ResolvableDependencies resolvableDependencies ->
processIncomingDependencies(resolvableDependencies, 'Resolved-Buildscript-Dependencies', dependencies)
}
} else {
processIncomingDependencies(conf.incoming, 'Resolved-Buildscript-Dependencies', dependencies)
}
}
})
}

private void processProjectDependencies(Project project, Map dependencies) {
project.configurations.all({ Configuration conf ->
if (canBeResolved(conf)) {
Expand Down
123 changes: 2 additions & 121 deletions src/test/groovy/nebula/plugin/info/InfoPluginIntegrationSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class InfoPluginIntegrationSpec extends IntegrationSpec {
ExecutionResult result = runTasksSuccessfully('assemble')

then:
result.standardOutput.contains('{buildscript-singlemodule-test-dependencies={Resolved-Buildscript-Dependencies-Classpath=com.google.guava:guava:21.0, Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}}')
result.standardOutput.contains('{buildscript-singlemodule-test-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}}')
}

def 'it returns build reports at the end of multiproject build'() {
Expand Down Expand Up @@ -96,126 +96,7 @@ class InfoPluginIntegrationSpec extends IntegrationSpec {
result.standardOutput.contains('common-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}')
result.standardOutput.contains('app-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:19.0}')
}

def 'it returns build reports at the end of multiproject build - with buildscript classpath info'() {
given:
buildFile << """
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.google.guava:guava:21.0"
}
}
allprojects {
${applyPlugin(InfoPlugin)}
}
subprojects {
repositories { mavenCentral() }
}
def broker = project.plugins.getPlugin(${InfoBrokerPlugin.name})
gradle.buildFinished {
println broker.buildReports().get('resolved-dependencies')
}
""".stripIndent()

settingsFile << """
rootProject.name='buildscript-multimodule-test'
"""

def common = addSubproject('common', '''\
apply plugin: 'java'
dependencies {
implementation 'com.google.guava:guava:18.0'
}
'''.stripIndent())
writeHelloWorld('nebula.common', common)
def app = addSubproject('app', '''\
apply plugin: 'java'
dependencies {
implementation 'com.google.guava:guava:19.0'
}
'''.stripIndent())
writeHelloWorld('nebula.app', app)

when:
ExecutionResult result = runTasksSuccessfully('build')

then:
result.standardOutput.contains('buildscript-multimodule-test-dependencies={Resolved-Buildscript-Dependencies-Classpath=com.google.guava:guava:21.0}')
result.standardOutput.contains('common-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}')
result.standardOutput.contains('app-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:19.0}')
}

def 'it returns build reports at the end of multiproject build - with buildscript classpath info - submodule has classpath'() {
given:
buildFile << """
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.google.guava:guava:21.0"
}
}
allprojects {
${applyPlugin(InfoPlugin)}
}
subprojects {
repositories { mavenCentral() }
}
def broker = project.plugins.getPlugin(${InfoBrokerPlugin.name})
gradle.buildFinished {
println broker.buildReports().get('resolved-dependencies')
}
""".stripIndent()

settingsFile << """
rootProject.name='buildscript-multimodule-test'
"""

def common = addSubproject('common', '''\
apply plugin: 'java'
dependencies {
implementation 'com.google.guava:guava:18.0'
}
'''.stripIndent())
writeHelloWorld('nebula.common', common)
def app = addSubproject('app', '''\
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.github.jengelman.gradle.plugins:shadow:5.2.0"
}
}
apply plugin: 'java'
dependencies {
implementation 'com.google.guava:guava:19.0'
}
'''.stripIndent())
writeHelloWorld('nebula.app', app)

when:
ExecutionResult result = runTasksSuccessfully('build')

then:
result.standardOutput.contains('{buildscript-multimodule-test-dependencies={Resolved-Buildscript-Dependencies-Classpath=com.google.guava:guava:21.0}, app-dependencies={Resolved-Buildscript-Dependencies-Classpath=com.github.jengelman.gradle.plugins:shadow:5.2.0,commons-io:commons-io:2.6,org.apache.ant:ant:1.9.7,org.apache.ant:ant-launcher:1.9.7,org.apache.logging.log4j:log4j-api:2.17.1,org.apache.logging.log4j:log4j-core:2.17.1,org.codehaus.plexus:plexus-utils:3.0.24,org.jdom:jdom2:2.0.6,org.ow2.asm:asm:7.0-beta,org.ow2.asm:asm-analysis:7.0-beta,org.ow2.asm:asm-commons:7.0-beta,org.ow2.asm:asm-tree:7.0-beta,org.vafer:jdependency:2.1.1, Resolved-Dependencies-CompileClasspath=com.google.guava:guava:19.0}, common-dependencies={Resolved-Dependencies-CompileClasspath=com.google.guava:guava:18.0}}')
}


def 'works with jenkins jpi plugin'() {
given:
buildFile << """
Expand Down

0 comments on commit 327c13e

Please sign in to comment.