List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:org.codehaus.mojo.license.ArtifactHelper.java
License:Open Source License
protected static boolean isExcludable(Log log, Artifact project, Pattern excludedGroupPattern, Pattern excludedArtifactPattern) { // check if the groupId of the project should be included if (excludedGroupPattern != null) { // we have some defined license filters try {// w w w . ja v a2 s . c o m Matcher matchGroupId = excludedGroupPattern.matcher(project.getGroupId()); if (matchGroupId.find()) { if (log.isDebugEnabled()) { log.debug("Exclude " + project.getGroupId()); } return true; } } catch (PatternSyntaxException e) { log.warn(String.format(INVALIDE_PATTERN_MESSAGE, excludedGroupPattern.pattern())); } } // check if the artifactId of the project should be included if (excludedArtifactPattern != null) { // we have some defined license filters try { Matcher matchGroupId = excludedArtifactPattern.matcher(project.getArtifactId()); if (matchGroupId.find()) { if (log.isDebugEnabled()) { log.debug("Exclude " + project.getArtifactId()); } return true; } } catch (PatternSyntaxException e) { log.warn(String.format(INVALIDE_PATTERN_MESSAGE, excludedArtifactPattern.pattern())); } } return false; }
From source file:org.codehaus.mojo.license.LicenseMap.java
License:Open Source License
public SortedSet<MavenProject> getUnsafeDependencies() { Log log = getLog(); // get unsafe dependencies (says with no license) SortedSet<MavenProject> unsafeDependencies = get(getUnknownLicenseMessage()); if (log.isDebugEnabled()) { if (CollectionUtils.isEmpty(unsafeDependencies)) { log.debug("There is no dependency with no license from poms."); } else {//from w ww.j a v a 2s .com log.debug("There is " + unsafeDependencies.size() + " dependencies with no license from poms : "); for (MavenProject dep : unsafeDependencies) { // no license found for the dependency log.debug(" - " + ArtifactHelper.getArtifactId(dep.getArtifact())); } } } return unsafeDependencies; }
From source file:org.codehaus.mojo.nbm.AbstractNbmMojo.java
License:Apache License
static boolean matchesLibrary(Artifact artifact, List<String> libraries, ExamineManifest depExaminator, Log log, boolean useOsgiDependencies) { String artId = artifact.getArtifactId(); String grId = artifact.getGroupId(); String id = grId + ":" + artId; boolean explicit = libraries.remove(id); if (explicit) { log.debug(id + " included as module library, explicitly declared in module descriptor."); return explicit; }/* ww w . ja v a 2 s . c o m*/ if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) || Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) { log.debug(id + " omitted as module library, has scope 'provided/system'"); return false; } if ("nbm".equals(artifact.getType())) { return false; } if (depExaminator.isNetBeansModule() || (useOsgiDependencies && depExaminator.isOsgiBundle())) { //TODO I can see how someone might want to include an osgi bundle as library, not dependency. // I guess it won't matter much in 6.9+, in older versions it could be a problem. return false; } log.debug(id + " included as module library, squeezed through all the filters."); return true; }
From source file:org.codehaus.mojo.nbm.AbstractNbmMojo.java
License:Apache License
static Dependency resolveNetBeansDependency(Artifact artifact, List<Dependency> deps, ExamineManifest manifest, Log log) { String artId = artifact.getArtifactId(); String grId = artifact.getGroupId(); String id = grId + ":" + artId; for (Dependency dep : deps) { if (id.equals(dep.getId())) { if (manifest.isNetBeansModule()) { return dep; } else { if (dep.getExplicitValue() != null) { return dep; }// w w w . j a v a 2 s . c o m log.warn(id + " declared as module dependency in descriptor, but not a NetBeans module"); return null; } } } if ("nbm".equals(artifact.getType())) { Dependency dep = new Dependency(); dep.setId(id); dep.setType("spec"); log.debug("Adding nbm module dependency - " + id); return dep; } if (manifest.isNetBeansModule()) { Dependency dep = new Dependency(); dep.setId(id); dep.setType("spec"); log.debug("Adding direct NetBeans module dependency - " + id); return dep; } return null; }
From source file:org.codehaus.mojo.nbm.AbstractNbmMojo.java
License:Apache License
static List<ModuleWrapper> getModuleDependencyArtifacts(DependencyNode treeRoot, NetBeansModule module, Dependency[] customDependencies, MavenProject project, Map<Artifact, ExamineManifest> examinerCache, List<Artifact> libraryArtifacts, Log log, boolean useOsgiDependencies) throws MojoExecutionException { List<Dependency> deps = new ArrayList<Dependency>(); if (customDependencies != null) { deps.addAll(Arrays.asList(customDependencies)); }/* ww w . j av a 2s . c om*/ if (module != null && !module.getDependencies().isEmpty()) { log.warn( "dependencies in module descriptor are deprecated, use the plugin's parameter moduleDependencies"); //we need to make sure a dependency is not twice there, module deps override the config (as is the case with other //configurations) for (Dependency d : module.getDependencies()) { Dependency found = null; for (Dependency d2 : deps) { if (d2.getId().equals(d.getId())) { found = d2; break; } } if (found != null) { deps.remove(found); } deps.add(d); } } List<ModuleWrapper> include = new ArrayList<ModuleWrapper>(); @SuppressWarnings("unchecked") List<Artifact> artifacts = project.getCompileArtifacts(); for (Artifact artifact : artifacts) { if (libraryArtifacts.contains(artifact)) { continue; } ExamineManifest depExaminator = examinerCache.get(artifact); if (depExaminator == null) { depExaminator = new ExamineManifest(log); depExaminator.setArtifactFile(artifact.getFile()); depExaminator.checkFile(); examinerCache.put(artifact, depExaminator); } Dependency dep = resolveNetBeansDependency(artifact, deps, depExaminator, log); if (dep != null) { ModuleWrapper wr = new ModuleWrapper(); wr.dependency = dep; wr.artifact = artifact; wr.transitive = false; //only direct deps matter to us.. if (depExaminator.isNetBeansModule() && artifact.getDependencyTrail().size() > 2) { log.debug(artifact.getId() + " omitted as NetBeans module dependency, not a direct one. Declare it in the pom for inclusion."); wr.transitive = true; } include.add(wr); } else { if (useOsgiDependencies && depExaminator.isOsgiBundle()) { ModuleWrapper wr = new ModuleWrapper(); wr.osgi = true; String id = artifact.getGroupId() + ":" + artifact.getArtifactId(); for (Dependency depe : deps) { if (id.equals(depe.getId())) { wr.dependency = depe; } } boolean print = false; if (wr.dependency == null) { Dependency depe = new Dependency(); depe.setId(id); depe.setType("spec"); wr.dependency = depe; print = true; } wr.artifact = artifact; wr.transitive = false; //only direct deps matter to us.. if (artifact.getDependencyTrail().size() > 2) { log.debug(artifact.getId() + " omitted as NetBeans module OSGi dependency, not a direct one. Declare it in the pom for inclusion."); wr.transitive = true; } else { if (print) { log.info("Adding OSGi bundle dependency - " + id); } } include.add(wr); } } } return include; }
From source file:org.codehaus.mojo.nbm.CreateClusterAppMojo.java
License:Apache License
static void assignClustersToBundles(List<BundleTuple> bundles, Set<String> wrappedBundleCNBs, Map<String, Set<String>> clusterDependencies, Map<String, Set<String>> cluster2depClusters, Log log) { List<BundleTuple> toProcess = new ArrayList<>(); List<BundleTuple> known = new ArrayList<>(); for (Iterator<BundleTuple> it = bundles.iterator(); it.hasNext();) { BundleTuple ent = it.next();/*from w w w . j ava 2 s .c om*/ Artifact art = ent.artifact; ExamineManifest ex = ent.manifest; String spec = ex.getModule(); //null check for tests //have a way to force inclusion of osgi items. Direct dependency is never wrapped by modules. if (art != null && art.getDependencyTrail().size() > 2 && wrappedBundleCNBs.contains(spec)) { // we already have this one as a wrapped module. log.debug("Not including bundle " + art.getDependencyConflictId() + ". It is already included in a NetBeans module"); it.remove(); continue; } List<String> depclusters = findByDependencies(clusterDependencies, spec); if (depclusters.size() == 1) { ent.cluster = depclusters.get(0); known.add(ent); } else if (depclusters.isEmpty()) { toProcess.add(ent); } else { //more results.. from 2 dependent clusters pick the one that is lower in the stack. for (Iterator<String> it2 = depclusters.iterator(); it2.hasNext();) { String s = it2.next(); Set<String> depsCs = cluster2depClusters.get(s); boolean removeS = false; for (String sDep : depclusters) { if (s.equals(sDep)) { continue; } if (depsCs != null && depsCs.contains(sDep)) { removeS = true; } } if (removeS) { it2.remove(); } } ent.cluster = depclusters.get(0); //TODO still some free room there, what if they don't directly depend on each other but still are related known.add(ent); } } if (!toProcess.isEmpty()) { walkKnownBundleDependenciesDown(known, toProcess); } if (!toProcess.isEmpty()) { walkKnownBundleDependenciesUp(known, toProcess); } }
From source file:org.codehaus.mojo.pomtools.wrapper.reflection.BeanFields.java
License:Apache License
public BeanFields(String fieldFullName, Object objectToInspect) { this.fieldFullName = fieldFullName; PomToolsPluginContext context = PomToolsPluginContext.getInstance(); Log log = context.getLog(); PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(objectToInspect); for (int i = 0; i < descriptors.length; i++) { PropertyDescriptor pd = descriptors[i]; FieldConfiguration config = context .getFieldConfiguration(ModelHelper.buildFullName(fieldFullName, pd.getName())); if (pd.getWriteMethod() != null && (config == null || !config.isIgnore())) { if (log.isDebugEnabled()) { log.debug("Property: " + ModelHelper.buildFullName(fieldFullName, pd.getName()) + " => " + pd.getPropertyType().getName()); }/*from w w w.j a v a 2s .c o m*/ if (pd.getPropertyType().equals(String.class)) { add(new StringField(fieldFullName, pd.getName())); } else if (pd.getPropertyType().equals(boolean.class)) { add(new BooleanField(fieldFullName, pd.getName())); } else if (pd.getPropertyType().equals(List.class)) { addListField(pd, objectToInspect); } else if (pd.getPropertyType().equals(Properties.class)) { add(new PropertiesBeanField(fieldFullName, pd.getName())); } else { add(new CompositeField(fieldFullName, pd.getName(), pd.getPropertyType())); } } } }
From source file:org.codehaus.mojo.rpm.AbstractRPMMojo.java
License:Apache License
/** * Check the parameters for validity./*from w ww . ja v a2 s .com*/ * * @throws MojoFailureException if an invalid parameter is found * @throws MojoExecutionException if an error occurs reading a script */ private void checkParams(RPMHelper helper) throws MojoExecutionException, MojoFailureException { Log log = getLog(); // Retrieve any versions set by the VersionMojo if (versionProperty != null) { String projversion = this.project.getProperties().getProperty(versionProperty); if (projversion != null) { this.projversion = projversion; } } if (releaseProperty != null) { String release = this.project.getProperties().getProperty(releaseProperty); if (release != null) { this.release = release; } } // calculate versions if neccessary, check for existing maven modifier and split them accordingly if (this.projversion == null || this.release == null || this.projversion.contains("-")) { // including -SNAPSHOT and 1-34 final VersionHelper.Version version = new VersionHelper(this).calculateVersion(); this.projversion = version.version; this.release = version.release; } log.debug("project version = " + this.projversion); log.debug("project release = " + this.release); // evaluate needarch and populate targetArch if (needarch == null || needarch.length() == 0 || "false".equalsIgnoreCase(needarch)) { targetArch = "noarch"; } else if ("true".equalsIgnoreCase(needarch)) { targetArch = helper.getArch(); } else { targetArch = needarch; } log.debug("targetArch = " + targetArch); // provide default targetOS if value not given if (targetOS == null || targetOS.length() == 0) { targetOS = Os.OS_NAME; } log.debug("targetOS = " + targetOS); if (targetVendor == null || targetVendor.length() == 0) { targetVendor = helper.getHostVendor(); } log.debug("targetVendor = " + targetVendor); // Various checks in the mappings for (Mapping map : mappings) { if (map.getDirectory() == null) { throw new MojoFailureException("<mapping> element must contain the destination directory"); } if (map.getSources() != null) { for (Source src : map.getSources()) { if (src.getLocation() == null) { throw new MojoFailureException("<mapping><source> tag must contain the source directory"); } } } } if ((changelog == null) && (changelogFile != null)) { if (!changelogFile.exists()) { log.debug(changelogFile.getAbsolutePath() + " does not exist - ignoring"); } else { try { StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(new FileReader(changelogFile)); while (br.ready()) { String line = br.readLine(); sb.append(line); sb.append('\n'); } br.close(); changelog = sb.toString(); } catch (Throwable t) { throw new MojoExecutionException("Unable to read " + changelogFile.getAbsolutePath(), t); } } } // generate license text if not set if (license == null) { license = generateDefaultCopyrightText(); } // if this package obsoletes any packages, make sure those packages are added to the provides list if (obsoletes != null && "true".equals(System.getProperty("disable.mrpm24"))) { //this block is incorrectly implemented, however we want to provide capability // to enable this if needed in the next few releases, after that remove it completely if (provides == null) { provides = obsoletes; } else { provides.addAll(obsoletes); } } if (!repackJars) { if (defineStatements == null) { defineStatements = new ArrayList<String>(); } defineStatements.add("__jar_repack 0"); } processDefineStatements(); }
From source file:org.codehaus.mojo.rpm.FileHelper.java
License:Apache License
/** * Make a list of the dependencies to package in this mapping. * * @param d The artifact mapping information * @return The list of artifacts to package *//*from www . j a va2 s. c o m*/ private List<Artifact> selectDependencies(Dependency d) { List<Artifact> retval = new ArrayList<Artifact>(); List<Artifact> inc = d.getIncludes(); List<Artifact> exc = d.getExcludes(); @SuppressWarnings("unchecked") Set<Artifact> deps = mojo.project.getArtifacts(); if (deps == null || deps.isEmpty()) { return retval; } final Log log = mojo.getLog(); for (Artifact pdep : deps) { log.debug("Dependency is " + pdep + " at " + pdep.getFile()); if (!depMatcher(pdep, exc)) { log.debug("--> not excluded"); if ((inc == null) || (depMatcher(pdep, inc))) { log.debug("--> included"); retval.add(pdep); } } } return retval; }
From source file:org.codehaus.mojo.rpm.FileHelper.java
License:Apache License
/** * Determine if the dependency matches an include or exclude list. * * @param dep The dependency to check//from w w w .j av a 2s.co m * @param list The list to check against * @return <code>true</code> if the dependency was found on the list */ private boolean depMatcher(Artifact dep, List<Artifact> list) { if (list == null) { // No list, not possible to match return false; } final Log log = mojo.getLog(); for (Artifact item : list) { log.debug("Compare " + dep + " to " + item); final String groupId = item.getGroupId(); if (StringUtils.isEmpty(groupId) || "*".equals(groupId) || groupId.equals(dep.getGroupId())) { log.debug("... Group matches"); final String artifactId = item.getArtifactId(); if (StringUtils.isEmpty(artifactId) || "*".equals(artifactId) || artifactId.equals(dep.getArtifactId())) { log.debug("... Artifact matches"); // ArtifactVersion av = item.getVersionRange().matchVersion( dep.getAvailableVersions() ); try { if (item.getVersionRange().containsVersion(dep.getSelectedVersion())) { log.debug("... Version matches"); if (item.getType().isEmpty()) { log.debug("... Type is empty"); return true; } else if (item.getType().equals(dep.getType())) { log.debug("... Type matches"); if (item.getClassifier().isEmpty()) { log.debug("... Classifier is empty"); return true; } else if (item.getClassifier().equals(dep.getClassifier())) { log.debug("... Classifier matches"); return true; } } } } catch (OverConstrainedVersionException ocve) { log.debug("... caught OverConstrainedVersionException"); } } } } // Not found return false; }