@TaskAction public void executeAction() { if (instantRunBuildContext.getBuildHasFailed()) { try { instantRunBuildContext.writeTmpBuildInfo(tmpBuildInfoFile); } catch (ParserConfigurationException | IOException e) { throw new RuntimeException("Exception while saving temp-build-info.xml", e); } return; } // done with the instant run context. instantRunBuildContext.close(); try { String xml = instantRunBuildContext.toXml(); if (logger.isEnabled(LogLevel.DEBUG)) { logger.debug("build-id $1$l, build-info.xml : %2$s", instantRunBuildContext.getBuildId(), xml); } Files.createParentDirs(buildInfoFile); Files.write(xml, buildInfoFile, Charsets.UTF_8); } catch (Exception e) { throw new RuntimeException("Exception while saving build-info.xml", e); } // Record instant run status in analytics for this build ProcessProfileWriter.getGlobalProperties() .setInstantRunStatus( InstantRunAnalyticsHelper.generateAnalyticsProto(instantRunBuildContext)); }