Search in sources :

Example 1 with ConfigurationVariantDetails

use of org.gradle.api.component.ConfigurationVariantDetails in project spring-boot by spring-projects.

the class MavenPublishingConventions method addMavenOptionalFeature.

/**
 * Add a feature that allows maven plugins to declare optional dependencies that
 * appear in the POM. This is required to make m2e in Eclipse happy.
 * @param project the project to add the feature to
 */
private void addMavenOptionalFeature(Project project) {
    JavaPluginExtension extension = project.getExtensions().getByType(JavaPluginExtension.class);
    extension.registerFeature("mavenOptional", (feature) -> feature.usingSourceSet(extension.getSourceSets().getByName("main")));
    AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) project.getComponents().findByName("java");
    javaComponent.addVariantsFromConfiguration(project.getConfigurations().findByName("mavenOptionalRuntimeElements"), ConfigurationVariantDetails::mapToOptional);
}
Also used : AdhocComponentWithVariants(org.gradle.api.component.AdhocComponentWithVariants) ConfigurationVariantDetails(org.gradle.api.component.ConfigurationVariantDetails) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension)

Aggregations

AdhocComponentWithVariants (org.gradle.api.component.AdhocComponentWithVariants)1 ConfigurationVariantDetails (org.gradle.api.component.ConfigurationVariantDetails)1 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)1