/** * Download license */ @TaskAction public void updateLicense() { String url = Validate.notNull(getLicenseUrl(), "The license URL must be set"); File licenseFile = Validate.notNull(getLicenseFile(), "The license file must be set"); try { String licenseText = Validate.notNull(Resources.toString(URI.create(url).toURL(), Charsets.UTF_8)); licenseText = licenseText.replaceFirst("(?s)^.*\\R---\\R+", ""); licenseText = replaceVariables(licenseText); licenseText = licenseText.replaceAll("(?m)^[ \\t]+", ""); Files.write(licenseText, licenseFile, Charsets.UTF_8); } catch (IOException e) { Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } }
/** * Download license */ @TaskAction public void updateLicense() { String url = Validate.notNull(getLicenseUrl(), "The license URL must be set"); File licenseFile = Validate.notNull(getLicenseFile(), "The license file must be set"); try { String licenseText = Validate.notNull(Resources.toString(URI.create(url).toURL(), Charsets.UTF_8)); licenseText = licenseText.replaceFirst("(?s)^.*\\R---\\R+", ""); licenseText = replaceVariables(licenseText); licenseText = licenseText.replaceAll("(?m)^[ \\t]+", ""); Files.write(licenseText, licenseFile, Charsets.UTF_8); } catch (IOException e) { Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } }