List of usage examples for org.apache.maven.plugin.logging Log error
void error(Throwable error);
From source file:com.jayway.maven.plugins.android.phase09package.ApkBuilder.java
License:Apache License
/** * Before being able to use the ApkBuilder, an initialization is required. * * @param log//from w ww .jav a2 s. c o m * the Mojo Logger * @param sdkLibs * the File pointing on {@code sdklib.jar} * @throws MojoExecutionException * if the ApkBuilder class cannot be loaded */ @SuppressWarnings("unchecked") public static void initialize(Log log, File sdkLibs) throws MojoExecutionException { if (apkBuilderClass != null) { // Already initialized return; } ApkBuilder.log = log; // Loads the ApkBuilder class try { URLClassLoader child = new URLClassLoader(new URL[] { sdkLibs.toURI().toURL() }, ApkBuilder.class.getClassLoader()); apkBuilderClass = child.loadClass("com.android.sdklib.build.ApkBuilder"); } catch (MalformedURLException e) { // This one cannot happen. throw new RuntimeException("Cannot create a correct URL from file " + sdkLibs.getAbsolutePath()); } catch (ClassNotFoundException e) { log.error(e); throw new MojoExecutionException("Cannot load 'com.android.sdklib.build.ApkBuilder'"); } log.debug("ApkBuilder loaded " + apkBuilderClass); // In order to improve performence and to check that all methods are available // we cache used methods. try { apkBuilderConstructor = apkBuilderClass.getConstructor( new Class[] { File.class, File.class, File.class, String.class, PrintStream.class }); setDebugMethod = apkBuilderClass.getMethod("setDebugMode", new Class[] { Boolean.TYPE }); addResourcesFromJarMethod = apkBuilderClass.getMethod("addResourcesFromJar", new Class[] { File.class }); addNativeLibrariesMethod = apkBuilderClass.getMethod("addNativeLibraries", new Class[] { File.class, String.class }); addSourceFolderMethod = apkBuilderClass.getMethod("addSourceFolder", new Class[] { File.class }); sealApkMethod = apkBuilderClass.getMethod("sealApk", new Class[0]); getDebugKeyStoreMethod = apkBuilderClass.getMethod("getDebugKeystore", new Class[0]); } catch (Exception e) { log.error("Cannot find required method", e); throw new MojoExecutionException("Cannot find the required method", e); } }
From source file:com.kaaprotech.satu.mojo.SatuMojo.java
License:Apache License
public void execute() throws MojoExecutionException { final Log log = getLog(); if (log.isDebugEnabled()) { for (String e : excludes) { log.debug("SATU: Exclude: " + e); }/*from w w w . j a va 2 s . com*/ for (String e : includes) { log.debug("SATU: Include: " + e); } log.debug("SATU: Output: " + outputDirectory); } if (!sourceDirectory.isDirectory()) { log.info("SATU: Root source directory doesn't exist " + sourceDirectory.getAbsolutePath()); return; } log.info("SATU: Processing root source directory " + sourceDirectory.getAbsolutePath()); log.debug("Output root directory is " + outputDirectory.getAbsolutePath()); if (!outputDirectory.exists()) { outputDirectory.mkdirs(); } final List<File> satuModelFiles; try { satuModelFiles = getSatuModelDefinitionFiles(); } catch (InclusionScanException e) { log.error(e); throw new MojoExecutionException("Error occured finding the Satu model definition files", e); } log.info("Compiling " + satuModelFiles.size() + " Satu model definition files to " + outputDirectory.getAbsolutePath()); final SatuToJava generator = new SatuToJava(outputDirectory.getAbsolutePath()); Exception exception = null; for (File file : satuModelFiles) { try { generator.generate(file.getPath(), encoding, jsonCompatible); } catch (Exception e) { if (exception == null) { exception = e; } log.error("Failed to generate code for Satu model definition " + file.getPath(), e); } } if (exception != null) { throw new MojoExecutionException("Error occured generating code for Sata model definition files", exception); } if (project != null) { project.addCompileSourceRoot(outputDirectory.getPath()); } }
From source file:com.monday_consulting.maven.plugins.fsm.util.PrototypeXml.java
License:Apache License
public PrototypeXml(final Log log, final File prototypeXml) throws XmlPullParserException, IOException { this.dependencyJointList = new ArrayList<PrototypeXml.DependencyJoint>(); this.log = log; this.prototypeDom = Xpp3DomBuilder.build(new XmlStreamReader(prototypeXml)); if (log.isDebugEnabled()) this.log.debug("Getting dependency-joints\nDependency-Joints to fill:"); for (final Xpp3Dom xpp3Dom : new Xpp3DomIterator(prototypeDom)) { if (xpp3Dom.getName().equals("dependencies")) { if (xpp3Dom.getValue().equals("")) { log.error( "Prototype-Xml-Error:\nTried to retrieve dependency-joint, but because its value was empty, no connection to a module can be made"); }/*w w w. ja v a 2 s . co m*/ dependencyJointList.add(new DependencyJoint(xpp3Dom.getValue(), xpp3Dom)); if (log.isDebugEnabled()) log.debug("\t" + xpp3Dom.getValue()); } } }
From source file:com.opoopress.maven.plugins.plugin.AbstractDeployMojo.java
License:Apache License
/** * Configure the Wagon with the information from serverConfigurationMap ( which comes from settings.xml ) * * @param wagon/*from w w w. j a v a 2 s . com*/ * @param repositoryId * @param settings * @param container * @param log * @throws WagonConfigurationException * @todo Remove when {@link WagonManager#getWagon(Repository) is available}. It's available in Maven 2.0.5. */ private static void configureWagon(Wagon wagon, String repositoryId, Settings settings, PlexusContainer container, Log log) throws WagonConfigurationException { log.debug(" configureWagon "); //config log configureLog(wagon, log); configureScpWagonIfRequired(wagon, log); // MSITE-25: Make sure that the server settings are inserted for (Server server : settings.getServers()) { String id = server.getId(); log.debug("configureWagon server " + id); if (id != null && id.equals(repositoryId) && (server.getConfiguration() != null)) { final PlexusConfiguration plexusConf = new XmlPlexusConfiguration( (Xpp3Dom) server.getConfiguration()); ComponentConfigurator componentConfigurator = null; try { componentConfigurator = (ComponentConfigurator) container.lookup(ComponentConfigurator.ROLE); componentConfigurator.configureComponent(wagon, plexusConf, container.getContainerRealm()); } catch (final ComponentLookupException e) { throw new WagonConfigurationException(repositoryId, "Unable to lookup wagon configurator." + " Wagon configuration cannot be applied.", e); } catch (ComponentConfigurationException e) { throw new WagonConfigurationException(repositoryId, "Unable to apply wagon configuration.", e); } finally { if (componentConfigurator != null) { try { container.release(componentConfigurator); } catch (ComponentLifecycleException e) { log.error("Problem releasing configurator - ignoring: " + e.getMessage()); } } } } } }
From source file:com.photon.maven.plugins.android.phase09package.ApkBuilder.java
License:Apache License
/** * Before being able to use the ApkBuilder, an initialization is required. * * @param log/*from www .j a va2s. c o m*/ * the Mojo Logger * @param sdkLibs * the File pointing on {@code sdklib.jar} * @throws MojoExecutionException * if the ApkBuilder class cannot be loaded */ @SuppressWarnings("unchecked") public static void initialize(Log log, File sdkLibs) throws MojoExecutionException { if (apkBuilderClass != null) { // Already initialized return; } ApkBuilder.log = log; // Loads the ApkBuilder class try { URLClassLoader child = new URLClassLoader(new URL[] { sdkLibs.toURI().toURL() }, ApkBuilder.class.getClassLoader()); apkBuilderClass = child.loadClass("com.android.sdklib.build.ApkBuilder"); } catch (MalformedURLException e) { // This one cannot happen. throw new RuntimeException("Cannot create a correct URL from file " + sdkLibs.getAbsolutePath()); } catch (ClassNotFoundException e) { log.error(e); throw new MojoExecutionException("Cannot load 'com.android.sdklib.build.ApkBuilder'"); } log.debug("ApkBuilder loaded " + apkBuilderClass); // In order to improve performence and to check that all methods are available // we cache used methods. try { apkBuilderConstructor = apkBuilderClass.getConstructor( new Class[] { File.class, File.class, File.class, String.class, PrintStream.class }); setDebugMethod = apkBuilderClass.getMethod("setDebugMode", new Class[] { Boolean.TYPE }); addResourcesFromJarMethod = apkBuilderClass.getMethod("addResourcesFromJar", new Class[] { File.class }); //The addNativeLibraries signature changed for api 14 Method[] builderMethods = apkBuilderClass.getMethods(); for (Method method : builderMethods) { if ("addNativeLibraries".equals(method.getName())) { Class<?>[] parameterTypes = method.getParameterTypes(); //The old method (pre v14) took a second string parameter. if (parameterTypes.length == 2) { if (parameterTypes[0] == File.class && parameterTypes[1] == String.class) { addNativeLibrariesMethod = method; break; } } else if (parameterTypes.length == 1 && parameterTypes[0] == File.class) { addNativeLibrariesMethod = method; break; } } } addSourceFolderMethod = apkBuilderClass.getMethod("addSourceFolder", new Class[] { File.class }); sealApkMethod = apkBuilderClass.getMethod("sealApk", new Class[0]); getDebugKeyStoreMethod = apkBuilderClass.getMethod("getDebugKeystore", new Class[0]); } catch (Exception e) { log.error("Cannot find required method", e); throw new MojoExecutionException("Cannot find the required method", e); } }
From source file:com.predic8.membrane.maven.ServiceProxyMojo.java
License:Apache License
/** * Validates the Mojo input.//from w w w . j av a 2s. c om * @param logger the {@link Logger} instance. * @throws MojoExecutionException if the configuration is invalid. */ protected void validateInput(Log logger) throws MojoExecutionException { String message = null; if (!new File(proxiesXml).exists()) { message = proxiesXml + " does not exist"; } else if (!new File(proxiesXml).canRead()) { message = proxiesXml + " is not readable"; } if (message != null) { logger.error(message); throw new MojoExecutionException(message); } }
From source file:com.redhat.victims.TextUI.java
License:Open Source License
/** * A rather lousy way at altering the logging level based on the mode of * operation that the rule has been configured for. * /*from w w w .j a v a 2s . c o m*/ * @param l The log instance to invoke warn, error, or info on. * @param mode The mode which determines which log method is invoked. * @param msg The message to send to the log. */ public static void report(final Log l, final String mode, final String msg) { String level; if (mode.equals(Settings.MODE_FATAL)) { level = "error"; } else if (mode.equals(Settings.MODE_WARNING)) { level = "warn"; } else { level = "info"; } try { @SuppressWarnings("rawtypes") Class[] args = { CharSequence.class }; Method m = l.getClass().getDeclaredMethod(level, args); m.invoke(l, msg); } catch (NoSuchMethodException e) { l.error(e); } catch (IllegalAccessException e) { l.error(e); } catch (InvocationTargetException e) { l.error(e); } }
From source file:com.retroduction.carma.mavenplugin.ReportMojo.java
License:Open Source License
public void execute() throws MojoExecutionException, MojoFailureException { Log log = this.getLog(); ReportModelLoader loader = new ReportModelLoader(); MutationRun mutationRun;/* w ww . j a va 2 s .co m*/ try { mutationRun = loader.loadReportModel(this.reportFile); ReportGenerator reportGenerator = new ReportGenerator(); List<File> sourceDirectories = new ArrayList<File>(); sourceDirectories.add(this.sourceDir); reportGenerator.perform(mutationRun, this.outputDirectory, sourceDirectories); log.info("# --------------------------------------------------------------------------------"); log.info("# Mutation Site report generated. Output directory: " + this.outputDirectory); log.info("# --------------------------------------------------------------------------------"); } catch (Exception e) { log.error(e); throw new MojoFailureException("Error during report generation"); } }
From source file:com.sahlbach.maven.delivery.exec.Executor.java
License:Apache License
public static Executor createExecutor(String type, Log logger) { Class<? extends Executor> executorClass = executorMap.get(type); Executor executor = null;/* w w w. j av a 2s . c o m*/ if (executorClass != null) { try { executor = executorClass.newInstance(); executor.setLogger(logger); } catch (InstantiationException e) { logger.error("Can't create Executor of type " + type); } catch (IllegalAccessException e) { logger.error("Can't create Executor of type " + type); } } return executor; }
From source file:com.sahlbach.maven.delivery.upload.Uploader.java
License:Apache License
public static Uploader createUploader(String type, Log logger) { Class<? extends Uploader> uploaderClass = uploaderMap.get(type); Uploader uploader = null;/*from w w w . j ava 2s . com*/ if (uploaderClass != null) { try { uploader = uploaderClass.newInstance(); uploader.setLogger(logger); } catch (InstantiationException e) { logger.error("Can't create Uploader of type " + type); } catch (IllegalAccessException e) { logger.error("Can't create Uploader of type " + type); } } return uploader; }