/** * Finalize the project configuration * * <ul> * <li>Initialize the license URLs if not set * </ul> * * @param projectConfig Project configuration to finalize */ @Finalize public void finalizeProjectConfig(ProjectConfig projectConfig) { License license = projectConfig.getLicense(); String licenseId = license.getId(); if (licenseId != null) { if (license.getUrl() == null) { license.setUrl("https://opensource.org/licenses/" + licenseId.replace(' ', '-')); } if (license.getSourceUrl() == null) { license.setSourceUrl( "https://raw.githubusercontent.com/github/choosealicense.com/gh-pages/_licenses/" + licenseId.toLowerCase().replace(' ', '-') + ".txt"); } } }
/** * Finalize the project configuration * * <ul> * <li>Initialize the license URLs if not set * </ul> * * @param projectConfig Project configuration to finalize */ @Finalize public void finalizeProjectConfig(ProjectConfig projectConfig) { License license = projectConfig.getLicense(); String licenseId = license.getId(); if (licenseId != null) { if (license.getUrl() == null) { license.setUrl("https://opensource.org/licenses/" + licenseId.replace(' ', '-')); } if (license.getSourceUrl() == null) { license.setSourceUrl( "https://raw.githubusercontent.com/github/choosealicense.com/gh-pages/_licenses/" + licenseId.toLowerCase().replace(' ', '-') + ".txt"); } } }
/** * Create task to update license template file * * @param tasks Task container to create task * @param projectConfig Project configuration for general project data * @param licenseExtension License extension for license data * @param files Resolver for file names */ @Mutate public void createLicenseTemplateUpdateTask(ModelMap<Task> tasks, ProjectConfig projectConfig, LicenseExtension licenseExtension, FileOperations files) { tasks.create("licenseTemplateUpdate", UpdateLicenseTask.class, t -> { t.setDescription("Download configured license into license template file."); t.setGroup("license"); t.setLicenseFile(files.file("src/doc/templates/LICENSE.txt")); ConventionMapping parameters = t.getConventionMapping(); parameters.map("copyrightName", () -> projectConfig.getOrganization().getName()); parameters.map("copyrightYear", () -> getCopyrightYearTemplate(projectConfig)); parameters.map("licenseUrl", () -> projectConfig.getLicense().getSourceUrl()); }); }
/** * Create task to update license template file * * @param tasks Task container to create task * @param projectConfig Project configuration for general project data * @param licenseExtension License extension for license data * @param files Resolver for file names */ @Mutate public void createLicenseTemplateUpdateTask(ModelMap<Task> tasks, ProjectConfig projectConfig, LicenseExtension licenseExtension, FileOperations files) { tasks.create("licenseTemplateUpdate", UpdateLicenseTask.class, t -> { t.setDescription("Download configured license into license template file."); t.setGroup("license"); t.setLicenseFile(files.file("src/doc/templates/LICENSE.txt")); ConventionMapping parameters = t.getConventionMapping(); parameters.map("copyrightName", () -> projectConfig.getOrganization().getName()); parameters.map("copyrightYear", () -> getCopyrightYearTemplate(projectConfig)); parameters.map("licenseUrl", () -> projectConfig.getLicense().getSourceUrl()); }); }
if (license.getSourceUrl() == null) { LOGGER.warn("Please configure projectConfig.license.sourceUrl");
if (license.getSourceUrl() == null) { LOGGER.warn("Please configure projectConfig.license.sourceUrl");