List of usage examples for org.apache.maven.plugin.logging Log warn
void warn(Throwable error);
From source file:org.grouplens.lenskit.eval.maven.MavenLogAppender.java
License:Open Source License
@Override protected void append(E event) { Log log = mavenLogger.get(); if (log == null) { return;/*from ww w. j av a2 s . c o m*/ } String fmt = layout.doLayout(event); Level lvl = event.getLevel(); if (lvl.isGreaterOrEqual(Level.ERROR)) { log.error(fmt); } else if (lvl.isGreaterOrEqual(Level.WARN)) { log.warn(fmt); } else if (lvl.isGreaterOrEqual(Level.INFO)) { log.info(fmt); } else { log.debug(fmt); } }
From source file:org.hardisonbrewing.maven.core.cli.LogStreamConsumer.java
License:Open Source License
@Override public void consumeLine(String line) { Log log = JoJoMojo.getMojo().getLog(); switch (level) { case LEVEL_INFO: log.info(line);/*from www.ja v a 2 s. c o m*/ break; case LEVEL_WARN: log.warn(line); break; case LEVEL_ERROR: log.error(line); break; default: log.debug(line); } }
From source file:org.hsc.novelSpider.bundleplugin.BundlePlugin.java
License:Apache License
protected static void addMavenSourcePath(MavenProject currentProject, Analyzer analyzer, Log log) { // pass maven source paths onto BND analyzer StringBuilder mavenSourcePaths = new StringBuilder(); if (currentProject.getCompileSourceRoots() != null) { for (Iterator<String> i = currentProject.getCompileSourceRoots().iterator(); i.hasNext();) { if (mavenSourcePaths.length() > 0) { mavenSourcePaths.append(','); }//from w w w . j a v a2s . c o m mavenSourcePaths.append(i.next()); } } final String sourcePath = (String) analyzer.getProperty(Analyzer.SOURCEPATH); if (sourcePath != null) { if (sourcePath.indexOf(MAVEN_SOURCES) >= 0) { // if there is no maven source path, we do a special treatment and replace // every occurance of MAVEN_SOURCES and a following comma with an empty string if (mavenSourcePaths.length() == 0) { String cleanedSource = removeTagFromInstruction(sourcePath, MAVEN_SOURCES); if (cleanedSource.length() > 0) { analyzer.setProperty(Analyzer.SOURCEPATH, cleanedSource); } else { analyzer.unsetProperty(Analyzer.SOURCEPATH); } } else { String combinedSource = StringUtils.replace(sourcePath, MAVEN_SOURCES, mavenSourcePaths.toString()); analyzer.setProperty(Analyzer.SOURCEPATH, combinedSource); } } else if (mavenSourcePaths.length() > 0) { log.warn(Analyzer.SOURCEPATH + ": overriding " + mavenSourcePaths + " with " + sourcePath + " (add " + MAVEN_SOURCES + " if you want to include the maven sources)"); } } else if (mavenSourcePaths.length() > 0) { analyzer.setProperty(Analyzer.SOURCEPATH, mavenSourcePaths.toString()); } }
From source file:org.ihtsdo.mojo.maven.MojoUtil.java
License:Apache License
public static boolean alreadyRun(Log l, String input, Class<?> targetClass, File targetDir) throws NoSuchAlgorithmException, IOException { Sha1HashCodeGenerator generator = new Sha1HashCodeGenerator(); if (input == null) { input = targetClass.getName();// ww w . j av a 2 s . co m l.warn("Input is NULL. Using mojo class name instead..."); } generator.add(input); String hashCode = generator.getHashCode(); File goalFileDirectory = new File(targetDir, "completed-mojos"); File goalFile = new File(goalFileDirectory, hashCode); // check to see if this goal has been executed previously if (!goalFile.exists()) { // create a new file to indicate this execution has completed goalFileDirectory.mkdirs(); goalFile.createNewFile(); } else { l.info("Previously executed: " + goalFile.getAbsolutePath() + "\nNow stopping."); StringOutputStream sos = new StringOutputStream(); PrintStream ps = new PrintStream(sos); l.info("Properties: " + sos.toString()); return true; } return false; }
From source file:org.ihtsdo.mojo.maven.Transform.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { Log logger = getLog(); logger.info("starting transform: " + Arrays.asList(outputSpecs)); // calculate the SHA-1 hashcode for this mojo based on input Sha1HashCodeGenerator generator;// ww w . j a va 2s. co m String hashCode = ""; try { generator = new Sha1HashCodeGenerator(); for (int i = 0; i < outputSpecs.length; i++) { generator.add(outputSpecs[i]); } generator.add(idFileLoc); generator.add(appendIdFiles); generator.add(idEncoding); generator.add(outputColumnDelimiter); generator.add(outputCharacterDelimiter); Iterator iter = sourceRoots.iterator(); while (iter.hasNext()) { generator.add(iter.next()); } hashCode = generator.getHashCode(); } catch (NoSuchAlgorithmException e) { System.out.println(e); } File goalFileDirectory = new File("target" + File.separator + "completed-mojos"); File goalFile = new File(goalFileDirectory, hashCode); // check to see if this goal has been executed previously if (!goalFile.exists()) { logger.info("goal has not run before"); // hasn't been executed previously try { for (OutputSpec outSpec : outputSpecs) { logger.info("processing " + outSpec); I_TransformAndWrite[] writers = outSpec.getWriters(); for (I_TransformAndWrite tw : writers) { File outputFile = new File(tw.getFileName()); outputFile.getParentFile().mkdirs(); FileOutputStream fos = new FileOutputStream(outputFile, tw.append()); OutputStreamWriter osw = new OutputStreamWriter(fos, tw.getOutputEncoding()); BufferedWriter bw = new BufferedWriter(osw); tw.init(bw, this); } if (outSpec.getConstantSpecs() != null) { for (I_ReadAndTransform constantTransform : outSpec.getConstantSpecs()) { constantTransform.setup(this); constantTransform.transform("test"); for (I_TransformAndWrite tw : writers) { tw.addTransform(constantTransform); } } } InputFileSpec[] inputSpecs = outSpec.getInputSpecs(); for (InputFileSpec spec : inputSpecs) { nextColumnId = 0; Map<Integer, Set<I_ReadAndTransform>> columnTransformerMap = new HashMap<Integer, Set<I_ReadAndTransform>>(); logger.info("Now processing file spec:\n\n" + spec); for (I_ReadAndTransform t : spec.getColumnSpecs()) { t.setup(this); Set<I_ReadAndTransform> transformerSet = (Set<I_ReadAndTransform>) columnTransformerMap .get((Integer) t.getColumnId()); if (transformerSet == null) { transformerSet = new HashSet<I_ReadAndTransform>(); columnTransformerMap.put((Integer) t.getColumnId(), transformerSet); } transformerSet.add(t); for (I_TransformAndWrite tw : writers) { tw.addTransform(t); } } File inputFile = normalize(spec); if (inputFile != null) { if (inputFile.length() == 0) { logger.warn("skipping 0 length file " + inputFile); continue; } } else { throw new MojoFailureException("Spec cannot be normalized. Does the input file exist?"); } FileInputStream fs = new FileInputStream(inputFile); InputStreamReader isr = new InputStreamReader(fs, spec.getInputEncoding()); BufferedReader br = new BufferedReader(isr); StreamTokenizer st = new StreamTokenizer(br); st.resetSyntax(); st.wordChars('\u001F', '\u00FF'); st.ordinaryChar(spec.getInputColumnDelimiter()); st.eolIsSignificant(true); if (spec.skipFirstLine()) { skipLine(st); } int tokenType = st.nextToken(); int rowCount = 0; while (tokenType != StreamTokenizer.TT_EOF) { int currentColumn = 0; while (tokenType != '\r' && tokenType != '\n' && tokenType != StreamTokenizer.TT_EOF) { /* * if (rowCount >= spec.getDebugRowStart() && * rowCount <= spec.getDebugRowEnd()) { * getLog().info("Transforming column: " + * currentColumn + " string token: " + st.sval); * getLog().info("Current row:" + rowCount); * } */ if (columnTransformerMap.get((Integer) currentColumn) == null) { } else { for (Object tObj : (Set) columnTransformerMap.get((Integer) currentColumn)) { I_ReadAndTransform t = (I_ReadAndTransform) tObj; /* * if (rowCount >= * spec.getDebugRowStart() && rowCount * <= spec.getDebugRowEnd()) { * * * * * * * getLog().info("Transform for column: " * + currentColumn + " is: " + t); * } */ if (tokenType == spec.getInputColumnDelimiter().charValue()) { t.transform(null); } else { t.transform(st.sval); } /* * if (rowCount >= * spec.getDebugRowStart() && rowCount * <= spec.getDebugRowEnd()) { * getLog().info("Transform: " + t + * " result: " + result); * } */ } } tokenType = st.nextToken(); if (spec.getInputColumnDelimiter().charValue() == tokenType) { // CR or LF tokenType = st.nextToken(); if (spec.getInputColumnDelimiter().charValue() == tokenType) { st.pushBack(); } } currentColumn++; } for (I_TransformAndWrite tw : writers) { tw.processRec(); } switch (tokenType) { case '\r': // is CR // LF tokenType = st.nextToken(); break; case '\n': // LF break; case StreamTokenizer.TT_EOF: // End of file break; default: throw new Exception( "There are more columns than transformers. Tokentype: " + tokenType); } rowCount++; if (rowCount % PROGRESS_LOGGING_SIZE == 0) { logger.info( "processed " + rowCount + " rows of file " + inputFile.getAbsolutePath()); } // Beginning of loop tokenType = st.nextToken(); } fs.close(); logger.info("Processed: " + rowCount + " rows."); } logger.info("closing writers"); int count = 0; for (I_TransformAndWrite tw : writers) { logger.info("closing " + ++count + " of " + writers.length); tw.close(); } logger.info("cleanup inputs"); count = 0; for (InputFileSpec ifs : inputSpecs) { logger.info("cleaning input spec " + ++count + " of " + inputSpecs.length); int transformCount = 0; I_ReadAndTransform[] columnSpecs = ifs.getColumnSpecs(); for (I_ReadAndTransform t : columnSpecs) { logger.info("cleaning column spec " + ++transformCount + " of " + columnSpecs.length); t.cleanup(this); } } logger.info("cleanup inputs - done"); } if (uuidToNativeMap != null) { logger.info("ID map is not null."); // write out id map... File outputFileLoc = new File(idFileLoc); outputFileLoc.getParentFile().mkdirs(); File file = new File(outputFileLoc, "uuidToNative.txt"); FileOutputStream fos = new FileOutputStream(file, appendIdFiles); OutputStreamWriter osw = new OutputStreamWriter(fos, idEncoding); BufferedWriter bw = new BufferedWriter(osw); if (includeHeader) { bw.append("UUID"); bw.append(outputColumnDelimiter); bw.append("NID"); bw.append("\n"); } int rowcount = 0; for (Iterator i = uuidToNativeMap.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Entry) i.next(); bw.append(entry.getKey().toString()); bw.append(outputColumnDelimiter); bw.append(entry.getValue().toString()); bw.append("\n"); rowcount++; if (rowcount++ % PROGRESS_LOGGING_SIZE == 0) { logger.info("processed " + rowcount + " rows of file " + file.getAbsolutePath()); } } bw.close(); } logger.info("writing out the source to uuid map"); for (Iterator keyItr = sourceToUuidMapMap.keySet().iterator(); keyItr.hasNext();) { String key = (String) keyItr.next(); File outputFileLoc = new File(idFileLoc); outputFileLoc.getParentFile().mkdirs(); File file = new File(outputFileLoc, key + "ToUuid.txt"); FileOutputStream fos = new FileOutputStream(file, appendIdFiles); OutputStreamWriter osw = new OutputStreamWriter(fos, idEncoding); BufferedWriter bw = new BufferedWriter(osw); if (includeHeader) { bw.append(key.toUpperCase()); bw.append(outputColumnDelimiter); bw.append("UUID"); bw.append("\n"); } Map idMap = (Map) sourceToUuidMapMap.get(key); int rowcount = 0; for (Iterator i = idMap.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Entry) i.next(); bw.append(entry.getKey().toString()); bw.append(outputColumnDelimiter); bw.append(entry.getValue().toString()); bw.append("\n"); rowcount++; if (rowcount++ % PROGRESS_LOGGING_SIZE == 0) { logger.info("processed " + rowcount + " rows of file " + file.getAbsolutePath()); } } bw.close(); } // create a new file to indicate this execution has completed try { goalFileDirectory.mkdirs(); goalFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } logger.info("execution complete"); } catch (FileNotFoundException e) { throw new MojoExecutionException(e.getMessage(), e); } catch (UnsupportedEncodingException e) { throw new MojoExecutionException(e.getMessage(), e); } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } } else { logger.info("Skipping goal - executed previously."); } }
From source file:org.jahia.utils.maven.plugin.osgi.FindPackageUsesMojo.java
License:Open Source License
public static Map<String, Map<String, Artifact>> findPackageUses(List<String> packageNames, Set<Artifact> artifacts, MavenProject project, File buildOutputDirectory, boolean searchInDependencies, Log log) { final Map<String, Map<String, Artifact>> packageResults = new TreeMap<String, Map<String, Artifact>>(); log.info("Scanning project build directory..."); if (buildOutputDirectory.exists()) { findPackageUsesInDirectory(packageNames, project, log, packageResults, buildOutputDirectory); }//from www. j a v a 2 s. c o m if (!searchInDependencies) { return packageResults; } log.info("Scanning project dependencies..."); for (Artifact artifact : artifacts) { if (artifact.isOptional()) { log.debug("Processing optional dependency " + artifact + "..."); } if (artifact.getType().equals("pom")) { log.warn("Skipping POM artifact " + artifact); continue; } if (!artifact.getType().equals("jar")) { log.warn("Found non JAR artifact " + artifact); } findPackageUsesInArtifact(packageNames, project, log, packageResults, artifact); } return packageResults; }
From source file:org.jahia.utils.maven.plugin.osgi.FindPackageUsesMojo.java
License:Open Source License
private static Set<String> findClassesThatUsePackage(File jarFile, String packageName, MavenProject project, Log log) { Set<String> classesThatHaveDependency = new TreeSet<String>(); JarInputStream jarInputStream = null; if (jarFile == null) { log.warn("File is null !"); return classesThatHaveDependency; }//from w w w.j a va 2s.com if (!jarFile.exists()) { log.warn("File " + jarFile + " does not exist !"); return classesThatHaveDependency; } log.debug("Scanning JAR " + jarFile + "..."); try { classesThatHaveDependency = ClassDependencyTracker.findDependencyInJar(jarFile, packageName, project.getTestClasspathElements()); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (DependencyResolutionRequiredException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } finally { IOUtils.closeQuietly(jarInputStream); } return classesThatHaveDependency; }
From source file:org.jahia.utils.maven.plugin.osgi.FindPackageUsesMojo.java
License:Open Source License
private static Artifact findArtifactInProject(MavenProject project, String artifactIdentifier, Log log) { List<Artifact> results = new ArrayList<Artifact>(); if (artifactMatches(project.getArtifact(), artifactIdentifier)) { results.add(project.getArtifact()); }//w ww . jav a 2 s .com for (Artifact artifact : project.getArtifacts()) { if (artifactMatches(artifact, artifactIdentifier)) { results.add(artifact); } } if (results.size() > 1) { log.warn("Found more than one matching dependency for identifier " + artifactIdentifier + ":"); for (Artifact resultArtifact : results) { log.warn(" --> " + resultArtifact.toString()); } return null; } else { if (results.size() == 1) { return results.get(0); } else { log.warn("Couldn't find project dependency for identifier " + artifactIdentifier + "!"); return null; } } }
From source file:org.jahia.utils.maven.plugin.support.AetherHelperFactory.java
License:Open Source License
private static void warnMavenVersion(Log log) { log.warn(""); log.warn("************************* DEPRECATION *************************"); log.warn("* *"); log.warn("* The version of Maven (3.0.x), you are using, is deprecated. *"); log.warn("* Please, switch to a more recent one (e.g. 3.3.x). *"); log.warn("* *"); log.warn("***************************************************************"); log.warn(""); }
From source file:org.jahia.utils.maven.plugin.support.MavenAetherHelperUtils.java
License:Open Source License
public static boolean doesJarHavePackageName(File jarFile, String packageName, Log log) { JarInputStream jarInputStream = null; if (jarFile == null) { log.warn("File is null !"); return false; }/* w ww .j a v a 2 s . c o m*/ if (!jarFile.exists()) { log.warn("File " + jarFile + " does not exist !"); return false; } log.debug("Scanning JAR " + jarFile + "..."); try { jarInputStream = new JarInputStream(new FileInputStream(jarFile)); JarEntry jarEntry = null; while ((jarEntry = jarInputStream.getNextJarEntry()) != null) { String jarPackageName = jarEntry.getName().replaceAll("/", "."); if (jarPackageName.endsWith(".")) { jarPackageName = jarPackageName.substring(0, jarPackageName.length() - 1); } if (jarPackageName.equals(packageName)) { return true; } } } catch (IOException e) { log.error(e); ; } finally { IOUtils.closeQuietly(jarInputStream); } return false; }