dev.gradleplugins.internal.plugins.AddGradleApiDependencyToCompileOnlyApiConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugin-development Show documentation
Show all versions of gradle-plugin-development Show documentation
Gradle plugin development plugins.
package dev.gradleplugins.internal.plugins;
import dev.gradleplugins.internal.GradlePluginDevelopmentDependencyExtensionInternal;
import lombok.val;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.plugins.AppliedPlugin;
import org.gradle.util.GradleVersion;
import static dev.gradleplugins.GradlePluginDevelopmentCompatibilityExtension.compatibility;
import static dev.gradleplugins.internal.util.GradlePluginDevelopmentUtils.gradlePlugin;
public final class AddGradleApiDependencyToCompileOnlyApiConfiguration implements Action {
private final Project project;
public AddGradleApiDependencyToCompileOnlyApiConfiguration(Project project) {
this.project = project;
}
@Override
public void execute(AppliedPlugin ignored) {
val dependencies = GradlePluginDevelopmentDependencyExtensionInternal.of(project.getDependencies());
dependencies.add(getCompileOnlyApiConfigurationName(), compatibility(gradlePlugin(project)).getGradleApiVersion().map(dependencies::gradleApi));
}
private static String getCompileOnlyApiConfigurationName() {
if (GradleVersion.current().compareTo(GradleVersion.version("6.7")) >= 0) {
return "compileOnlyApi";
}
return "compileOnly";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy