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

io.freefair.gradle.plugins.maven.OptionalPlugin Maven / Gradle / Ivy

There is a newer version: 8.11
Show newest version
package io.freefair.gradle.plugins.maven;

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.plugins.JavaPlugin;

public class OptionalPlugin implements Plugin {
    @Override
    public void apply(Project project) {
        project.getPlugins().withType(JavaPlugin.class, javaPlugin -> {
            Configuration optional = project.getConfigurations().create("optional");

            project.getConfigurations().getByName(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME)
                    .extendsFrom(optional);

            project.getConfigurations().getByName(JavaPlugin.TEST_COMPILE_ONLY_CONFIGURATION_NAME)
                    .extendsFrom(optional);
            project.getConfigurations().getByName(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME)
                    .extendsFrom(optional);
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy