Java源码示例:org.gradle.TaskExecutionRequest
示例1
private List<TaskExecutionRequest> unpack(final List<InternalLaunchable> launchables) {
// Important that the launchables are unpacked on the client side, to avoid sending back any additional internal state that
// the launchable may hold onto. For example, GradleTask implementations hold onto every task for every project in the build
List<TaskExecutionRequest> requests = new ArrayList<TaskExecutionRequest>(launchables.size());
for (InternalLaunchable launchable : launchables) {
if (launchable instanceof TaskExecutionRequest) {
TaskExecutionRequest originalLaunchable = (TaskExecutionRequest) launchable;
TaskExecutionRequest launchableImpl = new DefaultTaskExecutionRequest(originalLaunchable.getArgs(), originalLaunchable.getProjectPath());
requests.add(launchableImpl);
} else {
throw new InternalUnsupportedBuildArgumentException(
"Problem with provided launchable arguments: " + launchables + ". "
+ "\nOnly objects from this provider can be built."
);
}
}
return requests;
}
示例2
private List<TaskExecutionRequest> unpack(final List<InternalLaunchable> launchables) {
// Important that the launchables are unpacked on the client side, to avoid sending back any additional internal state that
// the launchable may hold onto. For example, GradleTask implementations hold onto every task for every project in the build
List<TaskExecutionRequest> requests = new ArrayList<TaskExecutionRequest>(launchables.size());
for (InternalLaunchable launchable : launchables) {
if (launchable instanceof TaskExecutionRequest) {
TaskExecutionRequest originalLaunchable = (TaskExecutionRequest) launchable;
TaskExecutionRequest launchableImpl = new DefaultTaskExecutionRequest(originalLaunchable.getArgs(), originalLaunchable.getProjectPath());
requests.add(launchableImpl);
} else {
throw new InternalUnsupportedBuildArgumentException(
"Problem with provided launchable arguments: " + launchables + ". "
+ "\nOnly objects from this provider can be built."
);
}
}
return requests;
}
示例3
public ModelClassLoaderFactory(ClassLoaderFactory classLoaderFactory) {
this.classLoaderFactory = classLoaderFactory;
ClassLoader parent = getClass().getClassLoader();
FilteringClassLoader filter = new FilteringClassLoader(parent);
filter.allowPackage("org.gradle.tooling.internal.protocol");
filter.allowClass(TaskExecutionRequest.class);
rootClassLoader = filter;
}
示例4
public List<TaskSelector.TaskSelection> parseTasks(TaskExecutionRequest taskExecutionRequest) {
List<TaskSelector.TaskSelection> out = Lists.newArrayList();
List<String> remainingPaths = new LinkedList<String>(taskExecutionRequest.getArgs());
while (!remainingPaths.isEmpty()) {
String path = remainingPaths.remove(0);
TaskSelector.TaskSelection selection = taskSelector.getSelection(taskExecutionRequest.getProjectPath(), path);
Set<Task> tasks = selection.getTasks();
remainingPaths = taskConfigurer.configureTasks(tasks, remainingPaths);
out.add(selection);
}
return out;
}
示例5
public void configure(BuildExecutionContext context) {
GradleInternal gradle = context.getGradle();
TaskGraphExecuter executer = gradle.getTaskGraph();
List<TaskExecutionRequest> taskParameters = gradle.getStartParameter().getTaskRequests();
for (TaskExecutionRequest taskParameter : taskParameters) {
List<TaskSelector.TaskSelection> taskSelections = commandLineTaskParser.parseTasks(taskParameter);
for (TaskSelector.TaskSelection taskSelection : taskSelections) {
LOGGER.info("Selected primary task '{}' from project {}", taskSelection.getTaskName(), taskSelection.getProjectPath());
executer.addTasks(taskSelection.getTasks());
}
}
context.proceed();
}
示例6
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();
}
示例7
public ModelClassLoaderFactory(ClassLoaderFactory classLoaderFactory) {
this.classLoaderFactory = classLoaderFactory;
ClassLoader parent = getClass().getClassLoader();
FilteringClassLoader filter = new FilteringClassLoader(parent);
filter.allowPackage("org.gradle.tooling.internal.protocol");
filter.allowClass(TaskExecutionRequest.class);
rootClassLoader = filter;
}
示例8
public List<TaskSelector.TaskSelection> parseTasks(TaskExecutionRequest taskExecutionRequest) {
List<TaskSelector.TaskSelection> out = Lists.newArrayList();
List<String> remainingPaths = new LinkedList<String>(taskExecutionRequest.getArgs());
while (!remainingPaths.isEmpty()) {
String path = remainingPaths.remove(0);
TaskSelector.TaskSelection selection = taskSelector.getSelection(taskExecutionRequest.getProjectPath(), path);
Set<Task> tasks = selection.getTasks();
remainingPaths = taskConfigurer.configureTasks(tasks, remainingPaths);
out.add(selection);
}
return out;
}
示例9
public void configure(BuildExecutionContext context) {
GradleInternal gradle = context.getGradle();
TaskGraphExecuter executer = gradle.getTaskGraph();
List<TaskExecutionRequest> taskParameters = gradle.getStartParameter().getTaskRequests();
for (TaskExecutionRequest taskParameter : taskParameters) {
List<TaskSelector.TaskSelection> taskSelections = commandLineTaskParser.parseTasks(taskParameter);
for (TaskSelector.TaskSelection taskSelection : taskSelections) {
LOGGER.info("Selected primary task '{}' from project {}", taskSelection.getTaskName(), taskSelection.getProjectPath());
executer.addTasks(taskSelection.getTasks());
}
}
context.proceed();
}
示例10
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();
}