@Override public void apply(String taskName) { if (!taskName.startsWith(CLEAN) || taskName.equals(CLEAN)) { return; } String targetTaskName = taskName.substring(CLEAN.length()); if (Character.isLowerCase(targetTaskName.charAt(0))) { return; } Task task = tasks.findByName(StringUtils.uncapitalize(targetTaskName)); if (task == null) { return; } Delete clean = tasks.create(taskName, Delete.class); clean.delete(task.getOutputs().getFiles()); }
public void apply(String taskName) { if (!taskName.startsWith(PREFIX)) { return; } String targetTaskName = taskName.substring(PREFIX.length()); if (Character.isLowerCase(targetTaskName.charAt(0))) { return; } Task task = tasks.findByName(StringUtils.uncapitalize(targetTaskName)); if (task == null) { return; } Delete clean = tasks.create(taskName, Delete.class); clean.delete(task.getOutputs().getFiles()); }
private void addClean(final ProjectInternal project) { addPlaceholderAction(project, CLEAN_TASK_NAME, Delete.class, new Action<Delete>() { @Override public void execute(Delete clean) { clean.setDescription("Deletes the build directory."); clean.setGroup(BUILD_GROUP); clean.delete(new Callable<File>() { public File call() throws Exception { return project.getBuildDir(); } }); } }); }
public void addWorker(Task worker, boolean includeInClean) { lifecycleTask.dependsOn(worker); Delete cleanWorker = project.getTasks().create(cleanName(worker.getName()), Delete.class); cleanWorker.delete(worker.getOutputs().getFiles()); if (includeInClean) { cleanTask.dependsOn(cleanWorker); } }
/** * Create the Eclipse UI tasks * * @param tasks Task container * @param eclipseConfig Eclipse configuration * @param project Current Gradle project */ @Mutate public void createEclipseUiTasks(ModelMap<Task> tasks, EclipseConfig eclipseConfig, Project project) { tasks.create("eclipseUi", GenerateEclipseUi.class, t -> { t.setDescription("Generates the Eclipse JDT UI settings file (org.eclipse.jdt.ui.prefs)."); t.setOutputFile(project.file(".settings/org.eclipse.jdt.ui.prefs")); t.setInputFile(project.file(".settings/org.eclipse.jdt.ui.prefs")); t.setUi(eclipseConfig.getUi()); }); tasks.create("cleanEclipseUi", Delete.class, t -> { t.delete(project.file(".settings/org.eclipse.jdt.ui.prefs")); t.setDescription("Removes the Eclipse JDT UI settings file (org.eclipse.jdt.ui.prefs)."); }); }
private void addClean(final Project project) { Delete clean = project.getTasks().create(CLEAN_TASK_NAME, Delete.class); clean.setDescription("Deletes the build directory."); clean.setGroup(BUILD_GROUP); clean.delete(new Callable<File>() { public File call() throws Exception { return project.getBuildDir(); } }); }