List of usage examples for org.apache.maven.plugin MojoFailureException MojoFailureException
public MojoFailureException(String message, Throwable cause)
MojoFailureException
exception wrapping an underlying Throwable
and providing a message
. From source file:be.redlab.maven.yamlprops.YamlToPropertiesMojo.java
License:Apache License
private YamlConfiguration getYamlConfiguration() throws MojoFailureException { YamlConfiguration yamlConfiguration; if (null != configuration) { try {//from w ww.ja va2s . com yamlConfiguration = new YamlConfigurationReaderWriter().getFromFile(configuration); } catch (FileNotFoundException e) { if (ignoreNotFound) { getLog().info("Ignoring not found yaml configuration at " + configuration.getAbsolutePath() + " using default"); yamlConfiguration = new YamlConfiguration(); } else { throw new MojoFailureException("Unable to read configuration for yaml to properties.", e); } } } else { yamlConfiguration = new YamlConfiguration(); } return yamlConfiguration; }
From source file:biz.gabrys.maven.plugins.css.splitter.SplitMojo.java
License:Open Source License
private String readCss(final File file) throws MojoFailureException { try {//from w w w .j a v a 2 s . c om return FileUtils.readFileToString(file, encoding); } catch (final IOException e) { throw new MojoFailureException("Cannot read file: " + file.getAbsolutePath(), e); } }
From source file:biz.gabrys.maven.plugins.css.splitter.SplitMojo.java
License:Open Source License
private void saveCss(final File file, final String css) throws MojoFailureException { if (getLog().isDebugEnabled()) { getLog().debug("Saving stylesheet to " + file.getAbsolutePath()); }//from w ww .j a v a2 s.c o m try { FileUtils.write(file, css, encoding); } catch (final IOException e) { throw new MojoFailureException("Cannot save file: " + file.getAbsolutePath(), e); } }
From source file:biz.gabrys.maven.plugins.directory.content.CopyMojo.java
License:Open Source License
private void copy(final File source, final File destination) throws MojoFailureException { if (!force && destination.exists() && source.lastModified() < destination.lastModified()) { if (verbose) { getLog().info("Skips copy file, because source is older than destination file: " + destination.getAbsolutePath()); }/*w ww . ja va 2 s. c om*/ return; } if (verbose) { getLog().info( String.format("Copying %s to %s", source.getAbsolutePath(), destination.getAbsolutePath())); } try { FileUtils.copyFile(source, destination); } catch (final IOException e) { final String message = String.format("Cannot copy %s to %s", source.getAbsolutePath(), destination.getAbsolutePath()); throw new MojoFailureException(message, e); } }
From source file:biz.gabrys.maven.plugins.directory.content.TransformListMojo.java
License:Open Source License
private String transformToDocument(final String xml) throws MojoFailureException { if (getLog().isDebugEnabled()) { getLog().debug("Transforming metadata to document..."); }/* w w w . j a v a2 s . c o m*/ try { return new XsltTransformer().transform(xml, xsltFile); } catch (final TransformException e) { throw new MojoFailureException(e.getMessage(), e); } }
From source file:biz.gabrys.maven.plugins.directory.content.TransformListMojo.java
License:Open Source License
private void saveDocument(final String document) throws MojoFailureException { if (verbose) { getLog().info("Saving document to " + outputFile.getAbsolutePath()); }//from w ww . j a v a 2 s . c om try { FileUtils.write(outputFile, document, encoding); } catch (final IOException e) { throw new MojoFailureException("Cannot save document to file: " + outputFile.getAbsolutePath(), e); } }
From source file:biz.gabrys.maven.plugins.directory.content.TransformMetadataMojo.java
License:Open Source License
private String transformMetadata(final FileMetadata metadata) throws MojoFailureException { if (getLog().isDebugEnabled()) { getLog().debug("Transforming metadata to document..."); }/*from www.j av a2s . co m*/ final String xml = new XmlFileMetadataTransformer().transform(metadata); try { return new XsltTransformer().transform(xml, xsltFile); } catch (final TransformException e) { throw new MojoFailureException(e.getMessage(), e); } }
From source file:biz.gabrys.maven.plugins.directory.content.TransformMetadataMojo.java
License:Open Source License
private void saveDocument(final String document, final File destination) throws MojoFailureException { if (verbose) { getLog().info("Saving transformed document to " + destination.getAbsolutePath()); }//from ww w . ja v a 2 s .co m try { FileUtils.write(destination, document, encoding); } catch (final IOException e) { throw new MojoFailureException( "Cannot save transformed document to file: " + destination.getAbsolutePath(), e); } }
From source file:biz.gabrys.maven.plugins.lesscss.CompileMojo.java
License:Open Source License
private void deleteWorkingDirectory() throws MojoFailureException { if (!workingDirectory.exists()) { return;//from w ww .java 2 s. c o m } if (getLog().isDebugEnabled()) { getLog().debug("Deleting working directory: " + workingDirectory.getAbsolutePath()); } try { FileUtils.deleteDirectory(workingDirectory); } catch (final IOException e) { throw new MojoFailureException( String.format("Cannot delete working directory: %s", workingDirectory.getAbsolutePath()), e); } }
From source file:biz.gabrys.maven.plugins.lesscss.CompileMojo.java
License:Open Source License
private void saveCompiledCode(final File source, final String compiled, final Date compilationDate) throws MojoFailureException { final File destination = new DestinationFileCreator(sourceDirectory, outputDirectory, outputFileFormat) .create(source);/*from w ww .j av a2 s .c o m*/ final boolean skipsFileSaving = !force && !alwaysOverwrite && destination.exists() && compilationDate.before(new Date(destination.lastModified())); if (skipsFileSaving) { if (verbose) { getLog().info( "Skips saving CSS compiled code to file, because cached version is older than destination file: " + destination.getAbsolutePath()); } return; } if (verbose) { getLog().info("Saving CSS code to " + destination.getAbsolutePath()); } try { FileUtils.write(destination, compiled, encoding); } catch (final IOException e) { throw new MojoFailureException( String.format("Cannot save CSS compiled code to file: %s", destination.getAbsolutePath()), e); } }