Java Code Examples for org.gradle.StartParameter#getCurrentDir()

The following examples show how to use org.gradle.StartParameter#getCurrentDir() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GradleParameters.java    From gradle-metrics-plugin with Apache License 2.0 6 votes vote down vote up
public static GradleParameters fromGradle(org.gradle.api.invocation.Gradle gradle) {
    StartParameter start = gradle.getStartParameter();
    List<KeyValue> projectProperties = KeyValue.mapToKeyValueList(start.getProjectProperties());
    return new GradleParameters(start.getTaskRequests(),
            start.getExcludedTaskNames(),
            start.isBuildProjectDependencies(),
            start.getCurrentDir(),
            start.getProjectDir(),
            projectProperties,
            start.getGradleUserHomeDir(),
            start.getSettingsFile(),
            start.getBuildFile(),
            start.getInitScripts(),
            start.isDryRun(),
            start.isRerunTasks(),
            start.isProfile(),
            start.isContinueOnFailure(),
            start.isOffline(),
            start.getProjectCacheDir(),
            start.isRefreshDependencies(),
            start.getMaxWorkerCount(),
            start.isConfigureOnDemand()
    );
}
 
Example 2
Source File: ProjectSpecs.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
static ProjectSpec forStartParameter(StartParameter startParameter, SettingsInternal settings) {
    File explicitProjectDir = startParameter.getProjectDir();
    File explicitBuildFile = startParameter.getBuildFile();
    if (explicitBuildFile != null) {
        return new BuildFileProjectSpec(explicitBuildFile);
    }
    if (explicitProjectDir != null) {
        return new ProjectDirectoryProjectSpec(explicitProjectDir);
    }
    return new DefaultProjectSpec(startParameter.getCurrentDir(), settings);
}
 
Example 3
Source File: ProjectSpecs.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
static ProjectSpec forStartParameter(StartParameter startParameter) {
    String explicitProjectPath = startParameter.getProjectPath();
    File explicitProjectDir = startParameter.getProjectDir();
    File explicitBuildFile = startParameter.getBuildFile();
    ProjectSpec spec = explicitProjectPath != null
            ? new ProjectPathProjectSpec(explicitProjectPath)
            : explicitBuildFile != null
            ? new BuildFileProjectSpec(explicitBuildFile)
            : explicitProjectDir == null ? new DefaultProjectSpec(startParameter.getCurrentDir()) : new ProjectDirectoryProjectSpec(explicitProjectDir);
    return spec;
}
 
Example 4
Source File: ProjectSpecs.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
static ProjectSpec forStartParameter(StartParameter startParameter, SettingsInternal settings) {
    File explicitProjectDir = startParameter.getProjectDir();
    File explicitBuildFile = startParameter.getBuildFile();
    if (explicitBuildFile != null) {
        return new BuildFileProjectSpec(explicitBuildFile);
    }
    if (explicitProjectDir != null) {
        return new ProjectDirectoryProjectSpec(explicitProjectDir);
    }
    return new DefaultProjectSpec(startParameter.getCurrentDir(), settings);
}
 
Example 5
Source File: ProjectSpecs.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
static ProjectSpec forStartParameter(StartParameter startParameter) {
    String explicitProjectPath = startParameter.getProjectPath();
    File explicitProjectDir = startParameter.getProjectDir();
    File explicitBuildFile = startParameter.getBuildFile();
    ProjectSpec spec = explicitProjectPath != null
            ? new ProjectPathProjectSpec(explicitProjectPath)
            : explicitBuildFile != null
            ? new BuildFileProjectSpec(explicitBuildFile)
            : explicitProjectDir == null ? new DefaultProjectSpec(startParameter.getCurrentDir()) : new ProjectDirectoryProjectSpec(explicitProjectDir);
    return spec;
}
 
