OptionalDependenciesPlugin.java (spring-boot-2.7.3) | : | OptionalDependenciesPlugin.java (spring-boot-2.7.4) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright 2012-2021 the original author or authors. | * Copyright 2012-2022 the original author or authors. | |||
* | * | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | * You may obtain a copy of the License at | |||
* | * | |||
* https://www.apache.org/licenses/LICENSE-2.0 | * https://www.apache.org/licenses/LICENSE-2.0 | |||
* | * | |||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | |||
* limitations under the License. | * limitations under the License. | |||
*/ | */ | |||
package org.springframework.boot.build.optional; | package org.springframework.boot.build.optional; | |||
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.Configuration; | |||
import org.gradle.api.plugins.JavaPlugin; | import org.gradle.api.plugins.JavaPlugin; | |||
import org.gradle.api.plugins.JavaPluginConvention; | import org.gradle.api.plugins.JavaPluginExtension; | |||
import org.gradle.api.tasks.SourceSetContainer; | import org.gradle.api.tasks.SourceSetContainer; | |||
/** | /** | |||
* A {@code Plugin} that adds support for Maven-style optional dependencies. Cre ates a new | * A {@code Plugin} that adds support for Maven-style optional dependencies. Cre ates a new | |||
* {@code optional} configuration. The {@code optional} configuration is part of the | * {@code optional} configuration. The {@code optional} configuration is part of the | |||
* project's compile and runtime classpaths but does not affect the classpath of dependent | * project's compile and runtime classpaths but does not affect the classpath of dependent | |||
* projects. | * projects. | |||
* | * | |||
* @author Andy Wilkinson | * @author Andy Wilkinson | |||
*/ | */ | |||
skipping to change at line 47 | skipping to change at line 47 | |||
* Name of the {@code optional} configuration. | * Name of the {@code optional} configuration. | |||
*/ | */ | |||
public static final String OPTIONAL_CONFIGURATION_NAME = "optional"; | public static final String OPTIONAL_CONFIGURATION_NAME = "optional"; | |||
@Override | @Override | |||
public void apply(Project project) { | public void apply(Project project) { | |||
Configuration optional = project.getConfigurations().create("opti onal"); | Configuration optional = project.getConfigurations().create("opti onal"); | |||
optional.setCanBeConsumed(false); | optional.setCanBeConsumed(false); | |||
optional.setCanBeResolved(false); | optional.setCanBeResolved(false); | |||
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> { | project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> { | |||
SourceSetContainer sourceSets = project.getConvention().g etPlugin(JavaPluginConvention.class) | SourceSetContainer sourceSets = project.getExtensions().g etByType(JavaPluginExtension.class) | |||
.getSourceSets(); | .getSourceSets(); | |||
sourceSets.all((sourceSet) -> { | sourceSets.all((sourceSet) -> { | |||
project.getConfigurations().getByName(sourceSet.g etCompileClasspathConfigurationName()) | project.getConfigurations().getByName(sourceSet.g etCompileClasspathConfigurationName()) | |||
.extendsFrom(optional); | .extendsFrom(optional); | |||
project.getConfigurations().getByName(sourceSet.g etRuntimeClasspathConfigurationName()) | project.getConfigurations().getByName(sourceSet.g etRuntimeClasspathConfigurationName()) | |||
.extendsFrom(optional); | .extendsFrom(optional); | |||
}); | }); | |||
}); | }); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |