List of usage examples for org.apache.maven.plugin.logging Log info
void info(Throwable error);
From source file:org.apache.james.mailet.DefaultDescriptorsExtractor.java
License:Apache License
public DefaultDescriptorsExtractor extract(MavenProject project, Log log) { final JavaClass[] classes = javaClasses(project); final URLClassLoader classLoader = classLoader(project, log); logProjectDependencies(project, log); logDirectories(project, log);/*w ww. ja v a2 s . c om*/ try { final Class<?> mailetClass = classLoader.loadClass(MAILET_CLASS_NAME); final Class<?> matcherClass = classLoader.loadClass(MATCHER_CLASS_NAME); for (JavaClass nextClass : classes) { addDescriptor(log, classLoader, mailetClass, matcherClass, nextClass); } } catch (ClassNotFoundException e) { log.debug(e); log.info("No mailets in " + project.getName()); } return this; }
From source file:org.apache.james.mailet.DefaultDescriptorsExtractor.java
License:Apache License
private MailetMatcherDescriptor describeMatcher(Log log, final JavaClass nextClass, String nameOfNextClass, final Class<?> klass) { final MailetMatcherDescriptor result = buildDescriptor(log, nextClass, nameOfNextClass, klass, "getMatcherInfo", MailetMatcherDescriptor.Type.MATCHER); log.info("Found a Matcher: " + klass.getName()); return result; }
From source file:org.apache.james.mailet.DefaultDescriptorsExtractor.java
License:Apache License
private void handleInfoLoadFailure(Log log, String nameOfClass, final Type type, Exception e) { log.info("Cannot load " + type + " info for " + nameOfClass + ": " + e.getMessage()); log.debug(e);/*from w w w . j av a 2 s. c om*/ }
From source file:org.apache.james.mailet.DefaultDescriptorsExtractor.java
License:Apache License
private MailetMatcherDescriptor describeMailet(Log log, final JavaClass nextClass, String nameOfNextClass, final Class<?> klass) { final MailetMatcherDescriptor result = buildDescriptor(log, nextClass, nameOfNextClass, klass, "getMailetInfo", MailetMatcherDescriptor.Type.MAILET); log.info("Found a Mailet: " + klass.getName()); return result; }
From source file:org.apache.pluto.maven.AssembleMojo.java
License:Apache License
protected void doExecute() throws MojoExecutionException { // Log parameter values. Log log = getLog(); if (log.isInfoEnabled()) { if (archives == null || archives.isEmpty()) { log.info("Reading web.xml from :" + webXml.getAbsolutePath()); log.info("Reading portlet.xml from: " + portletXml.getAbsolutePath()); log.info("Writing web.xml to: " + webXmlDestination.getAbsolutePath()); }//w w w. j av a 2 s . c om } try { // Assemble portlet app by updating web.xml. if (archives == null || archives.isEmpty()) { AssemblerConfig config = createAssemblerConfig(); Assembler assembler = AssemblerFactory.getFactory().createAssembler(config); assembler.assemble(config); } else { for (Iterator i = archives.iterator(); i.hasNext();) { File archive = new File(i.next().toString()); if (log.isInfoEnabled()) { log.info("Assembling archive file " + archive.getAbsolutePath() + " to directory " + assemblyOutputDirectory.getAbsolutePath()); } AssemblerConfig config = createArchiveAssemblerConfig(archive, assemblyOutputDirectory); Assembler assembler = AssemblerFactory.getFactory().createAssembler(config); assembler.assemble(config); } } } catch (UtilityException e) { log.error("Assembly failed: " + e.getMessage(), e); } }
From source file:org.apache.rat.mp.util.ScmIgnoreParser.java
License:Apache License
/** * Parses excludes from the given SCM ignore file. * * @param log Maven log to show output during RAT runs. * @param scmIgnore if <code>null</code> or invalid an empty list of exclusions is returned. * @return all exclusions (=non-comment lines) from the SCM ignore file. *///from www .j av a 2 s .c o m public static List<String> getExcludesFromFile(final Log log, final File scmIgnore) { final List<String> exclusionLines = new ArrayList<>(); if (scmIgnore != null && scmIgnore.exists() && scmIgnore.isFile()) { log.info("Parsing exclusions from " + scmIgnore); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(scmIgnore)); String line; while ((line = reader.readLine()) != null) { if (!isComment(line)) { exclusionLines.add(line); log.debug("Added " + line); } } } catch (final IOException e) { log.warn("Cannot parse " + scmIgnore + " for exclusions. Will skip this file."); log.debug("Skip parsing " + scmIgnore + " due to " + e.getMessage()); } finally { IOUtils.closeQuietly(reader); } } return exclusionLines; }
From source file:org.apache.sling.maven.slingstart.run.LauncherCallable.java
License:Apache License
public static void stop(final Log LOG, final ProcessDescription cfg) throws Exception { boolean isNew = false; if (cfg.getProcess() != null || isNew) { LOG.info("Stopping Launchpad " + cfg.getId()); boolean destroy = true; final int twoMinutes = 2 * 60 * 1000; final File controlPortFile = getControlPortFile(cfg.getDirectory()); LOG.debug("Control port file " + controlPortFile + " exists: " + controlPortFile.exists()); if (controlPortFile.exists()) { // reading control port int controlPort = -1; String secretKey = null; LineNumberReader lnr = null; String serverName = null; try { lnr = new LineNumberReader(new FileReader(controlPortFile)); final String portLine = lnr.readLine(); final int pos = portLine.indexOf(':'); controlPort = Integer.parseInt(portLine.substring(pos + 1)); if (pos > 0) { serverName = portLine.substring(0, pos); }//from w ww . jav a2 s.c o m secretKey = lnr.readLine(); } catch (final NumberFormatException ignore) { // we ignore this LOG.debug("Error reading control port file " + controlPortFile, ignore); } catch (final IOException ignore) { // we ignore this LOG.debug("Error reading control port file " + controlPortFile, ignore); } finally { IOUtils.closeQuietly(lnr); } if (controlPort != -1) { final List<String> hosts = new ArrayList<String>(); if (serverName != null) { hosts.add(serverName); } hosts.add("localhost"); hosts.add("127.0.0.1"); LOG.debug("Found control port " + controlPort); int index = 0; while (destroy && index < hosts.size()) { final String hostName = hosts.get(index); Socket clientSocket = null; DataOutputStream out = null; BufferedReader in = null; try { LOG.debug("Trying to connect to " + hostName + ":" + controlPort); clientSocket = new Socket(); // set a socket timeout clientSocket.connect(new InetSocketAddress(hostName, controlPort), twoMinutes); // without that, read() call on the InputStream associated with this Socket is infinite clientSocket.setSoTimeout(twoMinutes); LOG.debug(hostName + ":" + controlPort + " connection estabilished, sending the 'stop' command..."); out = new DataOutputStream(clientSocket.getOutputStream()); in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); if (secretKey != null) { out.writeBytes(secretKey); out.write(' '); } out.writeBytes("stop\n"); in.readLine(); destroy = false; LOG.debug("'stop' command sent to " + hostName + ":" + controlPort); } catch (final Throwable ignore) { // catch Throwable because InetSocketAddress and Socket#connect throws unchecked exceptions // we ignore this for now LOG.debug("Error sending 'stop' command to " + hostName + ":" + controlPort + " due to: " + ignore.getMessage()); } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); IOUtils.closeQuietly(clientSocket); } index++; } } } if (cfg.getProcess() != null) { final Process process = cfg.getProcess(); if (!destroy) { // as shutdown might block forever, we use a timeout final long now = System.currentTimeMillis(); final long end = now + twoMinutes; LOG.debug("Waiting for process to stop..."); while (isAlive(process) && (System.currentTimeMillis() < end)) { try { Thread.sleep(2500); } catch (InterruptedException e) { // ignore } } if (isAlive(process)) { LOG.debug("Process timeout out after 2 minutes"); destroy = true; } else { LOG.debug("Process stopped"); } } if (destroy) { LOG.debug("Destroying process..."); process.destroy(); LOG.debug("Process destroyed"); } cfg.setProcess(null); } } else { LOG.warn("Launchpad already stopped"); } }
From source file:org.apache.synapse.maven.xar.AbstractXarMojo.java
License:Apache License
private void addDependencies(Archiver archiver) throws ArchiverException, MojoExecutionException { Log log = getLog(); AndArtifactFilter filter = new AndArtifactFilter(); filter.add(new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME)); filter.add(new ArtifactFilter() { public boolean include(Artifact artifact) { return !artifact.isOptional(); }//from w w w .ja v a 2s . c o m }); filter.add(new TypeArtifactFilter("jar")); filter.add(buildSynapseRuntimeArtifactFilter()); for (Artifact artifact : filterArtifacts(project.getArtifacts(), filter)) { String targetFileName = artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension(); log.info("Adding " + targetFileName + " (scope " + artifact.getScope() + ")"); archiver.addFile(artifact.getFile(), "lib/" + targetFileName); } }
From source file:org.apache.synapse.maven.xar.AbstractXarMojo.java
License:Apache License
private void generateMetadata(Archiver archiver) throws ArchiverException, MojoExecutionException { Log log = getLog(); File tmpServicesDir = new File(new File(tmpDirectory, "META-INF"), "services"); File buildServicesDir = new File(new File(buildOutputDirectory, "META-INF"), "services"); if (!tmpServicesDir.mkdirs()) { throw new MojoExecutionException("Error while creating the directory: " + tmpServicesDir.getPath()); }/*from w w w . j av a 2 s .c o m*/ log.debug("Initializing class scanner ..."); ClassScanner scanner = new ClassScanner(buildOutputDirectory); for (Artifact artifact : filterArtifacts(project.getArtifacts(), new ScopeArtifactFilter(Artifact.SCOPE_COMPILE))) { scanner.addToClasspath(artifact.getFile()); } List<ServiceLocator> serviceLocators = new ArrayList<ServiceLocator>(serviceClassNames.length); for (String serviceClassName : serviceClassNames) { // If the user provided its own service file, skip generation File file = new File(buildServicesDir, serviceClassName); if (file.exists()) { log.debug(file + " exists; don't scan for " + serviceClassName + " implementation"); } else { ServiceLocator sl = new ServiceLocator(serviceClassName); serviceLocators.add(sl); scanner.addVisitor(sl); } } try { scanner.scan(); } catch (ClassScannerException e) { throw new MojoExecutionException("Failed to scan classes for services", e); } for (ServiceLocator sl : serviceLocators) { File file = new File(tmpServicesDir, sl.getServiceClassName()); if (!sl.getImplementations().isEmpty()) { String destFileName = "META-INF/services/" + sl.getServiceClassName(); log.info("Generating " + destFileName); try { Writer out = new OutputStreamWriter(new FileOutputStream(file)); try { for (String impl : sl.getImplementations()) { log.debug(" " + impl); out.write(impl); out.write("\n"); } } finally { out.close(); } } catch (IOException e) { throw new MojoExecutionException("Unable to create temporary file " + file, e); } archiver.addFile(file, destFileName); } } }
From source file:org.apache.tuscany.maven.bundle.plugin.BundleAggregatorMojo.java
License:Apache License
public static void aggregateBundles(Log log, File root, File[] files, File targetBundleFile, String bundleName, String bundleVersion) throws Exception { targetBundleFile.getParentFile().mkdirs(); Set<File> jarFiles = new HashSet<File>(); List<Manifest> manifests = new ArrayList<Manifest>(); for (File child : files) { try {//from w w w .ja va2 s .c o m Manifest manifest = null; if (child.isDirectory()) { File mf = new File(child, "META-INF/MANIFEST.MF"); if (mf.isFile()) { FileInputStream is = new FileInputStream(mf); manifest = new Manifest(is); is.close(); if (manifest != null) { String classpath = manifest.getMainAttributes().getValue("Bundle-ClassPath"); if (classpath != null) { for (HeaderClause clause : HeaderParser.parse(classpath)) { if (clause.getValue().equals(".")) { continue; } else { jarFiles.add(new File(child, clause.getValue())); } } } else { // } } } } else if (child.getName().endsWith(".jar")) { JarFile jar = new JarFile(child); manifest = jar.getManifest(); jar.close(); if (manifest != null) { String id = manifest.getMainAttributes().getValue("Bundle-SymbolicName"); if (id != null && (id.startsWith("org.eclipse.") || id.startsWith("org.apache.tuscany.sca.gateway"))) { manifest = null; } else { jarFiles.add(child); } } } if (manifest == null) { continue; } log.debug("Bundle file: " + child); manifests.add(manifest); } catch (Exception e) { throw e; } } Manifest merged = new Manifest(); Attributes attributes = merged.getMainAttributes(); attributes.putValue("Manifest-Version", "1.0"); attributes.putValue("Bundle-ManifestVersion", "2"); attributes.putValue("Bundle-License", "http://www.apache.org/licenses/LICENSE-2.0.txt"); attributes.putValue("Bundle-DocURL", "http://www.apache.org/"); attributes.putValue("Bundle-RequiredExecutionEnvironment", "J2SE-1.5,JavaSE-1.6"); attributes.putValue("Bundle-Vendor", "The Apache Software Foundation"); attributes.putValue("Bundle-Version", bundleVersion); attributes.putValue("Bundle-SymbolicName", bundleName); attributes.putValue("SCA-Version", "1.1"); attributes.putValue("Bundle-Name", bundleName); // attributes.putValue("Bundle-ActivationPolicy", "lazy"); for (Manifest mf : manifests) { for (Map.Entry<Object, Object> e : mf.getMainAttributes().entrySet()) { Attributes.Name key = (Attributes.Name) e.getKey(); String name = key.toString(); String oldValue = attributes.getValue(name); String value = (String) e.getValue(); if (name.equals("Export-Package") || name.equals("Import-Package") || name.equals("Require-Bundle") || name.equals("DynamicImport-Package") || name.equals("Bundle-ClassPath") || name.equals("Private-Package") || name.equals("Bundle-Description")) { attributes.putValue(name, merge(oldValue, value)); } else if (name.equals(BUNDLE_ACTIVATOR)) { oldValue = attributes.getValue(BUNDLE_ACTIVATOR_LIST); attributes.putValue(BUNDLE_ACTIVATOR_LIST, merge(oldValue, value)); } else if (name.equals("Main-Class") || name.startsWith("Eclipse-") || name.startsWith("Bundle-")) { // Ignore } else { // Ignore // attributes.putValue(name, value); } } } log.info("Generating " + targetBundleFile); attributes.putValue(BUNDLE_ACTIVATOR, AggregatedBundleActivator.class.getName()); String bundleClassPath = attributes.getValue(BUNDLE_CLASSPATH); bundleClassPath = merge(bundleClassPath, "."); for (File f : jarFiles) { bundleClassPath = merge(bundleClassPath, f.getName()); } attributes.putValue(BUNDLE_CLASSPATH, bundleClassPath); FileOutputStream fos = new FileOutputStream(targetBundleFile); JarOutputStream bundle = new JarOutputStream(fos, merged); for (File file : jarFiles) { log.info("Adding " + file); addEntry(bundle, file.getName(), file); } String classFile = AggregatedBundleActivator.class.getName().replace(".", "/") + ".class"; InputStream classStream = BundleAggregatorMojo.class.getClassLoader().getResourceAsStream(classFile); addEntry(bundle, classFile, classStream); bundle.close(); }