private void addInstallTask(final Project project, final Distribution distribution) { String taskName = TASK_INSTALL_NAME; if (!MAIN_DISTRIBUTION_NAME.equals(distribution.getName())) { taskName = "install" + StringGroovyMethods.capitalize(distribution.getName()) + "Dist"; } Sync installTask = project.getTasks().create(taskName, Sync.class); installTask.setDescription("Installs the project as a distribution as-is."); installTask.setGroup(DISTRIBUTION_GROUP); installTask.with(distribution.getContents()); installTask.into(new Callable<File>() { @Override public File call() throws Exception { return project.file("" + project.getBuildDir() + "/install/" + distribution.getBaseName()); } }); }
@Override public void apply(final Project project) { explodedArchives = project.getExtensions().create("explodedArchives", ExplodedArchivesExtension.class); explodeAll = project.getTasks().create("explode"); explodeAll.setGroup(BasePlugin.BUILD_GROUP); project.getTasks().withType(AbstractArchiveTask.class, archiveTask -> { Sync explodeArchive = project.getTasks().create("explode" + capitalize((CharSequence) archiveTask.getName()), Sync.class); explodeAll.dependsOn(explodeArchive); explodeArchive.dependsOn(archiveTask); explodeArchive.getConventionMapping() .map("group", (Callable<String>) archiveTask::getGroup); explodeArchive.getConventionMapping() .map("destinationDir", (Callable<File>) () -> { File explodedDir = new File(archiveTask.getDestinationDir(), "exploded"); if (explodedArchives.isIncludeExtension()) { return new File(explodedDir, archiveTask.getArchiveName()); } else { return new File(explodedDir, minus((CharSequence) archiveTask.getArchiveName(), "." + archiveTask.getExtension())); } }); explodeArchive.from((Callable<FileTree>) () -> project.zipTree(archiveTask.getArchivePath())); }); }
@NonNull @Override public Class<Sync> getType() { return Sync.class; }
@Override public void execute(@NonNull Sync packageRenderscript) { packageRenderscript.from(getAppVariantOutputContext().getApkOutputFile(true)); packageRenderscript.from(((AppVariantContext)variantContext).getAwbApkFiles()); }
private void configureOverlay(WarOverlay overlay, ExternalDependency dependency) { War warTask = overlay.getWarTask(); String capitalizedWarTaskName = StringGroovyMethods.capitalize((CharSequence) warTask.getName()); String capitalizedOverlayName = StringGroovyMethods.capitalize((CharSequence) overlay.getName()); dependency.setTransitive(false); Configuration configuration = project.getConfigurations().create(overlay.getConfigurationName()); configuration.setDescription(String.format("Contents of the overlay '%s' for the task '%s'.", overlay.getName(), warTask.getName())); configuration.getDependencies().add(dependency); File destinationDir = new File(project.getBuildDir(), String.format("overlays/%s/%s", warTask.getName(), overlay.getName())); Action<CopySpec> extractOverlay = copySpec -> { copySpec.into(destinationDir); copySpec.from((Callable<FileTree>) () -> project.zipTree(configuration.getSingleFile())); }; Sync extractOverlayTask = project.getTasks().create(String.format("extract%s%sOverlay", capitalizedOverlayName, capitalizedWarTaskName), Sync.class, extractOverlay); overlay.getWarCopySpec().from(extractOverlayTask); if (overlay.isEnableCompilation()) { 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(COMPILE_CLASSPATH_CONFIGURATION_NAME, classes); project.getDependencies().add(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME, classes); FileTree libs = project.files(extractOverlayTask).builtBy(extractOverlayTask).getAsFileTree() .matching(patternFilterable -> patternFilterable.include("WEB-INF/lib/**")); project.getDependencies().add(COMPILE_CLASSPATH_CONFIGURATION_NAME, libs); project.getDependencies().add(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME, libs); } }