private Copy _addTaskExpandCompileDependency( Project project, File file, File destinationDir, String taskNamePrefix, RenameDependencyClosure renameDependencyClosure) { String taskName = GradleUtil.getTaskName(taskNamePrefix, file); Copy copy = GradleUtil.addTask(project, taskName, Copy.class); copy.doFirst( new Action<Task>() { @Override public void execute(Task task) { Copy copy = (Copy) task; Project project = copy.getProject(); project.delete(copy.getDestinationDir()); } }); copy.from(project.zipTree(file)); String name = renameDependencyClosure.call(file.getName()); name = name.substring(0, name.length() - 4); destinationDir = new File(destinationDir, name); copy.setDescription( "Expands " + file.getName() + " into " + project.relativePath(destinationDir) + "."); copy.setDestinationDir(destinationDir); return copy; }
public static String getRelativePath(Project project, File file) { String relativePath = project.relativePath(file); return relativePath.replace('\\', '/'); }