List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:com.edugility.liquibase.maven.AssembleChangeLogMojo.java
License:Open Source License
/** * Executes this {@link AssembleChangeLogMojo} by calling the {@link * #assembleChangeLog()} method./*from w w w. ja v a2 s . c om*/ * * @exception MojoFailureException if an error occurs; under normal * circumstances this goal will not fail so this method does not * throw {@link MojoExecutionException} * * @exception TemplateSyntaxError if the supplied {@code template} * contained syntax errors * * @exception TemplateRuntimeError if there was a problem merging * the supplied {@link Collection} of {@link URL}s with the compiled * version of the supplied {@code template} * * @see #assembleChangeLog() */ @Override public void execute() throws MojoFailureException { final Log log = this.getLog(); if (this.getSkip()) { if (log != null && log.isDebugEnabled()) { log.debug("Skipping execution by request"); } } else { try { this.assembleChangeLog(); } catch (final RuntimeException e) { throw e; } catch (final IOException e) { throw new MojoFailureException("Failure assembling changelog", e); } catch (final ArtifactResolutionException e) { throw new MojoFailureException("Failure assembling changelog", e); } catch (final DependencyGraphBuilderException e) { throw new MojoFailureException("Failure assembling changelog", e); } } }
From source file:com.edugility.liquibase.maven.AssembleChangeLogMojo.java
License:Open Source License
/** * Assembles a <a href="http://www.liquibase.org/">Liquibase</a> <a * href="http://www.liquibase.org/documentation/databasechangelog.html">changelog</a> * from changelog fragments {@linkplain #getChangeLogResources() * found in topological dependency order among the dependencies} of * the {@linkplain #getProject() current project}. * * <p>This method:</p>/*from www .j a v a 2 s.c o m*/ * * <ul> * * <li>{@linkplain #getChangeLogTemplateResource() Verifies that * there is a template} that exists either in the {@linkplain * #getProject() project} or (more commonly) in this plugin</li> * * <li>Verifies that the template can be read and has contents</li> * * <li>{@linkplain * Artifacts#getArtifactsInTopologicalOrder(MavenProject, * DependencyGraphBuilder, ArtifactFilter, ArtifactResolver, * ArtifactRepository) Retrieves and resolves the project's * dependencies and sorts them in topological order} from the * artifact with the least dependencies to {@linkplain #getProject() * the current project} (which by definition has the most * dependencies)</li> * * <li>Builds a {@link ClassLoader} that can "see" the {@linkplain * Artifact#getFile() <code>File</code>s associated with those * <code>Artifact</code>s} and uses it to {@linkplain * ClassLoader#getResources(String) find} the {@linkplain * #getChangeLogResourceNames() specified changelog resources}</li> * * <li>Passes a {@link Collection} of {@link URL}s representing (in * most cases) {@code file:} or {@code jar:} {@link URL}s through * the {@linkplain TemplateRuntime MVEL template engine}, thus * merging the template and the {@link URL}s into an aggregating * changelog</li> * * <li>{@linkplain #write(String, Collection, File) Writes} the * resulting changelog to the destination denoted by the {@link * #getOutputFile() outputFile} parameter</li> * * </ul> * * @exception ArtifactResolutionException if there was a problem * {@linkplain ArtifactResolver#resolve(ArtifactResolutionRequest) * resolving} a given {@link Artifact} representing a dependency * * @exception DependencyGraphBuilderException if there was a problem * with dependency resolution * * @exception IOException if there was a problem with input or * output * * @see #getChangeLogTemplateResource() * * @see #getChangeLogResources() * * @see #getOutputFile() * * @see #write(String, Collection, File) */ public final void assembleChangeLog() throws ArtifactResolutionException, DependencyGraphBuilderException, IOException { final Log log = this.getLog(); final URL changeLogTemplateResource = this.getChangeLogTemplateResource(); if (log != null && log.isDebugEnabled()) { log.debug(String.format("Change log template resource: %s", changeLogTemplateResource)); } if (changeLogTemplateResource != null) { final String templateContents = this.readTemplate(changeLogTemplateResource); if (log != null && log.isDebugEnabled()) { log.debug(String.format("Change log template contents: %s", templateContents)); } if (templateContents != null) { final Collection<? extends URL> urls = this.getChangeLogResources(); if (log != null && log.isDebugEnabled()) { log.debug(String.format("Change log resources: %s", urls)); } if (urls != null && !urls.isEmpty()) { final File outputFile = this.getOutputFile(); if (log != null && log.isDebugEnabled()) { log.debug(String.format("Output file: %s", outputFile)); } if (outputFile != null) { this.write(templateContents, urls, outputFile); } } } } }
From source file:com.edugility.liquibase.maven.AssembleChangeLogMojo.java
License:Open Source License
/** * Writes appropriate representations of the supplied {@link URL}s * as interpreted and merged into the supplied {@code template} * contents to the {@link File} represented by the {@code * outputFile} parameter value.//from ww w . j ava 2 s. c o m * * @param template an <a href="http://mvel.codehaus.org/">MVEL</a> * template; may be {@code null} in which case no action will be * taken * * @param urls a {@link Collection} of {@link URL}s representing * existing changelog fragment resources, sorted in topological * dependency order; may be {@code null} in which case no action * will be taken * * @param outputFile a {@link File} representing the full path to * the location where an aggregate changelog should be written; may * be {@code null} in which case no action will be taken; not * validated in any way by this method * * @exception IOException if there was a problem writing to the supplied {@link File} * * @exception TemplateSyntaxError if the supplied {@code template} * contained syntax errors * * @exception TemplateRuntimeError if there was a problem merging * the supplied {@link Collection} of {@link URL}s with the compiled * version of the supplied {@code template} * * @see #getOutputFile() * * @see #getChangeLogResources() * * @see #getChangeLogResourceNames() */ public void write(final String template, final Collection<? extends URL> urls, final File outputFile) throws IOException { if (template != null && urls != null && !urls.isEmpty() && outputFile != null) { final CompiledTemplate compiledTemplate = TemplateCompiler.compileTemplate(template); assert compiledTemplate != null; final Map<Object, Object> variables = new HashMap<Object, Object>(); variables.put("databaseChangeLogXsdVersion", this.getDatabaseChangeLogXsdVersion()); variables.put("changeLogParameters", this.getChangeLogParameters()); variables.put("resources", urls); String encoding = this.getChangeLogCharacterEncoding(); if (encoding == null) { encoding = "UTF-8"; } final Log log = this.getLog(); if (log != null && log.isDebugEnabled()) { log.debug(String.format("Writing change log to %s using character encoding %s", outputFile, encoding)); } final Writer writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(outputFile), encoding)); try { TemplateRuntime.execute(compiledTemplate, this, new MapVariableResolverFactory(variables), null /* no TemplateRegistry */, new TemplateOutputWriter(writer)); } finally { try { writer.flush(); } catch (final IOException ignore) { // ignore on purpose } try { writer.close(); } catch (final IOException ignore) { // ignore on purpose } } } }
From source file:com.edugility.liquibase.maven.AssembleChangeLogMojo.java
License:Open Source License
/** * Given a {@link URL} to a changelog template, fully reads that * template into memory and returns it, uninterpolated, as a {@link * String}.// www. j a va 2 s . com * * <p>This method may return {@code null}.</p> * * @param changeLogTemplateResource a {@link URL} to an <a * href="http://mvel.codehaus.org/">MVEL<a> template; must not be * {@code null} * * @return the contents of the template, uninterpolated, or {@code * null} * * @exception IOException if an input/output error occurs * * @see #getTemplateCharacterEncoding() */ private final String readTemplate(final URL changeLogTemplateResource) throws IOException { final Log log = this.getLog(); if (changeLogTemplateResource == null) { throw new IllegalArgumentException("changeLogTemplateResource", new NullPointerException("changeLogTemplateResource")); } String returnValue = null; final InputStream rawStream = changeLogTemplateResource.openStream(); if (rawStream != null) { BufferedReader reader = null; String templateCharacterEncoding = this.getTemplateCharacterEncoding(); if (templateCharacterEncoding == null) { templateCharacterEncoding = "UTF-8"; } if (log != null && log.isDebugEnabled()) { log.debug(String.format("Reading change log template from %s using character encoding %s", changeLogTemplateResource, templateCharacterEncoding)); } try { reader = new BufferedReader(new InputStreamReader(rawStream, templateCharacterEncoding)); String line = null; final StringBuilder sb = new StringBuilder(); while ((line = reader.readLine()) != null) { sb.append(line); sb.append(LS); } returnValue = sb.toString(); } finally { try { rawStream.close(); } catch (final IOException nothingWeCanDo) { } if (reader != null) { try { reader.close(); } catch (final IOException nothingWeCanDo) { } } } } else if (log != null && log.isDebugEnabled()) { log.debug(String.format("Opening change log template %s results in a null InputStream.", changeLogTemplateResource)); } return returnValue; }
From source file:com.edugility.liquibase.maven.AssembleChangeLogMojo.java
License:Open Source License
/** * Creates and returns a new {@link ClassLoader} whose classpath * encompasses reachable changelog resources found among the * supplied {@link Artifact}s./* www. j a v a2 s.c o m*/ * * <p>This method may return {@code null}.</p> * * @param artifacts an {@link Iterable} of {@link Artifact}s, some * of whose members may house changelog fragments; may be {@code * null} in which case {@code null} will be returned * * @return an appropriate {@link ClassLoader}, or {@code null} * * @exception MalformedURLException if during classpath assembly a * bad {@link URL} was encountered * * @see #toURLs(Artifact) */ private final ClassLoader toClassLoader(final Iterable<? extends Artifact> artifacts) throws MalformedURLException { final Log log = this.getLog(); ClassLoader loader = null; if (artifacts != null) { final Collection<URL> urls = new ArrayList<URL>(); for (final Artifact artifact : artifacts) { final Collection<? extends URL> classpathElements = this.toURLs(artifact); if (classpathElements != null && !classpathElements.isEmpty()) { urls.addAll(classpathElements); } } if (!urls.isEmpty()) { if (log != null && log.isDebugEnabled()) { log.debug(String.format("Creating URLClassLoader with the following classpath: %s", urls)); } loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), Thread.currentThread().getContextClassLoader()); } } return loader; }
From source file:com.ericsson.tools.cpp.compiler.linking.executables.Executable.java
License:Apache License
private Collection<NativeCodeFile> findNativeCodeFiles(final Log log, final File projectBasedir, final Collection<NativeCodeFile> compiledFiles) { log.debug("Creative native code file list matching pattern " + entryPointPattern + " for executable " + name + "."); final Collection<NativeCodeFile> allCppFiles = new ArrayList<NativeCodeFile>(); if (entryPointPattern != null) { final Collection<File> matchingRawFiles = findMatchingSourceFiles(projectBasedir); allCppFiles.addAll(translateRawFilesToCompiledFiles(log, matchingRawFiles, compiledFiles)); }//from w ww . j a v a 2 s . co m if (allCppFiles.isEmpty()) log.debug("Found no compiled files matching the pattern \"" + entryPointPattern + "\" for executable " + name + "."); return allCppFiles; }
From source file:com.ericsson.tools.cpp.compiler.linux.LinuxProvider.java
License:Apache License
public LinuxProvider(EnvironmentManager em, Log log) { this.log = log; this.compatibilityChecker = new CompatibilityChecker(log); log.debug("Loaded Linux provider"); }
From source file:com.ericsson.tools.cpp.compiler.osx.OSXProvider.java
License:Apache License
public OSXProvider(EnvironmentManager em, Log log) { this.log = log; this.compatibilityChecker = new CompatibilityChecker(log); log.debug("Loaded OS X provider"); }
From source file:com.ericsson.tools.cpp.tester.execution.ValgrindTestExecutor.java
License:Apache License
public ValgrindTestExecutor(final Log log, final TestSettings settings) { super(log);/*from w w w. j av a 2 s .c om*/ if (settings.getSuppressionFile().exists()) suppressionsArgument = "--suppressions=" + settings.getSuppressionFile(); else log.debug("Suppressions file " + settings.getSuppressionFile() + " doesn't exist. Skipping Valgrind suppressions."); }
From source file:com.ericsson.tools.cpp.tools.bundle.BundleLoader.java
License:Apache License
public BundleLoader(ClassLoader loader, EnvironmentManager environment, Log log) throws IOException { this.loader = loader; this.log = log; this.em = environment; Enumeration<URL> urls = loader.getResources("META-INF/cpp/bundle.properties"); while (urls.hasMoreElements()) { URL url = urls.nextElement(); InputStream is = url.openStream(); try {// w w w . j ava2s .c om Properties p = new Properties(); p.load(is); bundles.add(new Bundle(p)); } finally { is.close(); } } log.debug("Loaded " + bundles.size() + " bundles"); }