name.remal.gradle_plugins.toolkit.build_logic.test-external-plugins.gradle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of build-logic Show documentation
Show all versions of build-logic Show documentation
Remal Gradle plugins: toolkit: build-logic
allprojects {
pluginManager.withPlugin('java') {
Configuration externalPluginsToTestConf = configurations.create('externalPluginsToTest') { Configuration conf ->
conf.extendsFrom = conf.extendsFrom.findAll { it.name != 'projectDependencyConstraints' }
conf.transitive = false
conf.allDependencies.configureEach { Dependency dep ->
if (dep instanceof ModuleDependency) dep.transitive = conf.transitive
String expectedName = "${dep.group}.gradle.plugin"
if (dep.name != expectedName) {
throw new GradleException("Gradle plugin dependency name should be '$expectedName', but '${dep.name}' is used")
}
}
}
tasks.withType(Test).configureEach { Test task ->
onlyIf {
externalPluginsToTestConf
.resolvedConfiguration
.firstLevelModuleDependencies
.forEach { ResolvedDependency dep ->
String pluginId = dep.moduleGroup
boolean isGradlePlugin = dep.moduleName == "${pluginId}.gradle.plugin"
if (!isGradlePlugin) return
String propertyName = "external-plugin-version-$pluginId"
task.systemProperty(propertyName, dep.moduleVersion)
}
return true
}
}
}
}