-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix: Uses Provider<ResolvedComponentResult> as input to Task #70
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,14 +16,16 @@ public class DependencyGuardPlugin : Plugin<Project> { | |
internal companion object { | ||
internal const val DEPENDENCY_GUARD_TASK_GROUP = "Dependency Guard" | ||
|
||
internal const val DEPENDENCY_GUARD_EXTENSION_NAME = "dependencyGuard" | ||
|
||
internal const val DEPENDENCY_GUARD_TASK_NAME = "dependencyGuard" | ||
|
||
internal const val DEPENDENCY_GUARD_BASELINE_TASK_NAME = "dependencyGuardBaseline" | ||
} | ||
|
||
override fun apply(target: Project) { | ||
val extension = target.extensions.create( | ||
DEPENDENCY_GUARD_TASK_NAME, | ||
DEPENDENCY_GUARD_EXTENSION_NAME, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is not required in this diff, but is zero risk and slightly more explicit. |
||
DependencyGuardPluginExtension::class.java, | ||
target.objects | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,23 +27,23 @@ internal object ConfigurationValidators { | |
}.toString() | ||
throw GradleException(message) | ||
} | ||
return | ||
} | ||
val configurationNames = monitoredConfigurations.map { it.configurationName } | ||
require(configurationNames.isNotEmpty() && configurationNames[0].isNotBlank()) { | ||
StringBuilder().apply { | ||
appendLine("Error: No configurations provided to Dependency Guard Plugin.") | ||
appendLine("Here are some valid configurations you could use.") | ||
appendLine("") | ||
val availableConfigNames = availableConfigurations | ||
.filter { isClasspathConfig(it) } | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were using the |
||
val configurationNames = monitoredConfigurations.map { it.configurationName } | ||
require(configurationNames.isNotEmpty() && configurationNames[0].isNotBlank()) { | ||
StringBuilder().apply { | ||
appendLine("Error: No configurations provided to Dependency Guard Plugin.") | ||
appendLine("Here are some valid configurations you could use.") | ||
appendLine("") | ||
val availableConfigNames = availableConfigurations | ||
.filter { isClasspathConfig(it) } | ||
|
||
appendLine("dependencyGuard {") | ||
availableConfigNames.forEach { | ||
appendLine(""" configuration("$it")""") | ||
} | ||
appendLine("}") | ||
}.toString() | ||
appendLine("dependencyGuard {") | ||
availableConfigNames.forEach { | ||
appendLine(""" configuration("$it")""") | ||
} | ||
appendLine("}") | ||
}.toString() | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import com.dropbox.gradle.plugins.dependencyguard.DependencyGuardPlugin | |
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.ConfigurationContainer | ||
import org.gradle.api.artifacts.result.ResolvedComponentResult | ||
import org.gradle.api.provider.Provider | ||
|
||
internal fun Project.isRootProject(): Boolean = this == rootProject | ||
|
||
|
@@ -19,8 +20,8 @@ internal val Project.projectConfigurations: ConfigurationContainer | |
configurations | ||
} | ||
|
||
internal fun ConfigurationContainer.getResolvedComponentResult(name: String): ResolvedComponentResult = this | ||
internal fun ConfigurationContainer.getResolvedComponentResult(name: String): Provider<ResolvedComponentResult> = this | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using recommended pattern in Config Cache Documentation: https://docs.gradle.org/current/userguide/configuration_cache.html |
||
.getByName(name) | ||
.incoming | ||
.resolutionResult | ||
.root | ||
.rootComponent |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import org.gradle.api.artifacts.result.ResolvedComponentResult | |
import org.gradle.api.file.DirectoryProperty | ||
import org.gradle.api.provider.MapProperty | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
|
@@ -57,7 +58,7 @@ internal abstract class DependencyGuardListTask : DefaultTask() { | |
abstract val projectPath: Property<String> | ||
|
||
@get:Input | ||
abstract val monitoredConfigurationsMap: MapProperty<DependencyGuardConfiguration, ResolvedComponentResult> | ||
abstract val monitoredConfigurationsMap: MapProperty<DependencyGuardConfiguration, Provider<ResolvedComponentResult>> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using recommended pattern in Config Cache Documentation: https://docs.gradle.org/current/userguide/configuration_cache.html |
||
|
||
@get:Input | ||
abstract val buildDirectory: DirectoryProperty | ||
|
@@ -70,7 +71,7 @@ internal abstract class DependencyGuardListTask : DefaultTask() { | |
internal fun execute() { | ||
val dependencyGuardConfigurations = monitoredConfigurationsMap.get() | ||
|
||
val reports = dependencyGuardConfigurations.map { generateReportForConfiguration(it.key, it.value) } | ||
val reports = dependencyGuardConfigurations.map { generateReportForConfiguration(it.key, it.value.get()) } | ||
|
||
// Throw Error if any Disallowed Dependencies are Found | ||
val reportsWithDisallowedDependencies = reports.filter { it.disallowed.isNotEmpty() } | ||
|
@@ -184,7 +185,7 @@ internal abstract class DependencyGuardListTask : DefaultTask() { | |
private fun resolveMonitoredConfigurationsMap( | ||
project: Project, | ||
monitoredConfigurations: Collection<DependencyGuardConfiguration>, | ||
): Map<DependencyGuardConfiguration, ResolvedComponentResult> { | ||
): Map<DependencyGuardConfiguration, Provider<ResolvedComponentResult>> { | ||
val configurationContainer = project.projectConfigurations | ||
|
||
return monitoredConfigurations.associateWith { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test fails for 7.3 because
resolutionRoot
is not available in this version.