List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:org.gephi.maven.ModuleUtils.java
License:Apache License
protected static String getModuleDownloadPath(MavenProject topPlugin, List<MavenProject> modules, File directory, Log log) throws MojoExecutionException { File dest;/*from ww w .jav a 2 s. c o m*/ if (modules.size() > 1) { dest = new File(directory, topPlugin.getArtifactId() + "-" + topPlugin.getVersion() + ".zip"); log.debug("The plugin '" + topPlugin + "' is a suite, creating zip archive at '" + dest.getAbsolutePath() + "'"); // Verify files exist and add to archive try { ZipArchiver archiver = new ZipArchiver(); for (MavenProject module : modules) { File f = new File(directory, module.getArtifactId() + "-" + module.getVersion() + ".nbm"); if (!f.exists()) { throw new MojoExecutionException( "The NBM file '" + f.getAbsolutePath() + "' can't be found"); } archiver.addFile(f, f.getName()); log.debug(" Add file '" + f.getAbsolutePath() + "' to the archive"); } archiver.setCompress(false); archiver.setDestFile(dest); archiver.setForced(true); archiver.createArchive(); log.info("Created ZIP archive for project '" + topPlugin.getName() + "' at '" + dest.getAbsolutePath() + "'"); } catch (IOException ex) { throw new MojoExecutionException( "Something went wrong with the creation of the ZIP archive for project '" + topPlugin.getName() + "'", ex); } catch (ArchiverException ex) { throw new MojoExecutionException( "Something went wrong with the creation of the ZIP archive for project '" + topPlugin.getName() + "'", ex); } } else { dest = new File(directory, topPlugin.getArtifactId() + "-" + topPlugin.getVersion() + ".nbm"); log.debug("The plugin is not a suite, return nbm file '" + dest.getAbsolutePath() + "'"); } return dest.getName(); }
From source file:org.gephi.maven.ScreenshotUtils.java
License:Apache License
protected static List<Image> copyScreenshots(MavenProject mavenProject, File outputFolder, String urlPrefix, Log log) throws MojoExecutionException { File folder = new File(mavenProject.getBasedir(), "src/img"); if (folder.exists()) { log.debug("Folder '" + folder.getAbsolutePath() + "' exists"); // List images in folder File[] files = folder.listFiles(new FilenameFilter() { @Override/*from w w w . java 2 s .c om*/ public boolean accept(File dir, String name) { return !name.startsWith(".") && (name.endsWith(".png") || name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".gif")) && !name.contains(THUMBNAIL_SUFFIX); } }); // Sort files alphabetically Arrays.sort(files, new Comparator<File>() { @Override public int compare(File f1, File f2) { return f1.getName().compareTo(f2.getName()); } }); log.debug(files.length + " images found in source folder"); // Create dest folder if (outputFolder.mkdirs()) { log.debug("Output folder '" + outputFolder.getAbsolutePath() + "' was created"); } List<Image> images = new ArrayList<Image>(); for (File file : files) { if (file.getName().contains(" ")) { throw new MojoExecutionException("Image file '" + file.getAbsolutePath() + "' contains spaces. Please rename image and try again"); } // Read original file and copy to dest folder String fileName = file.getName().substring(0, file.getName().lastIndexOf(".")) + ".png"; File imageDestFile = new File(outputFolder, fileName); try { Thumbnails.of(file).outputFormat("png").outputQuality(0.90).resizer(Resizers.NULL).scale(1.0) .toFile(imageDestFile); } catch (IOException ex) { log.error("Can't copy image file from '" + file.getAbsolutePath() + "' to '" + imageDestFile.getAbsolutePath() + "'", ex); } Image image = new Image(); image.image = urlPrefix + fileName; images.add(image); // Thumbnail path String thumFileName = file.getName().substring(0, file.getName().lastIndexOf(".")) + THUMBNAIL_SUFFIX + ".png"; File thumbFile = new File(outputFolder, thumFileName); if (!thumbFile.exists()) { // Thumbnail creation try { Thumbnails.of(file).outputFormat("png").outputQuality(0.90).size(140, 140) .crop(Positions.CENTER).toFile(thumbFile); log.debug("Created thumbnail in file '" + thumbFile.getAbsolutePath() + "'"); image.thumbnail = urlPrefix + thumFileName; } catch (IOException ex) { log.error("Can't create thumbnail for image file '" + file.getAbsolutePath() + "'", ex); } } log.info("Attached image '" + file.getName() + "' to plugin " + mavenProject.getName()); } return images; } else { log.debug("Folder '" + folder.getAbsolutePath() + "' was not found"); } return null; }
From source file:org.glassfish.maven.plugin.command.AbstractAsadminCommand.java
License:Open Source License
protected void doReadOutput(BufferedReader reader) throws IOException { Log log = sharedContext.getLog(); while (reader.ready()) { log.info(reader.readLine()); }/*from w ww . ja v a2 s. c o m*/ }
From source file:org.glassfish.maven.plugin.command.AsadminCommand.java
License:Open Source License
public void execute(ProcessBuilder processBuilder) throws MojoExecutionException, MojoFailureException { List<String> commandLine = new ArrayList<String>(getParameters()); File binDir = new File(sharedContext.getGlassfishDirectory(), "bin"); File asadmin = new File(binDir, "asadmin"); // bnevins 9/13/11 -- the install may have both asadmin and asadmin.bat // if we are on Windows - then prefer the .bat file and explicitly set it. // o/w windows will attempt running the UNIX script which is trouble! // http://java.net/jira/browse/MAVEN_GLASSFISH_PLUGIN-5 if (System.getProperty("os.name").contains("indows")) { File asadminBat = new File(binDir, "asadmin.bat"); if (asadminBat.exists()) { asadmin = asadminBat;/*w w w. ja v a 2s . co m*/ } } commandLine.addAll(0, Arrays.asList(asadmin.getAbsolutePath(), getName(), "--echo=" + sharedContext.isEcho(), "--terse=" + sharedContext.isTerse())); Log log = sharedContext.getLog(); log.debug(commandLine.toString()); processBuilder.command(commandLine); try { int exitValue; Process process = processBuilder.start(); processOut = process.getInputStream(); processErr = process.getErrorStream(); BufferedReader outReader = new BufferedReader(new InputStreamReader(processOut)); do { try { exitValue = process.exitValue(); break; } catch (IllegalThreadStateException e) { Thread.sleep(PROCESS_LOOP_SLEEP_MILLIS); } finally { while (outReader.ready()) { log.info(outReader.readLine()); } } } while (true); if (exitValue != EXIT_SUCCESS) { BufferedReader errorReader = new BufferedReader(new InputStreamReader(processErr)); while (errorReader.ready()) { log.error(errorReader.readLine()); } String errorMessage = getErrorMessage(); log.error(errorMessage); log.error( "For more detail on what might be causing the problem try running maven with the --debug option "); log.error("or setting the maven-glassfish-plugin \"echo\" property to \"true\"."); throw new MojoFailureException(errorMessage); } } catch (IOException e) { throw new MojoExecutionException(getErrorMessage() + " IOException: " + e.getMessage()); } catch (InterruptedException e) { throw new MojoExecutionException(getErrorMessage() + " Process was interrupted: " + e.getMessage()); } }
From source file:org.glassfish.maven.plugin.CreateDomainGlassfishMojo.java
License:Open Source License
public void doExecute() throws MojoExecutionException, MojoFailureException { ProcessBuilder processBuilder = new ProcessBuilder(); Log log = getLog(); if (domain.exists()) { log.info("Domain " + domain.getName() + " exists."); if (domain.isReuse()) { log.info("Reusing it."); return; } else {/*from www .j ava 2 s . co m*/ log.info("Deleting it."); if (domain.isStarted()) { new StopDomainCommand(this, domain).execute(processBuilder); } new DeleteDomainCommand(this, domain).execute(processBuilder); } } new CreateDomainMacro(this, domain).execute(processBuilder); }
From source file:org.glassfish.maven.plugin.StartDomainMacro.java
License:Open Source License
public void execute(ProcessBuilder processBuilder) throws MojoFailureException, MojoExecutionException { if (!domain.exists()) { Log log = sharedContext.getLog(); if (sharedContext.isAutoCreate()) { log.info("Domain " + domain.getName() + " does not exist. Creating it for you."); new CreateDomainMacro(sharedContext, domain).execute(processBuilder); } else {/*w w w . j av a2 s . com*/ throw new MojoFailureException("Domain " + domain.getName() + " does not exist and \"autoCreate\" is \"false\". Try 'mvn glassfish:createDomain' first."); } } new StartDomainCommand(sharedContext, domain).execute(processBuilder); }
From source file:org.grouplens.lenskit.eval.maven.MavenLogAppender.java
License:Open Source License
/** * Set the logger for the current thread. It will be propagated down to subloggers. * @param log The Maven logger./* w ww . j av a2s. c om*/ */ public static void setLog(Log log) { mavenLogger.set(log); log.info("initializing Maven logging"); }
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 a v a 2 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); break;// ww w. ja va 2s. co m case LEVEL_WARN: log.warn(line); break; case LEVEL_ERROR: log.error(line); break; default: log.debug(line); } }
From source file:org.ihtsdo.mojo.maven.CopyDirectory.java
License:Apache License
public void execute() throws MojoExecutionException, MojoFailureException { try {//from w w w.j a v a2 s. com Log l = getLog(); l.info("Now executing CopyDirectory from: " + inputDirectory + " to: " + outputDirectory + " invisibles: " + copyInvisibles); // calculate the SHA-1 hashcode for this mojo based on input if (MojoUtil.alreadyRun(l, inputDirectory.getAbsolutePath() + outputDirectory.getAbsolutePath(), this.getClass(), targetDirectory)) { return; } FileIO.recursiveCopy(inputDirectory, outputDirectory, copyInvisibles); } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } }