diff --git a/acl/spring-security-acl.gradle b/acl/spring-security-acl.gradle index 6226d2b129..8de65558b8 100644 --- a/acl/spring-security-acl.gradle +++ b/acl/spring-security-acl.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api 'org.springframework:spring-aop' api 'org.springframework:spring-context' diff --git a/aspects/spring-security-aspects.gradle b/aspects/spring-security-aspects.gradle index 5ae906b016..3a58595619 100644 --- a/aspects/spring-security-aspects.gradle +++ b/aspects/spring-security-aspects.gradle @@ -2,7 +2,7 @@ apply plugin: 'io.spring.convention.spring-module' apply plugin: 'io.freefair.aspectj' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api "org.aspectj:aspectjrt" api project(':spring-security-core') api 'org.springframework:spring-beans' diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy index e2eb4f725b..546f507fde 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy @@ -37,6 +37,7 @@ public abstract class AbstractSpringJavaPlugin implements Plugin { public final void apply(Project project) { PluginManager pluginManager = project.getPluginManager(); pluginManager.apply(JavaPlugin.class); + pluginManager.apply(ManagementConfigurationPlugin.class) if (project.file("src/main/groovy").exists() || project.file("src/test/groovy").exists() || project.file("src/integration-test/groovy").exists()) { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java b/buildSrc/src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java new file mode 100644 index 0000000000..8db6fd970b --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java @@ -0,0 +1,74 @@ +/* + * Copyright 2002-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.spring.gradle.convention; + +import org.gradle.api.Plugin; +import org.gradle.api.Project; +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; + +import org.springframework.gradle.propdeps.PropDepsPlugin; + +/** + * 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 + */ +public class ManagementConfigurationPlugin implements Plugin { + + public static final String MANAGEMENT_CONFIGURATION_NAME = "management"; + + @Override + public void apply(Project project) { + ConfigurationContainer configurations = project.getConfigurations(); + configurations.create(MANAGEMENT_CONFIGURATION_NAME, (management) -> { + management.setVisible(false); + management.setCanBeConsumed(false); + management.setCanBeResolved(false); + + PluginContainer plugins = project.getPlugins(); + plugins.withType(JavaPlugin.class, (javaPlugin) -> { + configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_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_RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management); + }); + plugins.withType(JavaTestFixturesPlugin.class, (javaTestFixturesPlugin) -> { + configurations.getByName("testFixturesCompileClasspath").extendsFrom(management); + configurations.getByName("testFixturesRuntimeClasspath").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); + })); + }); + } +} \ No newline at end of file diff --git a/cas/spring-security-cas.gradle b/cas/spring-security-cas.gradle index ee7b3b46b2..8b3d4630f7 100644 --- a/cas/spring-security-cas.gradle +++ b/cas/spring-security-cas.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api project(':spring-security-web') api 'org.jasig.cas.client:cas-client-core' diff --git a/config/spring-security-config.gradle b/config/spring-security-config.gradle index 6208e2ea28..a54edbd15c 100644 --- a/config/spring-security-config.gradle +++ b/config/spring-security-config.gradle @@ -9,7 +9,7 @@ repositories { } dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) // NB: Don't add other compile time dependencies to the config module as this breaks tooling api project(':spring-security-core') api 'org.springframework:spring-aop' diff --git a/core/spring-security-core.gradle b/core/spring-security-core.gradle index acc7641b0d..213f24f92c 100644 --- a/core/spring-security-core.gradle +++ b/core/spring-security-core.gradle @@ -3,7 +3,7 @@ import java.util.concurrent.Callable apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-crypto') api 'org.springframework:spring-aop' api 'org.springframework:spring-beans' diff --git a/crypto/spring-security-crypto.gradle b/crypto/spring-security-crypto.gradle index 096ac0ed23..b45a20b0d8 100644 --- a/crypto/spring-security-crypto.gradle +++ b/crypto/spring-security-crypto.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) optional 'org.springframework:spring-jcl' optional 'org.bouncycastle:bcpkix-jdk15on' diff --git a/data/spring-security-data.gradle b/data/spring-security-data.gradle index 64c0212a80..e0c9f14dab 100644 --- a/data/spring-security-data.gradle +++ b/data/spring-security-data.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api 'javax.xml.bind:jaxb-api' api 'org.springframework.data:spring-data-commons' diff --git a/ldap/spring-security-ldap.gradle b/ldap/spring-security-ldap.gradle index 35d81b08be..e16802ea45 100644 --- a/ldap/spring-security-ldap.gradle +++ b/ldap/spring-security-ldap.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api 'org.springframework:spring-beans' api 'org.springframework:spring-context' diff --git a/messaging/spring-security-messaging.gradle b/messaging/spring-security-messaging.gradle index 895858e359..6556c0e6b0 100644 --- a/messaging/spring-security-messaging.gradle +++ b/messaging/spring-security-messaging.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api 'org.springframework:spring-beans' api 'org.springframework:spring-context' diff --git a/oauth2/oauth2-client/spring-security-oauth2-client.gradle b/oauth2/oauth2-client/spring-security-oauth2-client.gradle index 675f9b871c..fd71a9a30f 100644 --- a/oauth2/oauth2-client/spring-security-oauth2-client.gradle +++ b/oauth2/oauth2-client/spring-security-oauth2-client.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api project(':spring-security-oauth2-core') api project(':spring-security-web') diff --git a/oauth2/oauth2-core/spring-security-oauth2-core.gradle b/oauth2/oauth2-core/spring-security-oauth2-core.gradle index 76a8ec9da3..9fb4449b52 100644 --- a/oauth2/oauth2-core/spring-security-oauth2-core.gradle +++ b/oauth2/oauth2-core/spring-security-oauth2-core.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api 'org.springframework:spring-core' api 'org.springframework:spring-web' diff --git a/oauth2/oauth2-jose/spring-security-oauth2-jose.gradle b/oauth2/oauth2-jose/spring-security-oauth2-jose.gradle index 70fdc8c36d..8290b8579e 100644 --- a/oauth2/oauth2-jose/spring-security-oauth2-jose.gradle +++ b/oauth2/oauth2-jose/spring-security-oauth2-jose.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api project(':spring-security-oauth2-core') api 'org.springframework:spring-core' diff --git a/oauth2/oauth2-resource-server/spring-security-oauth2-resource-server.gradle b/oauth2/oauth2-resource-server/spring-security-oauth2-resource-server.gradle index 4031334bda..438bbc8b5d 100644 --- a/oauth2/oauth2-resource-server/spring-security-oauth2-resource-server.gradle +++ b/oauth2/oauth2-resource-server/spring-security-oauth2-resource-server.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api project(':spring-security-oauth2-core') api project(':spring-security-web') diff --git a/openid/spring-security-openid.gradle b/openid/spring-security-openid.gradle index 7ce077c0fa..0725b0d0a8 100644 --- a/openid/spring-security-openid.gradle +++ b/openid/spring-security-openid.gradle @@ -5,7 +5,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api project(':spring-security-web') api('com.google.inject:guice') { diff --git a/remoting/spring-security-remoting.gradle b/remoting/spring-security-remoting.gradle index ca89a418d1..adbc8baeb3 100644 --- a/remoting/spring-security-remoting.gradle +++ b/remoting/spring-security-remoting.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api 'org.springframework:spring-aop' api 'org.springframework:spring-beans' diff --git a/rsocket/spring-security-rsocket.gradle b/rsocket/spring-security-rsocket.gradle index d06d652a74..04950bb290 100644 --- a/rsocket/spring-security-rsocket.gradle +++ b/rsocket/spring-security-rsocket.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api 'io.rsocket:rsocket-core' optional project(':spring-security-oauth2-resource-server') diff --git a/saml2/saml2-service-provider/spring-security-saml2-service-provider.gradle b/saml2/saml2-service-provider/spring-security-saml2-service-provider.gradle index 24d87225ce..5bcc457a61 100644 --- a/saml2/saml2-service-provider/spring-security-saml2-service-provider.gradle +++ b/saml2/saml2-service-provider/spring-security-saml2-service-provider.gradle @@ -41,7 +41,7 @@ compileOpensaml4MainJava { } dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-web') api "org.opensaml:opensaml-core" api "org.opensaml:opensaml-saml-api" diff --git a/taglibs/spring-security-taglibs.gradle b/taglibs/spring-security-taglibs.gradle index 7ab8469f0a..a45ad37f12 100644 --- a/taglibs/spring-security-taglibs.gradle +++ b/taglibs/spring-security-taglibs.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-acl') api project(':spring-security-core') api project(':spring-security-web') diff --git a/test/spring-security-test.gradle b/test/spring-security-test.gradle index 599a9fe466..e5b977dda5 100644 --- a/test/spring-security-test.gradle +++ b/test/spring-security-test.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api project(':spring-security-web') api 'org.springframework:spring-core' diff --git a/web/spring-security-web.gradle b/web/spring-security-web.gradle index bedf99dda6..ad2279b46e 100644 --- a/web/spring-security-web.gradle +++ b/web/spring-security-web.gradle @@ -1,7 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { - api platform(project(":spring-security-dependencies")) + management platform(project(":spring-security-dependencies")) api project(':spring-security-core') api 'org.springframework:spring-core' api 'org.springframework:spring-aop'