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

The following examples show how to use org.gradle.StartParameter#setTaskNames() . 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: DefaultTasksBuildExecutionAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void configure(BuildExecutionContext context) {
    StartParameter startParameter = context.getGradle().getStartParameter();

    if (!startParameter.getTaskNames().isEmpty()) {
        context.proceed();
        return;
    }

    // Gather the default tasks from this first group project
    ProjectInternal project = context.getGradle().getDefaultProject();
    List<String> defaultTasks = project.getDefaultTasks();
    if (defaultTasks.size() == 0) {
        defaultTasks = Arrays.asList(ImplicitTasksConfigurer.HELP_TASK);
        LOGGER.info("No tasks specified. Using default task {}", GUtil.toString(defaultTasks));
    } else {
        LOGGER.info("No tasks specified. Using project default tasks {}", GUtil.toString(defaultTasks));
    }

    startParameter.setTaskNames(defaultTasks);
    context.proceed();
}
 
Example 2
Source File: DefaultTasksBuildExecutionAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void configure(BuildExecutionContext context) {
    StartParameter startParameter = context.getGradle().getStartParameter();

    if (!startParameter.getTaskNames().isEmpty()) {
        context.proceed();
        return;
    }

    // Gather the default tasks from this first group project
    ProjectInternal project = context.getGradle().getDefaultProject();
    List<String> defaultTasks = project.getDefaultTasks();
    if (defaultTasks.size() == 0) {
        defaultTasks = Arrays.asList(ImplicitTasksConfigurer.HELP_TASK);
        LOGGER.info("No tasks specified. Using default task {}", GUtil.toString(defaultTasks));
    } else {
        LOGGER.info("No tasks specified. Using project default tasks {}", GUtil.toString(defaultTasks));
    }

    startParameter.setTaskNames(defaultTasks);
    context.proceed();
}
 
Example 3
Source File: DefaultTasksBuildExecutionAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void configure(BuildExecutionContext context) {
    StartParameter startParameter = context.getGradle().getStartParameter();

    for (TaskExecutionRequest request : startParameter.getTaskRequests()) {
        if (!request.getArgs().isEmpty()) {
            context.proceed();
            return;
        }
    }

    // Gather the default tasks from this first group project
    ProjectInternal project = context.getGradle().getDefaultProject();

    //so that we don't miss out default tasks
    projectConfigurer.configure(project);

    List<String> defaultTasks = project.getDefaultTasks();
    if (defaultTasks.size() == 0) {
        defaultTasks = Arrays.asList(ProjectInternal.HELP_TASK);
        LOGGER.info("No tasks specified. Using default task {}", GUtil.toString(defaultTasks));
    } else {
        LOGGER.info("No tasks specified. Using project default tasks {}", GUtil.toString(defaultTasks));
    }

    startParameter.setTaskNames(defaultTasks);
    context.proceed();
}
 
Example 4
Source File: DefaultTasksBuildExecutionAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void configure(BuildExecutionContext context) {
    StartParameter startParameter = context.getGradle().getStartParameter();

    for (TaskExecutionRequest request : startParameter.getTaskRequests()) {
        if (!request.getArgs().isEmpty()) {
            context.proceed();
            return;
        }
    }

    // Gather the default tasks from this first group project
    ProjectInternal project = context.getGradle().getDefaultProject();

    //so that we don't miss out default tasks
    projectConfigurer.configure(project);

    List<String> defaultTasks = project.getDefaultTasks();
    if (defaultTasks.size() == 0) {
        defaultTasks = Arrays.asList(ProjectInternal.HELP_TASK);
        LOGGER.info("No tasks specified. Using default task {}", GUtil.toString(defaultTasks));
    } else {
        LOGGER.info("No tasks specified. Using project default tasks {}", GUtil.toString(defaultTasks));
    }

    startParameter.setTaskNames(defaultTasks);
    context.proceed();
}
 
Example 5
Source File: ConfiguringBuildAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private StartParameter configureStartParameter(ProviderOperationParameters parameters, Map<String, String> properties) {
    // Important that this is constructed on the client so that it has the right gradleHomeDir and other state internally
    StartParameter startParameter = new StartParameter();

    startParameter.setProjectDir(parameters.getProjectDir());
    if (parameters.getGradleUserHomeDir() != null) {
        startParameter.setGradleUserHomeDir(parameters.getGradleUserHomeDir());
    }

    List<InternalLaunchable> launchables = parameters.getLaunchables(null);
    if (launchables != null) {
        startParameter.setTaskRequests(unpack(launchables));
    } else if (parameters.getTasks() != null) {
        startParameter.setTaskNames(parameters.getTasks());
    }

    new PropertiesToStartParameterConverter().convert(properties, startParameter);

    List<String> arguments = parameters.getArguments(Collections.<String>emptyList());
    if (arguments != null) {
        DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
        try {
            converter.convert(arguments, startParameter);
        } catch (CommandLineArgumentException e) {
            throw new InternalUnsupportedBuildArgumentException(
                "Problem with provided build arguments: " + arguments + ". "
                + "\n" + e.getMessage()
                + "\nEither it is not a valid build option or it is not supported in the target Gradle version."
                + "\nNot all of the Gradle command line options are supported build arguments."
                + "\nExamples of supported build arguments: '--info', '-u', '-p'."
                + "\nExamples of unsupported build options: '--daemon', '-?', '-v'."
                + "\nPlease find more information in the javadoc for the BuildLauncher class.", e);
        }
    }

    if (parameters.isSearchUpwards() != null) {
        startParameter.setSearchUpwards(parameters.isSearchUpwards());
    }

    if (parameters.getBuildLogLevel() != null) {
        startParameter.setLogLevel(parameters.getBuildLogLevel());
    }

    return startParameter;
}
 
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: ConfiguringBuildAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
StartParameter configureStartParameter(PropertiesToStartParameterConverter propertiesToStartParameterConverter) {
    StartParameter startParameter = startParameterTemplate.newInstance();

    startParameter.setProjectDir(projectDirectory);
    if (gradleUserHomeDir != null) {
        startParameter.setGradleUserHomeDir(gradleUserHomeDir);
    }

    if (launchables != null) {
        List<String> allTasks = new ArrayList<String>();
        String projectPath = null;
        for (InternalLaunchable launchable : launchables) {
            if (launchable instanceof LaunchableImplementation) {
                LaunchableImplementation launchableImpl = (LaunchableImplementation) launchable;
                allTasks.add(launchableImpl.getTaskName());
                if (launchableImpl.getProjectPath() != null) {
                    if (projectPath != null && !projectPath.equals(launchableImpl.getProjectPath())) {
                        throw new InternalUnsupportedBuildArgumentException(
                                "Problem with provided launchable arguments: " + launchables + ". "
                                        + "\nOnly selector from the same Gradle project can be built."
                        );
                    }
                    projectPath = launchableImpl.getProjectPath();
                }
            } else {
                throw new InternalUnsupportedBuildArgumentException(
                        "Problem with provided launchable arguments: " + launchables + ". "
                                + "\nOnly objects from this provider can be built."
                );
            }
        }
        if (projectPath != null) {
            startParameter.setProjectPath(projectPath);
        }
        startParameter.setTaskNames(allTasks);
    } else if (tasks != null) {
        startParameter.setTaskNames(tasks);
    }

    propertiesToStartParameterConverter.convert(properties, startParameter);

    if (arguments != null) {
        DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
        try {
            converter.convert(arguments, startParameter);
        } catch (CommandLineArgumentException e) {
            throw new InternalUnsupportedBuildArgumentException(
                "Problem with provided build arguments: " + arguments + ". "
                + "\n" + e.getMessage()
                + "\nEither it is not a valid build option or it is not supported in the target Gradle version."
                + "\nNot all of the Gradle command line options are supported build arguments."
                + "\nExamples of supported build arguments: '--info', '-u', '-p'."
                + "\nExamples of unsupported build options: '--daemon', '-?', '-v'."
                + "\nPlease find more information in the javadoc for the BuildLauncher class.", e);
        }
    }

    if (searchUpwards != null) {
        startParameter.setSearchUpwards(searchUpwards);
    }

    if (buildLogLevel != null) {
        startParameter.setLogLevel(buildLogLevel);
    }

    return startParameter;
}
 
