dev.gradleplugins.internal.DeferredRepositoryFactory 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;
import dev.gradleplugins.GroovyGradlePluginDevelopmentExtension;
import dev.gradleplugins.JavaGradlePluginDevelopmentExtension;
import lombok.val;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.artifacts.dsl.RepositoryHandler;
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
import org.gradle.api.artifacts.repositories.MavenRepositoryContentDescriptor;
import org.gradle.api.plugins.ExtensionAware;
import org.gradle.plugin.devel.GradlePluginDevelopmentExtension;
import javax.inject.Inject;
import java.util.Optional;
import java.util.function.Consumer;
/**
* Create deferred repositories on the project.
*
* We defer the repository creation until after the project is evaluated because we give a chance to the users to add their own repository first.
* We also try to limit the resolution content as much as possible to avoid users from relying on the internal implementation of the plugins.
*/
public abstract class DeferredRepositoryFactory {
private final Project project;
@Inject
public DeferredRepositoryFactory(Project project) {
this.project = project;
}
public void groovy() {
project.afterEvaluate(DeferredRepositoryFactory::createGroovyRepository);
}
public void spock() {
project.afterEvaluate(DeferredRepositoryFactory::createSpockRepository);
}
private static void mutateRepositories(Project project, Action super RepositoryHandler> action) {
// NOTE: We work around the existence (or not) of the extension because Nokee repository is naughty and use GroovySpockFrameworkTestSuite via SpockFrameworkTestSuiteBasePlugin
val extension = ((ExtensionAware) project.getExtensions().findByType(GradlePluginDevelopmentExtension.class));
if (extension == null) {
action.execute(project.getRepositories());
} else {
val defaultRepositoriesDisabled = ((GradlePluginDevelopmentExtensionInternal) Optional.
© 2015 - 2024 Weber Informatics LLC | Privacy Policy