Search in sources :

Example 1 with RelativeFilePathResolver

use of org.gradle.internal.file.RelativeFilePathResolver in project gradle by gradle.

the class BuildInitPlugin method apply.

@Override
public void apply(Project project) {
    if (project.getParent() == null) {
        project.getTasks().register("init", InitBuild.class, initBuild -> {
            initBuild.setGroup("Build Setup");
            initBuild.setDescription("Initializes a new Gradle build.");
            RelativeFilePathResolver resolver = ((ProjectInternal) project).getFileResolver();
            File buildFile = project.getBuildFile();
            FileDetails buildFileDetails = FileDetails.of(buildFile, resolver);
            File settingsFile = ((ProjectInternal) project).getGradle().getSettings().getSettingsScript().getResource().getLocation().getFile();
            FileDetails settingsFileDetails = FileDetails.of(settingsFile, resolver);
            initBuild.onlyIf(new InitBuildOnlyIfSpec(buildFileDetails, settingsFileDetails, initBuild.getLogger()));
            initBuild.dependsOn(new InitBuildDependsOnCallable(buildFileDetails, settingsFileDetails));
            ProjectInternal.DetachedResolver detachedResolver = ((ProjectInternal) project).newDetachedResolver();
            initBuild.getProjectLayoutRegistry().getBuildConverter().configureClasspath(detachedResolver, project.getObjects());
            initBuild.getInsecureProtocol().convention(InsecureProtocolOption.WARN);
        });
    }
}
Also used : RelativeFilePathResolver(org.gradle.internal.file.RelativeFilePathResolver) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) File(java.io.File)

Aggregations

File (java.io.File)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 RelativeFilePathResolver (org.gradle.internal.file.RelativeFilePathResolver)1