Example 6
Source File: DefaultCommandLineConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public StartParameter convert(final ParsedCommandLine options, final StartParameter startParameter) throws CommandLineArgumentException {
    loggingConfigurationCommandLineConverter.convert(options, startParameter);
    Transformer<File, String> resolver = new BasicFileResolver(startParameter.getCurrentDir());

    Map<String, String> systemProperties = systemPropertiesCommandLineConverter.convert(options, new HashMap<String, String>());
    convertCommandLineSystemProperties(systemProperties, startParameter, resolver);

    Map<String, String> projectProperties = projectPropertiesCommandLineConverter.convert(options, new HashMap<String, String>());
    startParameter.getProjectProperties().putAll(projectProperties);

    BuildLayoutParameters layout = new BuildLayoutParameters()
            .setGradleUserHomeDir(startParameter.getGradleUserHomeDir())
            .setProjectDir(startParameter.getProjectDir())
            .setCurrentDir(startParameter.getCurrentDir());
    layoutCommandLineConverter.convert(options, layout);
    startParameter.setGradleUserHomeDir(layout.getGradleUserHomeDir());
    if (layout.getProjectDir() != null) {
        startParameter.setProjectDir(layout.getProjectDir());
    }
    startParameter.setSearchUpwards(layout.getSearchUpwards());

    if (options.hasOption(BUILD_FILE)) {
        startParameter.setBuildFile(resolver.transform(options.option(BUILD_FILE).getValue()));
    }
    if (options.hasOption(SETTINGS_FILE)) {
        startParameter.setSettingsFile(resolver.transform(options.option(SETTINGS_FILE).getValue()));
    }

    for (String script : options.option(INIT_SCRIPT).getValues()) {
        startParameter.addInitScript(resolver.transform(script));
    }

    if (options.hasOption(PROJECT_CACHE_DIR)) {
        startParameter.setProjectCacheDir(resolver.transform(options.option(PROJECT_CACHE_DIR).getValue()));
    }

    if (options.hasOption(NO_PROJECT_DEPENDENCY_REBUILD)) {
        startParameter.setBuildProjectDependencies(false);
    }

    if (!options.getExtraArguments().isEmpty()) {
        startParameter.setTaskNames(options.getExtraArguments());
    }

    if (options.hasOption(DRY_RUN)) {
        startParameter.setDryRun(true);
    }

    if (options.hasOption(RERUN_TASKS)) {
        startParameter.setRerunTasks(true);
    }

    if (options.hasOption(RECOMPILE_SCRIPTS)) {
        startParameter.setRecompileScripts(true);
    }

    if (options.hasOption(EXCLUDE_TASK)) {
        startParameter.setExcludedTaskNames(options.option(EXCLUDE_TASK).getValues());
    }

    if (options.hasOption(PROFILE)) {
        startParameter.setProfile(true);
    }

    if (options.hasOption(CONTINUE)) {
        startParameter.setContinueOnFailure(true);
    }

    if (options.hasOption(OFFLINE)) {
        startParameter.setOffline(true);
    }

    if (options.hasOption(REFRESH_DEPENDENCIES)) {
        startParameter.setRefreshDependencies(true);
    }

    if (options.hasOption(PARALLEL)) {
        startParameter.setParallelThreadCount(-1);
    }

    if (options.hasOption(PARALLEL_THREADS)) {
        try {
            int parallelThreads = Integer.parseInt(options.option(PARALLEL_THREADS).getValue());
            startParameter.setParallelThreadCount(parallelThreads);
        } catch (NumberFormatException e) {
            throw new CommandLineArgumentException(String.format("Not a numeric argument for %s", PARALLEL_THREADS));
        }
    }

    if (options.hasOption(CONFIGURE_ON_DEMAND)) {
        startParameter.setConfigureOnDemand(true);
    }

    return startParameter;
}
 
Example 7
Source File: BuildLayoutConfiguration.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public BuildLayoutConfiguration(StartParameter startParameter) {
    currentDir = startParameter.getCurrentDir();
    searchUpwards = startParameter.isSearchUpwards();
    settingsFile = startParameter.getSettingsFile();
    useEmptySettings = startParameter.isUseEmptySettings();
}
 
Example 8
Source File: BuildLayoutConfiguration.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public BuildLayoutConfiguration(StartParameter startParameter) {
    currentDir = startParameter.getCurrentDir();
    searchUpwards = startParameter.isSearchUpwards();
    settingsFile = startParameter.getSettingsFile();
    useEmptySettings = startParameter.isUseEmptySettings();
}
 
