org.gradle.api.tasks.Delete Java Examples

The following examples show how to use org.gradle.api.tasks.Delete. 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: CleanRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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());
}
 
Example #2
Source File: CleanRule.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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());
}
 
Example #3
Source File: CleanRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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());
}
 
Example #4
Source File: CleanRule.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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());
}
 
Example #5
Source File: LifecycleBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
        }
    });
}
 
Example #6
Source File: BasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
        }
    });
}
 
Example #7
Source File: CloudServicesPackagingPlugin.java    From commerce-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(Project project) {
    PackagingExtension extension = project.getExtensions().create(EXTENSION, PackagingExtension.class, project);
    extension.getPlatformZip().set(project.file("hybris/temp/hybris/hybrisServer/hybrisServer-Platform.zip"));
    extension.getAllExtensionsZip().set(project.file("hybris/temp/hybris/hybrisServer/hybrisServer-AllExtensions.zip"));
    extension.getEnvironments().set(project.provider(() -> new HashSet<>(Arrays.asList("dev", "stag", "prod"))));
    extension.getPreProductionEnvironment().set("stag");
    extension.getProjectID().set(project.provider(project::getName));

    extension.getConfigurationFolder().set(project.file("ccv1-configuration"));
    extension.getDistributionFolder().set(project.file("dist"));
    extension.getTempFolder().set(project.file("temp"));


    Task bootstrap = project.getTasks().create("bootstrapCCV1Config");
    bootstrap.setGroup(GROUP);
    bootstrap.setDescription("Creates environment config folders, if they don't exist");
    project.afterEvaluate(p -> setupBootstrap(p, bootstrap, extension));

    Delete cleanTempFolder = project.getTasks().create("cleanTemp", Delete.class, t -> {
        t.delete(extension.getTempFolder());
    });
    cleanTempFolder.setGroup(GROUP);
    cleanTempFolder.setDescription("cleans temp folder used to assemble the final package");

    Task buildPackage = project.getTasks().create("buildCCV1Package");
    buildPackage.setGroup(GROUP);
    buildPackage.setDescription("Builds a distribution package based on Deployment Packaging Guidelines (v.2.3.3)");
    project.afterEvaluate(p -> setupPackaging(p, buildPackage, extension));

    project.getPlugins().withType(HybrisPlugin.class, hybrisPlugin -> {
        //sensible defaults
        buildPackage.mustRunAfter(project.getTasks().getByPath("yproduction"));
    });
}
 
Example #8
Source File: CloudV2Plugin.java    From commerce-gradle-plugin with Apache License 2.0 5 votes vote down vote up
private void configureCloudExtensionPackBootstrap(Project project, boolean useCloudExtensionPack) {
    if (!useCloudExtensionPack) {
        return;
    }
    Task cleanCep = project.getTasks().create("cleanCloudExtensionPack", Delete.class, d -> {
        d.delete(extension.getCloudExtensionPackFolder().getAsFile());
    });
    Copy unpackCep = project.getTasks().create("unpackCloudExtensionPack", Copy.class, c -> {
        c.dependsOn(cleanCep);
        c.from(project.provider(() -> project.getConfigurations()
                        .getByName(EXTENSION_PACK)
                        .getFiles()
                        .stream()
                        .map(project::zipTree)
                        .collect(Collectors.toSet())
                )
        );
        c.into(extension.getCloudExtensionPackFolder().getAsFile());
        c.doLast(a -> project.getConfigurations().getByName(EXTENSION_PACK)
                .getResolvedConfiguration()
                .getFirstLevelModuleDependencies()
                .forEach(r -> a.getLogger().lifecycle("Using Cloud Extension Pack: {}", r.getModuleVersion())));
    });

    Task bootstrapPlatform = project.getTasks().getByName("bootstrapPlatform");
    bootstrapPlatform.dependsOn(unpackCep);
    String reservedTypeCodes = "hybris/bin/platform/ext/core/resources/core/unittest/reservedTypecodes.txt";
    Copy copyTypeCodes = project.getTasks().create("copyCEPTypeCode", Copy.class, c -> {
        c.mustRunAfter(unpackCep);
        c.mustRunAfter("unpackPlatform");
        c.from(extension.getCloudExtensionPackFolder().file(reservedTypeCodes));
        c.into(project.file(reservedTypeCodes).getParent());
    });
    bootstrapPlatform.dependsOn(copyTypeCodes);
    PatchLocalExtensions patch = project.getTasks().create("patchLocalExtensions", PatchLocalExtensions.class, p -> {
        p.getTarget().set(project.file("hybris/config/localextensions.xml"));
        p.getCepFolder().set(extension.getCloudExtensionPackFolder());
    });
    bootstrapPlatform.dependsOn(patch);
}
 
Example #9
Source File: LifecycleBasePlugin.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
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();
                }
            });
        }
    });
}
 
Example #10
Source File: NodePlugin.java    From curiostack with MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
  project.getRootProject().getPlugins().apply(NodeSetupPlugin.class);
  project.getPlugins().apply(BasePlugin.class);

  project
      .getTasks()
      .withType(Delete.class)
      .named("clean")
      .configure(t -> t.delete("node_modules"));

  project
      .getTasks()
      .addRule(
          "Pattern: \"yarn_<command>\": Executes an Yarn command.",
          taskName -> {
            if (taskName.startsWith("yarn_")) {
              project
                  .getTasks()
                  .create(
                      taskName,
                      NodeTask.class,
                      t -> {
                        List<String> tokens = YARN_TASK_SPLITTER.splitToList(taskName);
                        t.args(tokens.subList(1, tokens.size()));
                      });
            }
          });
}
 
Example #11
Source File: LifecycleBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
        }
    });
}
 
Example #12
Source File: BasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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();
        }
    });
}