org.gradle.api.tasks.Sync Java Examples

The following examples show how to use org.gradle.api.tasks.Sync. 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: PlayDistributionPlugin.java    From playframework with Apache License 2.0 5 votes vote down vote up
private void createDistributionZipTasks(Project project, Distribution distribution, TaskProvider<Task> stageLifecycleTask, TaskProvider<Task> distLifecycleTask) {
    final String capitalizedDistName = capitalizeDistributionName(distribution.getName());
    final String stageTaskName = "stage" + capitalizedDistName + "Dist";
    final File stageDir = new File(project.getBuildDir(), "stage");
    final String baseName = (distribution.getBaseName() != null && "".equals(distribution.getBaseName())) ? distribution.getBaseName() : distribution.getName();

    TaskProvider<Sync> stageSyncTask = project.getTasks().register(stageTaskName, Sync.class, sync -> {
        sync.setDescription("Copies the '" + distribution.getName() + "' distribution to a staging directory.");
        sync.setDestinationDir(stageDir);

        sync.into(baseName, copySpec -> copySpec.with(distribution.getContents()));
    });

    stageLifecycleTask.configure(task -> task.dependsOn(stageSyncTask));

    final String distributionZipTaskName = "create" + capitalizedDistName + "ZipDist";
    TaskProvider<Zip> distZipTask = project.getTasks().register(distributionZipTaskName, Zip.class, zip -> {
        zip.setDescription("Packages the '" + distribution.getName() + "' distribution as a zip file.");
        zip.setBaseName(baseName);
        zip.setDestinationDir(new File(project.getBuildDir(), "distributions"));
        zip.from(stageSyncTask);
    });

    final String distributionTarTaskName = "create" + capitalizedDistName + "TarDist";
    TaskProvider<Tar> distTarTask = project.getTasks().register(distributionTarTaskName, Tar.class, tar -> {
        tar.setDescription("Packages the '" + distribution.getName() + "' distribution as a tar file.");
        tar.setBaseName(baseName);
        tar.setDestinationDir(new File(project.getBuildDir(), "distributions"));
        tar.from(stageSyncTask);
    });

    distLifecycleTask.configure(task -> {
        task.dependsOn(distZipTask);
        task.dependsOn(distTarTask);
    });
}
 
Example #2
Source File: ProcessJavaResConfigAction.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(@NonNull Sync processResources) {
    scope.getVariantData().processJavaResourcesTask = processResources;

    // set the input
    processResources.from(((AndroidSourceSet) scope.getVariantConfiguration().getDefaultSourceSet()).getResources().getSourceFiles());
    processResources.from(((AndroidSourceSet) scope.getVariantConfiguration().getBuildTypeSourceSet()).getResources().getSourceFiles());
    if (scope.getVariantConfiguration().hasFlavors()) {
        for (SourceProvider flavorSourceSet : scope.getVariantConfiguration().getFlavorSourceProviders()) {
            processResources.from(((AndroidSourceSet) flavorSourceSet).getResources().getSourceFiles());
        }

    }
    processResources.setDestinationDir(new File(scope.getSourceFoldersJavaResDestinationDir(), "src"));
}
 
Example #3
Source File: WarOverlayPlugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
private void configureOverlay(WarOverlay overlay, Callable<FileTree> warTree) {
    War warTask = overlay.getWarTask();

    String capitalizedWarTaskName = StringGroovyMethods.capitalize((CharSequence) warTask.getName());
    String capitalizedOverlayName = StringGroovyMethods.capitalize((CharSequence) overlay.getName());

    File destinationDir = new File(project.getBuildDir(), String.format("overlays/%s/%s", warTask.getName(), overlay.getName()));
    Action<CopySpec> extractOverlay = copySpec -> {
        copySpec.into(destinationDir);
        copySpec.from(warTree);
    };

    Sync extractOverlayTask = project.getTasks().create(String.format("extract%s%sOverlay", capitalizedOverlayName, capitalizedWarTaskName), Sync.class, extractOverlay);

    overlay.getWarCopySpec().from(extractOverlayTask);

    if (overlay.isEnableCompilation()) {

        if (!destinationDir.exists() || isEmpty(destinationDir)) {
            project.sync(extractOverlay);
        }

        project.getTasks().getByName(CLEAN_TASK_NAME).finalizedBy(extractOverlayTask);

        ConfigurableFileCollection classes = project.files(new File(destinationDir, "WEB-INF/classes"))
                .builtBy(extractOverlayTask);

        project.getDependencies().add(getClasspathConfigurationName(overlay), classes);

        FileTree libs = project.files(extractOverlayTask).builtBy(extractOverlayTask).getAsFileTree()
                .matching(patternFilterable -> patternFilterable.include("WEB-INF/lib/**"));

        project.getDependencies().add(getClasspathConfigurationName(overlay), libs);
    }
}
 
Example #4
Source File: WarOverlayPlugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
private void configureOverlay(WarOverlay overlay, Callable<FileTree> warTree) {
    War warTask = overlay.getWarTask();

    String capitalizedWarTaskName = StringGroovyMethods.capitalize((CharSequence) warTask.getName());
    String capitalizedOverlayName = StringGroovyMethods.capitalize((CharSequence) overlay.getName());

    File destinationDir = new File(project.getBuildDir(), String.format("overlays/%s/%s", warTask.getName(), overlay.getName()));
    Action<CopySpec> extractOverlay = copySpec -> {
        copySpec.into(destinationDir);
        copySpec.from(warTree);
    };

    Sync extractOverlayTask = project.getTasks().create(String.format("extract%s%sOverlay", capitalizedOverlayName, capitalizedWarTaskName), Sync.class, extractOverlay);

    overlay.getWarCopySpec().from(extractOverlayTask);

    if (overlay.isEnableCompilation()) {

        if (!destinationDir.exists() || isEmpty(destinationDir)) {
            project.sync(extractOverlay);
        }

        project.getTasks().getByName(CLEAN_TASK_NAME).finalizedBy(extractOverlayTask);

        ConfigurableFileCollection classes = project.files(new File(destinationDir, "WEB-INF/classes"))
                .builtBy(extractOverlayTask);

        project.getDependencies().add(getClasspathConfigurationName(overlay), classes);

        FileTree libs = project.files(extractOverlayTask).builtBy(extractOverlayTask).getAsFileTree()
                .matching(patternFilterable -> patternFilterable.include("WEB-INF/lib/**"));

        project.getDependencies().add(getClasspathConfigurationName(overlay), libs);
    }
}
 
Example #5
Source File: MergeClassesHelper.java    From gradle-modules-plugin with MIT License 4 votes vote down vote up
public Sync createMergeClassesTask() {
    return project.getTasks().create(MERGE_CLASSES_TASK_NAME, Sync.class);
}
 
Example #6
Source File: PackageTPatchConfigAction.java    From atlas with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public Class<Sync> getType() {
    return Sync.class;
}
 
Example #7
Source File: PackageTPatchConfigAction.java    From atlas with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(@NonNull Sync packageRenderscript) {
    packageRenderscript.from(getAppVariantOutputContext().getApkOutputFile(true));
    packageRenderscript.from(((AppVariantContext)variantContext).getAwbApkFiles());
}
 
Example #8
Source File: ProcessJavaResConfigAction.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Class<Sync> getType() {
    return Sync.class;
}
 
Example #9
Source File: BaseVariantImpl.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
@Override
@NonNull
public Sync getProcessJavaResources() {
    return getVariantData().processJavaResourcesTask;
}
 
Example #10
Source File: VariantScope.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public AndroidTask<Sync> getProcessJavaResourcesTask() {
    return processJavaResourcesTask;
}
 
Example #11
Source File: VariantScope.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public void setProcessJavaResourcesTask(
        AndroidTask<Sync> processJavaResourcesTask) {
    this.processJavaResourcesTask = processJavaResourcesTask;
}