Skip to content

Commit

Permalink
Merge pull request #10 from nebula-plugins/use_internal_gradle_depend…
Browse files Browse the repository at this point in the history
…ency_report

Use Gradle's internal dependency report
  • Loading branch information
OdysseusLives authored Jun 26, 2018
2 parents e7a84f2 + e60e5ca commit 2998f3d
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 528 deletions.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-rc-3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -15,59 +15,16 @@
*/
package com.netflix.nebula.dependencybase

import com.netflix.nebula.dependencybase.tasks.NebulaDependencyInsightReportTask
import groovy.lang.Closure
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.execution.TaskExecutionGraph

class DependencyBasePlugin: Plugin<Project> {
val dependencyManagement: DependencyManagement = DependencyManagement()
lateinit var insightTask: NebulaDependencyInsightReportTask

override fun apply(project: Project) {
initializeDependencyBase(project)
enableForceCollection(project)
setupDependencyInsightEnhanced(project)
project.gradle.taskGraph.whenReady( groovyClosure { taskGraph : TaskExecutionGraph ->
if (!taskGraph.hasTask(insightTask)) {
dependencyManagement.disableMessageStore()
}
})
}

private fun initializeDependencyBase(project: Project) {
// We are leaving this around for backwards compatibility of people using this plugin
project.extensions.extraProperties.set("nebulaDependencyBase", dependencyManagement)
dependencyManagement.disableMessageStore()
}

private fun enableForceCollection(project: Project) {
project.configurations.all { conf ->
if (conf.state == Configuration.State.UNRESOLVED) {
conf.incoming.beforeResolve {
val forced = conf.resolutionStrategy.forcedModules
forced.forEach { force -> dependencyManagement.addForce(conf.name, "${force.group}:${force.name}") }
}
}
}
}

private fun setupDependencyInsightEnhanced(project: Project) {
insightTask = project.tasks.create("dependencyInsightEnhanced", NebulaDependencyInsightReportTask::class.java)
insightTask.reasonLookup = dependencyManagement
project.afterEvaluate {
it.tasks.findByName("dependencyInsight").apply {
if (this == null) return@afterEvaluate
dependsOn(insightTask)
enabled = false
}
}
}
}

inline fun <S,T> S.groovyClosure(crossinline call: (a: T) -> Unit) = object : Closure<Unit>(this) {
@Suppress("unused")
fun doCall(a: T) {
call(a)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class DependencyManagement {
val pluginMessages: MutableSet<String> = mutableSetOf()
private var shouldStoreReason: Boolean = true

// Leaving these methods in place for backwards compatibility for projects calling them

fun addRecommendation(configuration: String, coordinate: String, version: String, source: String, plugin: String) {
if (shouldStoreReason) reasons.add(Recommendation(configuration, coordinate, version, source))
}
Expand Down

This file was deleted.

Loading

0 comments on commit 2998f3d

Please sign in to comment.