Example 9
Source File: DefaultCommandLineConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public StartParameter convert(final ParsedCommandLine options, final StartParameter startParameter) throws CommandLineArgumentException {
    loggingConfigurationCommandLineConverter.convert(options, startParameter);
    Transformer<File, String> resolver = new BasicFileResolver(startParameter.getCurrentDir());

    Map<String, String> systemProperties = systemPropertiesCommandLineConverter.convert(options, new HashMap<String, String>());
    convertCommandLineSystemProperties(systemProperties, startParameter, resolver);

    Map<String, String> projectProperties = projectPropertiesCommandLineConverter.convert(options, new HashMap<String, String>());
    startParameter.getProjectProperties().putAll(projectProperties);

    BuildLayoutParameters layout = new BuildLayoutParameters()
            .setGradleUserHomeDir(startParameter.getGradleUserHomeDir())
            .setProjectDir(startParameter.getProjectDir())
            .setCurrentDir(startParameter.getCurrentDir());
    layoutCommandLineConverter.convert(options, layout);
    startParameter.setGradleUserHomeDir(layout.getGradleUserHomeDir());
    if (layout.getProjectDir() != null) {
        startParameter.setProjectDir(layout.getProjectDir());
    }
    startParameter.setSearchUpwards(layout.getSearchUpwards());

    if (options.hasOption(BUILD_FILE)) {
        startParameter.setBuildFile(resolver.transform(options.option(BUILD_FILE).getValue()));
    }
    if (options.hasOption(SETTINGS_FILE)) {
        startParameter.setSettingsFile(resolver.transform(options.option(SETTINGS_FILE).getValue()));
    }

    for (String script : options.option(INIT_SCRIPT).getValues()) {
        startParameter.addInitScript(resolver.transform(script));
    }

    if (options.hasOption(PROJECT_CACHE_DIR)) {
        startParameter.setProjectCacheDir(resolver.transform(options.option(PROJECT_CACHE_DIR).getValue()));
    }

    if (options.hasOption(NO_PROJECT_DEPENDENCY_REBUILD)) {
        startParameter.setBuildProjectDependencies(false);
    }

    if (!options.getExtraArguments().isEmpty()) {
        startParameter.setTaskNames(options.getExtraArguments());
    }

    if (options.hasOption(DRY_RUN)) {
        startParameter.setDryRun(true);
    }

    if (options.hasOption(RERUN_TASKS)) {
        startParameter.setRerunTasks(true);
    }

    if (options.hasOption(RECOMPILE_SCRIPTS)) {
        startParameter.setRecompileScripts(true);
    }

    if (options.hasOption(EXCLUDE_TASK)) {
        startParameter.setExcludedTaskNames(options.option(EXCLUDE_TASK).getValues());
    }

    if (options.hasOption(PROFILE)) {
        startParameter.setProfile(true);
    }

    if (options.hasOption(CONTINUE)) {
        startParameter.setContinueOnFailure(true);
    }

    if (options.hasOption(OFFLINE)) {
        startParameter.setOffline(true);
    }

    if (options.hasOption(REFRESH_DEPENDENCIES)) {
        startParameter.setRefreshDependencies(true);
    }

    if (options.hasOption(PARALLEL)) {
        startParameter.setParallelThreadCount(-1);
    }

    if (options.hasOption(PARALLEL_THREADS)) {
        try {
            int parallelThreads = Integer.parseInt(options.option(PARALLEL_THREADS).getValue());
            startParameter.setParallelThreadCount(parallelThreads);
        } catch (NumberFormatException e) {
            throw new CommandLineArgumentException(String.format("Not a numeric argument for %s", PARALLEL_THREADS));
        }
    }

    if (options.hasOption(CONFIGURE_ON_DEMAND)) {
        startParameter.setConfigureOnDemand(true);
    }

    return startParameter;
}
 
Example 10
Source File: BuildLayoutConfiguration.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public BuildLayoutConfiguration(StartParameter startParameter) {
    currentDir = startParameter.getCurrentDir();
    searchUpwards = startParameter.isSearchUpwards();
    settingsFile = startParameter.getSettingsFile();
    useEmptySettings = startParameter.isUseEmptySettings();
}
 
Example 11
Source File: BuildLayoutConfiguration.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public BuildLayoutConfiguration(StartParameter startParameter) {
    currentDir = startParameter.getCurrentDir();
    searchUpwards = startParameter.isSearchUpwards();
    settingsFile = startParameter.getSettingsFile();
    useEmptySettings = startParameter.isUseEmptySettings();
}