Example 8
Source File: ConfiguringBuildAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private StartParameter configureStartParameter(ProviderOperationParameters parameters, Map<String, String> properties) {
    // Important that this is constructed on the client so that it has the right gradleHomeDir and other state internally
    StartParameter startParameter = new StartParameter();

    startParameter.setProjectDir(parameters.getProjectDir());
    if (parameters.getGradleUserHomeDir() != null) {
        startParameter.setGradleUserHomeDir(parameters.getGradleUserHomeDir());
    }

    List<InternalLaunchable> launchables = parameters.getLaunchables(null);
    if (launchables != null) {
        startParameter.setTaskRequests(unpack(launchables));
    } else if (parameters.getTasks() != null) {
        startParameter.setTaskNames(parameters.getTasks());
    }

    new PropertiesToStartParameterConverter().convert(properties, startParameter);

    List<String> arguments = parameters.getArguments(Collections.<String>emptyList());
    if (arguments != null) {
        DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
        try {
            converter.convert(arguments, startParameter);
        } catch (CommandLineArgumentException e) {
            throw new InternalUnsupportedBuildArgumentException(
                "Problem with provided build arguments: " + arguments + ". "
                + "\n" + e.getMessage()
                + "\nEither it is not a valid build option or it is not supported in the target Gradle version."
                + "\nNot all of the Gradle command line options are supported build arguments."
                + "\nExamples of supported build arguments: '--info', '-u', '-p'."
                + "\nExamples of unsupported build options: '--daemon', '-?', '-v'."
                + "\nPlease find more information in the javadoc for the BuildLauncher class.", e);
        }
    }

    if (parameters.isSearchUpwards() != null) {
        startParameter.setSearchUpwards(parameters.isSearchUpwards());
    }

    if (parameters.getBuildLogLevel() != null) {
        startParameter.setLogLevel(parameters.getBuildLogLevel());
    }

    return startParameter;
}
 
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: ConfiguringBuildAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
StartParameter configureStartParameter(PropertiesToStartParameterConverter propertiesToStartParameterConverter) {
    StartParameter startParameter = startParameterTemplate.newInstance();

    startParameter.setProjectDir(projectDirectory);
    if (gradleUserHomeDir != null) {
        startParameter.setGradleUserHomeDir(gradleUserHomeDir);
    }

    if (launchables != null) {
        List<String> allTasks = new ArrayList<String>();
        String projectPath = null;
        for (InternalLaunchable launchable : launchables) {
            if (launchable instanceof LaunchableImplementation) {
                LaunchableImplementation launchableImpl = (LaunchableImplementation) launchable;
                allTasks.add(launchableImpl.getTaskName());
                if (launchableImpl.getProjectPath() != null) {
                    if (projectPath != null && !projectPath.equals(launchableImpl.getProjectPath())) {
                        throw new InternalUnsupportedBuildArgumentException(
                                "Problem with provided launchable arguments: " + launchables + ". "
                                        + "\nOnly selector from the same Gradle project can be built."
                        );
                    }
                    projectPath = launchableImpl.getProjectPath();
                }
            } else {
                throw new InternalUnsupportedBuildArgumentException(
                        "Problem with provided launchable arguments: " + launchables + ". "
                                + "\nOnly objects from this provider can be built."
                );
            }
        }
        if (projectPath != null) {
            startParameter.setProjectPath(projectPath);
        }
        startParameter.setTaskNames(allTasks);
    } else if (tasks != null) {
        startParameter.setTaskNames(tasks);
    }

    propertiesToStartParameterConverter.convert(properties, startParameter);

    if (arguments != null) {
        DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
        try {
            converter.convert(arguments, startParameter);
        } catch (CommandLineArgumentException e) {
            throw new InternalUnsupportedBuildArgumentException(
                "Problem with provided build arguments: " + arguments + ". "
                + "\n" + e.getMessage()
                + "\nEither it is not a valid build option or it is not supported in the target Gradle version."
                + "\nNot all of the Gradle command line options are supported build arguments."
                + "\nExamples of supported build arguments: '--info', '-u', '-p'."
                + "\nExamples of unsupported build options: '--daemon', '-?', '-v'."
                + "\nPlease find more information in the javadoc for the BuildLauncher class.", e);
        }
    }

    if (searchUpwards != null) {
        startParameter.setSearchUpwards(searchUpwards);
    }

    if (buildLogLevel != null) {
        startParameter.setLogLevel(buildLogLevel);
    }

    return startParameter;
}