Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't resolve configurations which are emmiting warning that shouldn't resolved #58

Merged
merged 1 commit into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.VersionP
class DependenciesInfoPlugin implements Plugin<Project>, InfoCollectorPlugin {
private final DefaultVersionComparator versionComparator = new DefaultVersionComparator()
private final VersionParser versionParser = new VersionParser()
private static final List<String> RESOLVABLE_WITH_DEPRECATION_CONF_SUFFIXES = ['compileOnly', 'compile', 'runtime']

@Override
void apply(Project project) {
Expand All @@ -38,20 +39,22 @@ class DependenciesInfoPlugin implements Plugin<Project>, InfoCollectorPlugin {
Map dependencies = [:]
project.plugins.withType(InfoBrokerPlugin) { InfoBrokerPlugin manifestPlugin ->
project.configurations.all( { Configuration conf ->
conf.incoming.afterResolve { ResolvableDependencies resolvableDependencies ->
if (project.configurations.contains(conf)) {
String resolvedDependencies = resolvableDependencies.resolutionResult.allComponents.findAll {
it.id instanceof ModuleComponentIdentifier
}*.moduleVersion
.sort(true, { m1, m2 ->
if (m1.group != m2.group)
return m1.group <=> m2.group ?: -1
if (m1.name != m2.name)
return m1.name <=> m2.name // name is required
versionComparator.compare(new VersionInfo(versionParser.transform(m1.version)), new VersionInfo(versionParser.transform(m2.version)))
})*.toString().join(',')
if (resolvedDependencies) {
dependencies.put("Resolved-Dependencies-${resolvableDependencies.name.capitalize()}", resolvedDependencies)
if (canBeResolved(conf)) {
conf.incoming.afterResolve { ResolvableDependencies resolvableDependencies ->
if (project.configurations.contains(conf)) {
String resolvedDependencies = resolvableDependencies.resolutionResult.allComponents.findAll {
it.id instanceof ModuleComponentIdentifier
}*.moduleVersion
.sort(true, { m1, m2 ->
if (m1.group != m2.group)
return m1.group <=> m2.group ?: -1
if (m1.name != m2.name)
return m1.name <=> m2.name // name is required
versionComparator.compare(new VersionInfo(versionParser.transform(m1.version)), new VersionInfo(versionParser.transform(m2.version)))
})*.toString().join(',')
if (resolvedDependencies) {
dependencies.put("Resolved-Dependencies-${resolvableDependencies.name.capitalize()}", resolvedDependencies)
}
}
}
}
Expand All @@ -64,6 +67,10 @@ class DependenciesInfoPlugin implements Plugin<Project>, InfoCollectorPlugin {
}
}

private boolean canBeResolved(Configuration conf) {
conf.isCanBeResolved() && !RESOLVABLE_WITH_DEPRECATION_CONF_SUFFIXES.any { conf.name.toLowerCase().endsWith(it.toLowerCase()) }
}

@CompileDynamic
private void setInfoDependencies(Project project) {
if (!project.rootProject.hasProperty('nebulaInfoDependencies')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,22 @@ class DependenciesInfoPluginSpec extends PluginProjectSpec {
project.apply plugin: DependenciesInfoPlugin

def guava = project.dependencies.create('com.google.guava:guava:21.0')
def slf4j = project.dependencies.create('org.slf4j:slf4j-api:1.7.30')

project.repositories.add(project.repositories.mavenCentral())

def configurations = project.configurations
def config = configurations.compile
config.dependencies.add(guava)
def compileConfig = configurations.compile
compileConfig.dependencies.add(guava)
configurations.implementation.dependencies.add(slf4j)

def detached = configurations.detachedConfiguration(guava)
configurations.add(detached)
configurations.remove(detached)

config.resolve()
compileConfig.resolve()
detached.resolve()
configurations.compileClasspath.resolve()

when:
brokerPlugin.buildFinished.set(true)
Expand Down