mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-04-03 13:58:59 +00:00
Update plugins to support api/implementation
Issue gh-9540
This commit is contained in:
parent
58a69bb7e2
commit
e4c03e9e5a
@ -54,10 +54,10 @@ public class IntegrationTestPlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
project.configurations {
|
project.configurations {
|
||||||
integrationTestCompile {
|
integrationTestCompile {
|
||||||
extendsFrom testCompile
|
extendsFrom testCompile, testImplementation
|
||||||
}
|
}
|
||||||
integrationTestRuntime {
|
integrationTestRuntime {
|
||||||
extendsFrom integrationTestCompile, testRuntime
|
extendsFrom integrationTestCompile, testRuntime, testRuntimeOnly
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +1,61 @@
|
|||||||
package io.spring.gradle.convention;
|
package io.spring.gradle.convention;
|
||||||
|
|
||||||
import org.gradle.api.Action;
|
|
||||||
|
import io.spring.gradle.propdeps.PropDepsPlugin;
|
||||||
import org.gradle.api.Plugin;
|
import org.gradle.api.Plugin;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
import org.gradle.api.artifacts.Configuration;
|
import org.gradle.api.artifacts.ConfigurationContainer;
|
||||||
|
import org.gradle.api.plugins.JavaPlugin;
|
||||||
|
import org.gradle.api.plugins.JavaTestFixturesPlugin;
|
||||||
|
import org.gradle.api.plugins.PluginContainer;
|
||||||
|
import org.gradle.api.publish.PublishingExtension;
|
||||||
|
import org.gradle.api.publish.maven.MavenPublication;
|
||||||
|
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/gradle/gradle/issues/7576#issuecomment-434637595
|
* Creates a Management configuration that is appropriate for adding a platform to that is not exposed externally. If
|
||||||
|
* the JavaPlugin is applied, the compileClasspath, runtimeClasspath, testCompileClasspath, and testRuntimeClasspath
|
||||||
|
* will extend from it.
|
||||||
* @author Rob Winch
|
* @author Rob Winch
|
||||||
*/
|
*/
|
||||||
public class ManagementConfigurationPlugin implements Plugin<Project> {
|
public class ManagementConfigurationPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
|
public static final String MANAGEMENT_CONFIGURATION_NAME = "management";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(Project project) {
|
public void apply(Project project) {
|
||||||
Configuration management = project.getConfigurations()
|
ConfigurationContainer configurations = project.getConfigurations();
|
||||||
.create("management", new Action<Configuration>() {
|
configurations.create(MANAGEMENT_CONFIGURATION_NAME, (management) -> {
|
||||||
@Override
|
management.setVisible(false);
|
||||||
public void execute(Configuration configuration) {
|
management.setCanBeConsumed(false);
|
||||||
configuration.setCanBeResolved(false);
|
management.setCanBeResolved(false);
|
||||||
configuration.setCanBeConsumed(false);
|
|
||||||
configuration.setDescription("Used for setting Gradle constraints that impact all configurations that can be resolved");
|
PluginContainer plugins = project.getPlugins();
|
||||||
}
|
plugins.withType(JavaPlugin.class, (javaPlugin) -> {
|
||||||
|
configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
|
||||||
|
configurations.getByName(JavaPlugin.COMPILE_CONFIGURATION_NAME).extendsFrom(management);
|
||||||
|
configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
|
||||||
|
configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
|
||||||
|
configurations.getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME).extendsFrom(management);
|
||||||
|
configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management);
|
||||||
});
|
});
|
||||||
project.getConfigurations().all(new Action<Configuration>() {
|
plugins.withType(JavaTestFixturesPlugin.class, (javaTestFixturesPlugin) -> {
|
||||||
@Override
|
configurations.getByName("testFixturesCompileClasspath").extendsFrom(management);
|
||||||
public void execute(Configuration configuration) {
|
configurations.getByName("testFixturesRuntimeClasspath").extendsFrom(management);
|
||||||
if (configuration.isCanBeResolved()) {
|
});
|
||||||
configuration.extendsFrom(management);
|
plugins.withType(MavenPublishPlugin.class, (mavenPublish) -> {
|
||||||
}
|
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class);
|
||||||
}
|
publishing.getPublications().withType(MavenPublication.class, (mavenPublication -> {
|
||||||
|
mavenPublication.versionMapping((versions) ->
|
||||||
|
versions.allVariants(versionMapping -> versionMapping.fromResolutionResult())
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
plugins.withType(PropDepsPlugin.class, (propDepsPlugin -> {
|
||||||
|
configurations.getByName("optional").extendsFrom(management);
|
||||||
|
configurations.getByName("provided").extendsFrom(management);
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class TestsConfigurationPlugin implements Plugin<Project> {
|
|||||||
|
|
||||||
private void applyJavaProject(Project project) {
|
private void applyJavaProject(Project project) {
|
||||||
project.configurations {
|
project.configurations {
|
||||||
tests.extendsFrom testRuntime
|
tests.extendsFrom testRuntime, testRuntimeClasspath
|
||||||
}
|
}
|
||||||
|
|
||||||
project.tasks.create('testJar', Jar) {
|
project.tasks.create('testJar', Jar) {
|
||||||
|
@ -59,6 +59,6 @@ configure(project.tasks.withType(Test)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Callable<String> springVersion() {
|
Callable<String> springVersion() {
|
||||||
return (Callable<String>) { project.configurations.compile.resolvedConfiguration.resolvedArtifacts
|
return (Callable<String>) { project.configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts
|
||||||
.find { it.name == 'spring-core' }.moduleVersion.id.version }
|
.find { it.name == 'spring-core' }.moduleVersion.id.version }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user