List of usage examples for org.apache.maven.plugin.logging Log warn
void warn(Throwable error);
From source file:schemacrawler.tools.integration.maven.SchemaCrawlerMojo.java
License:Open Source License
/** * Load configuration files, and add in other configuration options. * * @return SchemaCrawler command configuration *///from w ww . j av a2s .c o m private Config createAdditionalConfiguration() { final Config textOptionsConfig = createSchemaTextOptions(); try { final Config additionalConfiguration = Config.load(config, additionalConfig); additionalConfiguration.putAll(textOptionsConfig); return additionalConfiguration; } catch (final IOException e) { final Log logger = getLog(); logger.warn(e); return textOptionsConfig; } }
From source file:se.natusoft.tools.codelicmgr.MojoUtils.java
License:Open Source License
/** * Updates third party license information from maven project information. * * @param thirdpartyLicenses The third party license configuration to update. * @param mavenProject The running maven project. * @param localRepository The artifact repository for the current build. * @param log To log to./*from w w w.j a v a2 s . c o m*/ * @return The passed configuration. */ public static void updateThirdpartyLicenseConfigFromMavenProject(ThirdpartyLicensesConfig thirdpartyLicenses, MavenProject mavenProject, ArtifactRepository localRepository, Log log) { Set<Artifact> dependencies = mavenProject.getDependencyArtifacts(); if (dependencies != null) { for (Artifact depArtifact : dependencies) { if (!depArtifact.getType().equals("pom") && // Avoid test scope dependencies !depArtifact.getScope().equals(Artifact.SCOPE_TEST) && // Avoid internal dependencies. !depArtifact.getGroupId().equals(mavenProject.getArtifact().getGroupId())) { try { PomExtractor depPom = new PomExtractor(localRepository, depArtifact); ProductConfig newProdConfig = new ProductConfig(); newProdConfig.setName(depArtifact.getArtifactId()); newProdConfig.setVersion(depArtifact.getVersion()); newProdConfig.setWeb(depPom.getProductUrl()); if (depPom.getLicenseName() != null) { String licName = getLicenseName(depPom.getLicenseName()); String licVer = getLicenseVersion(depPom.getLicenseName()); // Lets try the name we extracted first ThirdpartyLicenseConfig tplConfig = lookupThirdpartyLicense(thirdpartyLicenses, licName); // That failed, try to construct an acronym of the name instead. if (tplConfig == null) { String altLicName = getLicenseNameAcronym(depPom.getLicenseName()); tplConfig = lookupThirdpartyLicense(thirdpartyLicenses, altLicName); if (tplConfig != null) { licName = altLicName; } else {// Not among the already known third party licenses, look in license library next. try { LibraryLicense libLic = LicenseLibrary.getLicense(altLicName, licVer, ""); if (libLic != null && !libLic.isDownloadable()) { String type = libLic.getType(); if (type != null) { licName = type; } } } catch (CodeLicenseException cle) { } } } // That also failed, now we try to remove all spaces from the name. if (tplConfig == null) { String altLicName = getLicenseName(depPom.getLicenseName()).replace(" ", ""); tplConfig = lookupThirdpartyLicense(thirdpartyLicenses, altLicName); if (tplConfig != null) { licName = altLicName; } else {// Not among the already known third party licenses, look in license library next. try { LibraryLicense libLic = LicenseLibrary.getLicense(altLicName, licVer, ""); if (libLic != null && !libLic.isDownloadable()) { String type = libLic.getType(); if (type != null) { licName = type; } } } catch (CodeLicenseException cle) { } } } // Still no go! Just create a new config and use what we have. Please note that if the // license was not found among the already known third party licenses, but found in a // license library the license name have been modified to the official name in the license // library. if (tplConfig == null) { tplConfig = new ThirdpartyLicenseConfig(); tplConfig.setType(licName); tplConfig.setVersion(licVer); tplConfig.setLicenseUrl(depPom.getLicenseUrl()); thirdpartyLicenses.addLicense(tplConfig); } // Check if current artifact already exists boolean artifactExists = false; for (ProductConfig prodConfig : tplConfig.getProducts().getProducts()) { if (prodConfig.getName().trim().toLowerCase() .equals(newProdConfig.getName().trim().toLowerCase())) { artifactExists = true; } } // If not add it. if (!artifactExists) { tplConfig.getProducts().addProduct(newProdConfig); } } else { if (lookupArtifactInConfiguredThirdpartyProduct(thirdpartyLicenses, depArtifact) == null) { log.warn("WARNING: Artifact '" + depArtifact + "' has no license information and has not been configured " + "under the <thirdpartyLicenses><license><products> section!"); } } } catch (IOException ioe) { log.warn("WARNING: Failed to extract information from maven dependency: " + depArtifact.getArtifactId() + "-" + depArtifact.getVersion() + " [" + ioe.getMessage() + "]"); } } } } }
From source file:ua.tifoha.maven.MergerMojo.java
License:Apache License
public void execute() throws MojoExecutionException { Log logger = getLog(); Pattern pattern = Pattern.compile(".+\\.properties"); Predicate<Path> propertiesPredicate = path -> pattern.matcher(path.toString()).matches(); Path buildPath = buildDirectory.toPath(); logger.debug("read directory:" + buildPath); try {//www . ja v a 2 s. c o m Map<Path, List<Path>> propGroups = Files.walk(buildPath).filter(propertiesPredicate) .collect(Collectors.groupingBy(MergerMojo::getBasePath)); for (Map.Entry<Path, List<Path>> pathListEntry : propGroups.entrySet()) { Path mainProperty = pathListEntry.getKey(); logger.debug("processing property file:" + mainProperty); Properties properties = new Properties(); pathListEntry.getValue().stream() .filter(path -> isTemplateProperties(path.getFileName().toString())) .peek(path -> logger.debug("applying templete:" + path)).map(MergerMojo::loadProperties) .forEach(properties::putAll); if (Files.exists(mainProperty)) { logger.debug("applying main file:" + mainProperty); properties.putAll(loadProperties(mainProperty)); } pathListEntry.getValue().stream().filter(path -> isLocalProperties(path.getFileName().toString())) .peek(path -> logger.debug("applying local properties:" + path)) .map(MergerMojo::loadProperties).forEach(properties::putAll); try (OutputStream outputStream = Files.newOutputStream(mainProperty)) { properties.store(outputStream, "Generated by 'property-merger-maven-plugin'"); } if (deleteSourceFiles) { pathListEntry.getValue().stream().filter((path) -> !mainProperty.equals(path)).forEach(path -> { try { Files.deleteIfExists(path); } catch (IOException e) { logger.warn("Cannot delete file: " + path); } }); } } } catch (IOException e) { throw new MojoExecutionException("Cannot process file", e); } }