List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:org.codehaus.mojo.freeform.analyser.Analyser.java
License:Apache License
/** * This method gives the <packaging>Analyser associated to the mavenProject * packaging. The returned Analyser is injected withe the given parameters. * * @param mavenProject The maven project which defines the packaging. * @param executedProject The maven prokect resulting of the phases * prerequisites. * @param localRepository The local repository of the Maven2 execution. * @param log The logging system. * @param mavenpath The path to the maven executable. * @return the <packaging>Analyser which is the one defined for the * packaging of the given mavenProject. *///from w w w . ja va 2 s . c om public static Analyser getAnalyser(final MavenProject mavenProject, final MavenProject executedProject, final ArtifactRepository localRepository, final Log log, final String mavenpath) { Analyser analyser = null; // choose the <packaging>Analyser for the given project. if ((mavenProject.getPackaging() != null) && mavenProject.getPackaging().equalsIgnoreCase("jar")) { analyser = new JarAnalyser(); } else if ((mavenProject.getPackaging() != null) && mavenProject.getPackaging().equalsIgnoreCase("maven-plugin")) { analyser = new MavenPluginAnalyser(); } else { analyser = new JarAnalyser(); } // inject the mavenProject, the executedProject, the localRepository, // the log, and the maven path to the choosen analyser. analyser.setMavenProject(mavenProject); analyser.setMavenExecutedProject(executedProject); analyser.setLocalRepository(localRepository); analyser.setLog(log); analyser.setMavenPath(mavenpath); log.info(analyser + " found"); return analyser; }
From source file:org.codehaus.mojo.jalopy.JalopyMojo.java
License:Apache License
private void logMessage(Jalopy jalopy, File currentFile) throws MojoExecutionException { Log log = getLog(); if (jalopy.getState() == Jalopy.State.OK) { log.info(currentFile + " formatted correctly."); } else if (jalopy.getState() == Jalopy.State.WARN) { log.warn(currentFile + " formatted with warnings."); } else if (jalopy.getState() == Jalopy.State.ERROR) { log.error(currentFile + " could not be formatted."); if (isFailOnError()) { throw new MojoExecutionException(currentFile + " could not be formatted."); }/*from w ww . ja v a 2 s. c om*/ } else { log.info(currentFile + " formatted with unknown state."); } }
From source file:org.codehaus.mojo.jalopy.JalopyMojo.java
License:Apache License
private Jalopy createJalopy(Jalopy jalopy) { Log log = getLog(); try {/*from w w w. j av a 2s. com*/ if (convention != null) { File conventionContents = locator.resolveLocation(convention, "jalopy-convention.xml"); Jalopy.setConvention(conventionContents); } else { log.info("Using default convention : jalopy.xml"); InputStream in = this.getClass().getClassLoader().getResourceAsStream("jalopy.xml"); Convention.importSettings(in, Convention.EXTENSION_XML); } } catch (IOException ex) { ex.printStackTrace(); } Convention settings = Convention.getInstance(); jalopy.setFileFormat(getFileFormat()); jalopy.setInspect(settings.getBoolean(ConventionKeys.INSPECTOR, ConventionDefaults.INSPECTOR)); if (!getHistory().equalsIgnoreCase("none")) { jalopy.setHistoryPolicy(History.Policy.valueOf(getHistory())); } History.Method historyMethod = History.Method .valueOf(settings.get(ConventionKeys.HISTORY_METHOD, ConventionDefaults.HISTORY_METHOD)); jalopy.setHistoryMethod(historyMethod); jalopy.setBackup(settings.getInt(ConventionKeys.BACKUP_LEVEL, ConventionDefaults.BACKUP_LEVEL) > 0); jalopy.setForce(settings.getBoolean(ConventionKeys.FORCE_FORMATTING, ConventionDefaults.FORCE_FORMATTING)); jalopy.setEncoding(encoding); return jalopy; }
From source file:org.codehaus.mojo.javascript.titanium.TitaniumBuilder.java
License:Open Source License
/** * Launch the android emulator and start the simulator after. * * @param projectName The project name./* w w w .ja v a 2 s . com*/ * @param tiProjectDirectory The directory containing the titanium project files. * @param appId The Titanium application id. * <p>Must use the <code>com.company.name</code> format and not containing -.</p> * @param androidAPI The API to use to build the application. * @param androidDeviceAPI The API the android emulator should use. * @param androidDeviceSkin The skin of the android emulator to use. * @param androidDeviceWait The interval between the emulator launch and the simulator launch. * In milliseconds. * @param log The Maven logger * @throws MojoFailureException When the builder process return an error. * @throws MojoExecutionException When an error occurs during the call. * @throws IOException When an error occurs during the call. * @throws InterruptedException When an error occurs during the call. */ public void launchOnAndroidEmulator(String projectName, File tiProjectDirectory, String appId, String androidAPI, String androidDeviceAPI, String androidDeviceSkin, Long androidDeviceWait, Log log) throws MojoFailureException, MojoExecutionException, IOException, InterruptedException { if (TitaniumUtils.createAvd(androidSdk, androidDeviceAPI, androidDeviceSkin, log)) { log.info("AVD created for " + androidDeviceAPI + " " + androidDeviceSkin); } boolean isEmulatorRunning = false; try { isEmulatorRunning = TitaniumUtils.isAndroidEmulatorRunning(androidSdk); } catch (Throwable t) { log.error("Unable to retrieve launched emulators", t); } if (!isEmulatorRunning) { log.info("Launching emulator"); ProcessBuilder emulatorBuilder = createAndroidBuilderProcess("emulator", projectName, tiProjectDirectory.getAbsolutePath(), appId, androidDeviceAPI, androidDeviceSkin); AndroidEmulatorThread emulatorThread = new AndroidEmulatorThread(emulatorBuilder, log); emulatorThread.start(); log.info("Waiting for emulator start (" + androidDeviceWait + " ms.)"); Thread.sleep(androidDeviceWait); } else { log.info("Skipping emulator launching."); } log.info("Launching simulator"); ProcessBuilder simulatorBuilder = createAndroidBuilderProcess("simulator", projectName, tiProjectDirectory.getAbsolutePath(), appId, androidAPI, androidDeviceSkin); //simulatorBuilder.redirectErrorStream(true); Process simulator = simulatorBuilder.start(); logProcess(simulator, log, null, true); log.info("Waiting for simulator end"); simulator.waitFor(); log.info("done"); if (simulator.exitValue() != 0) { throw new MojoFailureException("The titanium builder failed"); } }
From source file:org.codehaus.mojo.javascript.titanium.TitaniumBuilder.java
License:Open Source License
/** * Launch the specified titanium project on an iOs device. * @param iosVersion The iOS version to use to build the application. * @param tiProjectDirectory The titanium project directory. * @param appId The titanium application identifier. * @param projectName The project name./*from w w w . j av a2s . c o m*/ * @param appuuid The project uuid * @param distName The project dist name. * @param family The family to use when building the project. * @param log The Maven logger. * @throws MojoFailureException When the builder process return an error. * @throws MojoExecutionException When an error occured while launching on the device. */ public void launchIphoneDevice(String iosVersion, File tiProjectDirectory, String appId, String projectName, String appuuid, String distName, String family, Log log) throws MojoExecutionException, MojoFailureException { if (iosBuilder == null) { throw new MojoExecutionException("Unable to retrieve the iphone builder"); } ProcessBuilder pb = new ProcessBuilder(iosBuilder.getAbsolutePath(), "install", iosVersion, tiProjectDirectory.getAbsolutePath(), appId, projectName, appuuid, distName, family); // The first call may fail log.info("ProcessBuilder: " + getProcessBuilderString(pb)); boolean relaunch = false; int result; try { StringBuilder logContent = new StringBuilder(); Process p = pb.start(); TitaniumBuilder.logProcess(p, log, logContent, false); p.waitFor(); result = p.exitValue(); if (failOnTiapp(tiProjectDirectory.getAbsolutePath(), logContent.toString())) { relaunch = true; } } catch (Throwable t) { throw new MojoExecutionException("Error while building iphone", t); } if (relaunch) { log.warn("Relaunching builder as it failed on missing tiapp.xml"); try { Process p = pb.start(); TitaniumBuilder.logProcess(p, log); p.waitFor(); result = p.exitValue(); } catch (Throwable t) { throw new MojoExecutionException("Error while building iphone", t); } } if (result != 0) { throw new MojoFailureException("The titanium builder failed"); } }
From source file:org.codehaus.mojo.javascript.titanium.TitaniumBuilder.java
License:Open Source License
/** * Launch a titanium project on an iOs simulator. * @param iosVersion The ios version to use to build the application. * @param tiProjectDirectory The titanium project directory. * @param projectName The name of the project. * @param family The family to use to build the application. * @param simulatorFamily family The family of the simulator ("universal" translates to "iphone"). * @param log The maven logger.// www . jav a 2 s . co m * @throws MojoFailureException When the builder process return an error. * @throws MojoExecutionException When an error occurs during the simulator process. */ public void launchIphoneEmulator(String iosVersion, String tiProjectDirectory, String projectName, String family, String simulatorFamily, Log log) throws MojoFailureException, MojoExecutionException { if (iosBuilder == null) { throw new MojoExecutionException("Unable to retrieve the iphone builder"); } ProcessBuilder pb = new ProcessBuilder(iosBuilder.getAbsolutePath(), "simulator", iosVersion, tiProjectDirectory, "appid", //project.getGroupId() + "." + project.getArtifactId(), projectName, family, simulatorFamily); //pb.directory(tiProjectDir); // The first call may fail log.info("ProcessBuilder: " + getProcessBuilderString(pb)); boolean relaunch = false; int result; try { StringBuilder logContent = new StringBuilder(); Process p = pb.start(); TitaniumBuilder.logProcess(p, log, logContent, false); p.waitFor(); result = p.exitValue(); if (failOnTiapp(tiProjectDirectory, logContent.toString())) { relaunch = true; } } catch (Throwable t) { throw new MojoExecutionException("Error while building iphone", t); } if (relaunch) { log.warn("Relaunching builder as it failed on missing tiapp.xml"); try { Process p = pb.start(); TitaniumBuilder.logProcess(p, log); p.waitFor(); result = p.exitValue(); } catch (Throwable t) { throw new MojoExecutionException("Error while building iphone", t); } } if (result != 0) { throw new MojoFailureException("The titanium build failed"); } }
From source file:org.codehaus.mojo.javascript.titanium.TitaniumBuilder.java
License:Open Source License
/** * Launch the titanium ios builder distribute command and log its output. * @param iosVersion The ios version./* w ww . ja v a2 s . com*/ * @param tiProjectDirectory The titanium project directory. * @param appId The application identifier. * @param projectName The project name. * @param appuuid The application uuid. * @param distName The distribution name. * @param targetDir The folder where the resulting file will be created. * @param family The device family. * @param log The maven logger. * @throws MojoFailureException When the builder process return an error. * @throws MojoExecutionException When an error occurs while creating the distribution. */ public void launchIphoneDistribute(String iosVersion, File tiProjectDirectory, String appId, String projectName, String appuuid, String distName, File targetDir, String family, Log log) throws MojoExecutionException, MojoFailureException { if (iosBuilder == null) { throw new MojoExecutionException("Unable to retrieve the iphone builder"); } log.info("iphoneBuilder: " + iosBuilder.getAbsolutePath()); targetDir.mkdirs(); ProcessBuilder pb = new ProcessBuilder(iosBuilder.getAbsolutePath(), "distribute", iosVersion, tiProjectDirectory.getAbsolutePath(), appId, projectName, appuuid, distName, targetDir.getAbsolutePath(), family).redirectErrorStream(true); log.info("ProcessBuilder: " + getProcessBuilderString(pb)); boolean relaunch = false; int result; try { StringBuilder logContent = new StringBuilder(); Process p = pb.start(); TitaniumBuilder.logProcess(p, log, logContent, true); p.waitFor(); result = p.exitValue(); if (failOnTiapp(tiProjectDirectory.getAbsolutePath(), logContent.toString())) { relaunch = true; } } catch (Throwable t) { throw new MojoExecutionException("Error while building iphone", t); } if (relaunch) { log.warn("Relaunching builder as it failed on missing tiapp.xml"); try { Process p = pb.start(); TitaniumBuilder.logProcess(p, log, null, true); p.waitFor(); result = p.exitValue(); } catch (Throwable t) { throw new MojoExecutionException("Error while building iphone", t); } } if (result != 0) { throw new MojoFailureException("The titanium builder failed"); } }
From source file:org.codehaus.mojo.javascript.titanium.TitaniumBuilder.java
License:Open Source License
/** * Parse a line and output to the specified logger using the appropriate level. * @param line The line to parse.// w w w . j av a 2s. c o m * @param log The logger. * @param defaultLogLevel The log level to use if the parsed line doesn't contain * the log level info. * @return the log level used to log the line. */ private static String parseTitaniumBuilderLine(String line, Log log, String defaultLogLevel) { final Pattern pattern = Pattern.compile("\\[(TRACE|INFO|DEBUG|WARN|ERROR)\\] (.+)"); final Matcher matcher = pattern.matcher(line); if (matcher.find()) { String type = matcher.group(1); String msg = matcher.group(2); if (type.equals("TRACE") || type.equals("DEBUG")) { log.debug(msg); return "DEBUG"; } else if (type.equals("INFO")) { log.info(msg); return "INFO"; } else if (type.equals("ERROR")) { log.error(msg); return "ERROR"; } else if (type.equals("WARN")) { log.warn(msg); return "WARN"; } else { log.debug(msg); return "DEBUG"; } } else { if (defaultLogLevel != null) { defaultLogLevel = defaultLogLevel.toUpperCase(); if (defaultLogLevel.equals("DEBUG") || defaultLogLevel.equals("TRACE")) { log.debug(line); } else if (defaultLogLevel.equals("INFO")) { log.info(line); } else if (defaultLogLevel.equals("ERROR")) { log.error(line); } else if (defaultLogLevel.equals("WARN")) { log.warn(line); } else { log.debug(line); defaultLogLevel = "DEBUG"; } return defaultLogLevel; } else { log.debug(line); return "DEBUG"; } } }
From source file:org.codehaus.mojo.javascript.titanium.TitaniumUtils.java
License:Open Source License
/** * Create a new Android AVD.//from w ww . j a v a 2 s . co m * * @param androidSdkHome The android SDK home folder. * @param avdId The android API version. * @param skin The skin of the emulator. * @param log The logging system. * @return true if the avd was successfully created, false if the avd already existed. * @throws MojoExecutionException When an error occured during the AVD creation. */ public static boolean createAvd(File androidSdkHome, String avdId, String skin, Log log) throws MojoExecutionException { String avdName = "titanium_" + avdId + "_" + skin; String homeDir = System.getProperty("user.home"); File avdDir = new File(homeDir, ".android" + File.separator + "avd" + File.separator + avdName + ".avd"); if (!avdDir.exists()) { File androidCmd = new File(androidSdkHome, "tools" + File.separator + "android"); File sdCard = new File(homeDir, ".titanium" + File.separatorChar + avdName + ".sdcard"); createSdCard(androidSdkHome, sdCard, "64M"); ProcessBuilder pb = new ProcessBuilder(androidCmd.getAbsolutePath(), "--verbose", "create", "avd", "-n", avdName, "-t", avdId, "-s", skin, "--force", "--sdcard", sdCard.getAbsolutePath()); try { Process p = pb.start(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream())); //log.info("Start create AVD"); //TitaniumPackageMojo.logProcess(p, log); log.info("Sending no"); writer.write("no"); writer.write("\n"); writer.flush(); TitaniumBuilder.logProcess(p, log); p.waitFor(); } catch (IOException ioe) { throw new MojoExecutionException("Error while creating avd", ioe); } catch (InterruptedException ie) { throw new MojoExecutionException("Error while creating avd", ie); } return true; } else { return false; } }
From source file:org.codehaus.mojo.jaxb2.AbstractJaxbMojo.java
License:Apache License
/** * {@inheritDoc}/*from w w w . j av a2 s .co m*/ */ @Override public final void execute() throws MojoExecutionException, MojoFailureException { // 0) Get the log and its relevant level final Log log = getLog(); final boolean isDebugEnabled = log.isDebugEnabled(); final boolean isInfoEnabled = log.isInfoEnabled(); // 1) Should we skip execution? if (shouldExecutionBeSkipped()) { if (isDebugEnabled) { log.debug("Skipping execution, as instructed."); } return; } // 2) Printout relevant version information. if (isDebugEnabled) { logPluginAndJaxbDependencyInfo(); } // 3) Are generated files stale? if (isReGenerationRequired()) { if (performExecution()) { // As instructed by the performExecution() method, update // the timestamp of the stale File. updateStaleFileTimestamp(); // Hack to support M2E buildContext.refresh(getOutputDirectory()); } else if (isInfoEnabled) { log.info("Not updating staleFile timestamp as instructed."); } } else if (isInfoEnabled) { log.info("No changes detected in schema or binding files - skipping JAXB generation."); } // 4) If the output directories exist, add them to the MavenProject's source directories if (getOutputDirectory().exists() && getOutputDirectory().isDirectory()) { final String canonicalPathToOutputDirectory = FileSystemUtilities .getCanonicalPath(getOutputDirectory()); if (log.isDebugEnabled()) { log.debug("Adding existing JAXB outputDirectory [" + canonicalPathToOutputDirectory + "] to Maven's sources."); } // Add the output Directory. getProject().addCompileSourceRoot(canonicalPathToOutputDirectory); } }