public WorkResult execute(final CopyActionProcessingStream stream) { ZipOutputStream zipOutStr; try { zipOutStr = new ZipOutputStream(new FileOutputStream(zipFile)); } catch (Exception e) { throw new GradleException(String.format("Could not create ZIP '%s'.", zipFile), e); } IoActions.withResource(zipOutStr, new Action<ZipOutputStream>() { public void execute(ZipOutputStream outputStream) { stream.process(new StreamAction(outputStream)); } }); return new SimpleWorkResult(true); }