All Downloads are FREE. Search and download functionalities are using the official Maven repository.

name.remal.gradle_plugins.toolkit.build_logic.test-external-plugins.gradle Maven / Gradle / Ivy

There is a newer version: 0.64.11
Show newest version
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
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy