org.gradle.initialization.BuildLayoutParametersBuildOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
/*
* Copyright 2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.initialization;
import org.gradle.api.Transformer;
import org.gradle.api.internal.file.BasicFileResolver;
import org.gradle.internal.buildoption.BuildOption;
import org.gradle.internal.buildoption.BuildOptionSet;
import org.gradle.internal.buildoption.CommandLineOptionConfiguration;
import org.gradle.internal.buildoption.Origin;
import org.gradle.internal.buildoption.StringBuildOption;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class BuildLayoutParametersBuildOptions extends BuildOptionSet {
private static List> options;
static {
List> options = new ArrayList>();
options.add(new GradleUserHomeOption());
options.add(new ProjectDirOption());
options.add(new SettingsFileOption());
options.add(new BuildFileOption());
BuildLayoutParametersBuildOptions.options = Collections.unmodifiableList(options);
}
@Override
public List> getAllOptions() {
return options;
}
public static class GradleUserHomeOption extends StringBuildOption {
public GradleUserHomeOption() {
super(BuildLayoutParameters.GRADLE_USER_HOME_PROPERTY_KEY, CommandLineOptionConfiguration.create("gradle-user-home", "g", "Specifies the Gradle user home directory. Defaults to ~/.gradle"));
}
@Override
public void applyTo(String value, BuildLayoutParameters settings, Origin origin) {
Transformer resolver = new BasicFileResolver(settings.getCurrentDir());
settings.setGradleUserHomeDir(resolver.transform(value));
}
}
public static class ProjectDirOption extends StringBuildOption {
public ProjectDirOption() {
super(null, CommandLineOptionConfiguration.create("project-dir", "p", "Specifies the start directory for Gradle. Defaults to current directory."));
}
@Override
public void applyTo(String value, BuildLayoutParameters settings, Origin origin) {
Transformer resolver = new BasicFileResolver(settings.getCurrentDir());
File projectDir = resolver.transform(value);
settings.setCurrentDir(projectDir);
settings.setProjectDir(projectDir);
}
}
@Deprecated
public static class SettingsFileOption extends StringBuildOption {
public SettingsFileOption() {
super(null, CommandLineOptionConfiguration.create("settings-file", "c", "Specify the settings file. [deprecated]"));
}
@Override
public void applyTo(String value, BuildLayoutParameters settings, Origin origin) {
Transformer resolver = new BasicFileResolver(settings.getCurrentDir());
settings.setSettingsFile(resolver.transform(value));
}
}
@Deprecated
public static class BuildFileOption extends StringBuildOption {
public BuildFileOption() {
super(null, CommandLineOptionConfiguration.create("build-file", "b", "Specify the build file. [deprecated]"));
}
@Override
public void applyTo(String value, BuildLayoutParameters settings, Origin origin) {
Transformer resolver = new BasicFileResolver(settings.getCurrentDir());
settings.setBuildFile(resolver.transform(value));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy