List of usage examples for org.apache.maven.plugin MojoExecutionException MojoExecutionException
public MojoExecutionException(String message, Throwable cause)
MojoExecutionException
exception wrapping an underlying Throwable
and providing a message
. From source file:ca.uhn.hl7v2.sourcegen.SegmentGenerator.java
License:Mozilla Public License
/** * <p>Creates skeletal source code (without correct data structure but no business * logic) for all segments found in the normative database. </p> */// w w w. j a v a 2 s . c o m public static void makeAll(String baseDirectory, String version, String theTemplatePackage, String theFileExt) throws IOException, SQLException, HL7Exception, MojoExecutionException { //make base directory if (!(baseDirectory.endsWith("\\") || baseDirectory.endsWith("/"))) { baseDirectory = baseDirectory + "/"; } File targetDir = SourceGenerator .makeDirectory(baseDirectory + DefaultModelClassFactory.getVersionPackagePath(version) + "segment"); ArrayList<String> segments = getSegmentNames(version); if (segments.size() == 0) { log.warn("No version {} segments found in database {}", version, System.getProperty("ca.on.uhn.hl7.database.url")); } for (int i = 0; i < segments.size(); i++) { try { String seg = (String) segments.get(i); String hapiTestGenSegment = System.getProperty("hapi.test.gensegment"); if (hapiTestGenSegment != null && !hapiTestGenSegment.contains(seg)) { continue; } makeSegment(seg, version, theTemplatePackage, targetDir, theFileExt); } catch (Exception e) { // System.err.println("Error creating source code for all segments: " + e.getMessage()); // e.printStackTrace(); throw new MojoExecutionException("Failure generating segments", e); } } }
From source file:ca.weblite.mirah.maven.MirahCompilerMojo.java
License:Apache License
public void execute() throws MojoExecutionException, CompilationFailureException { if (!pathExists(macroSourcePath)) { FileUtils.mkdir(macroSourcePath); }/*from w ww . j a v a 2 s . com*/ Paths paths = new Paths(); paths.glob(this.sourceDirectory, "**/macros/**"); if (!paths.isEmpty()) { try { paths.copyTo(macroSourcePath); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } paths = new Paths(); paths.glob(macroSourcePath, "**/macros/Bootstrap.mirah"); paths.delete(); WLMirahCompiler c = new WLMirahCompiler(); setupCompiler(c); c.setSourcePath(macroSourcePath); File macroClassesDir = new File(macroClassesDirectory); macroClassesDir.mkdirs(); c.setDestinationDirectory(macroClassesDir); try { c.compile(new String[] { macroSourcePath }); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } } if (!pathExists(macroBootstrapPath)) { FileUtils.mkdir(macroBootstrapPath); } paths = new Paths(); paths.glob(sourceDirectory, "**/macros/Bootstrap.mirah"); if (!paths.isEmpty()) { try { paths.copyTo(macroBootstrapPath); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } WLMirahCompiler c = new WLMirahCompiler(); setupCompiler(c); c.setSourcePath(macroBootstrapPath); File macroBootstrapClassesDir = new File(macroBootstrapClassesDirectory); macroBootstrapClassesDir.mkdirs(); c.setDestinationDirectory(macroBootstrapClassesDir); c.setMacroClassPath(StringUtils.join(classpathElements.iterator(), File.pathSeparator) + File.pathSeparator + macroClassesDirectory); c.setClassPath(StringUtils.join(classpathElements.iterator(), File.pathSeparator) + File.pathSeparator + macroClassesDirectory); try { c.compile(new String[] { macroBootstrapPath }); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } } if (pathExists(sourceDirectory)) { WLMirahCompiler c = new WLMirahCompiler(); setupCompiler(c); c.setSourcePath(sourceDirectory); if (pathExists(macroSourcePath) && pathExists(macroBootstrapPath)) { c.setMacroClassPath( StringUtils.join(classpathElements.iterator(), File.pathSeparator) + File.pathSeparator + macroClassesDirectory + File.pathSeparator + macroBootstrapClassesDirectory ); c.setClassPath( StringUtils.join(classpathElements.iterator(), File.pathSeparator) + File.pathSeparator + macroClassesDirectory + File.pathSeparator + macroBootstrapClassesDirectory ); } File outputDir = new File(mirahClassesOutputDirectory); outputDir.mkdirs(); c.setDestinationDirectory(outputDir); try { c.compile(new String[] { sourceDirectory }); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } // Copy to classes directory File classesDir = new File(outputDirectory); classesDir.mkdirs(); try { FileUtils.copyDirectoryStructure(outputDir, classesDir); } catch (IOException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } // Generate jar file with mirah classes only File mirahJar = new File(mirahClassesJarFile); mirahJar.getParentFile().mkdirs(); try { createJar(outputDir, outputDir.getPath(), mirahJar); } catch (IOException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } } }
From source file:ca.weblite.mirah.maven.MirahTestCompilerMojo.java
License:Apache License
public void execute() throws MojoExecutionException, CompilationFailureException { if (!pathExists(macroSourcePath)) { FileUtils.mkdir(macroSourcePath); }//w w w .j av a2 s . co m Paths paths = new Paths(); paths.glob(this.sourceDirectory.getPath(), "**/macros/**"); if (!paths.isEmpty()) { try { paths.copyTo(macroSourcePath); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } paths = new Paths(); paths.glob(macroSourcePath, "**/macros/Bootstrap.mirah"); paths.delete(); WLMirahCompiler c = new WLMirahCompiler(); setupCompiler(c); c.setSourcePath(macroSourcePath); File macroClassesDir = new File(macroClassesDirectory); macroClassesDir.mkdirs(); c.setDestinationDirectory(macroClassesDir); try { c.compile(new String[] { macroSourcePath }); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } } if (!pathExists(macroBootstrapPath)) { FileUtils.mkdir(macroBootstrapPath); } paths = new Paths(); paths.glob(sourceDirectory.getPath(), "**/macros/Bootstrap.mirah"); if (!paths.isEmpty()) { try { paths.copyTo(macroBootstrapPath); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } WLMirahCompiler c = new WLMirahCompiler(); setupCompiler(c); c.setSourcePath(macroBootstrapPath); File macroBootstrapClassesDir = new File(macroBootstrapClassesDirectory); macroBootstrapClassesDir.mkdirs(); c.setDestinationDirectory(macroBootstrapClassesDir); c.setMacroClassPath(StringUtils.join(classpathElements.iterator(), File.pathSeparator) + File.pathSeparator + macroClassesDirectory); c.setClassPath(StringUtils.join(classpathElements.iterator(), File.pathSeparator) + File.pathSeparator + macroClassesDirectory); try { c.compile(new String[] { macroBootstrapPath }); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } } if (pathExists(sourceDirectory.getPath())) { WLMirahCompiler c = new WLMirahCompiler(); setupCompiler(c); c.setSourcePath(sourceDirectory.getPath()); if (pathExists(macroSourcePath) && pathExists(macroBootstrapPath)) { c.setMacroClassPath( StringUtils.join(classpathElements.iterator(), File.pathSeparator) + File.pathSeparator + macroClassesDirectory + File.pathSeparator + macroBootstrapClassesDirectory ); c.setClassPath( StringUtils.join(classpathElements.iterator(), File.pathSeparator) + File.pathSeparator + macroClassesDirectory + File.pathSeparator + macroBootstrapClassesDirectory ); } File outputDir = new File(mirahClassesOutputDirectory); outputDir.mkdirs(); c.setDestinationDirectory(outputDir); try { c.compile(new String[] { sourceDirectory.getPath() }); } catch (Throwable t) { throw new MojoExecutionException(t.getMessage(), t); } // Copy to classes directory File classesDir = new File(outputDirectory.getPath()); classesDir.mkdirs(); try { FileUtils.copyDirectoryStructure(outputDir, classesDir); } catch (IOException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } // Generate jar file with mirah classes only File mirahJar = new File(mirahClassesJarFile); mirahJar.getParentFile().mkdirs(); try { createJar(outputDir, outputDir.getPath(), mirahJar); } catch (IOException ex) { throw new MojoExecutionException(ex.getMessage(), ex); } } }
From source file:cascading.avro.AbstractAvroMojo.java
License:Apache License
private void compileFiles(String[] files, File sourceDir, File outDir) throws MojoExecutionException { for (String filename : files) { try {//ww w. j av a 2 s .com doCompile(filename, sourceDir, outDir); } catch (IOException e) { throw new MojoExecutionException("Error compiling protocol file " + filename + " to " + outDir, e); } } }
From source file:ch.entwine.weblounge.maven.S3DeployMojo.java
License:Open Source License
/** * @return//from w w w. j ava 2 s. c o m * @throws MojoExecutionException */ @SuppressWarnings("unchecked") protected List<File> getResources() throws MojoExecutionException { File directory = new File(resources.getDirectory()); String includes = StringUtils.join(resources.getIncludes(), ","); String excludes = StringUtils.join(resources.getExcludes(), ","); try { List<File> files = FileUtils.getFiles(directory, includes, excludes); getLog().debug("Adding " + files.size() + " objects to the list of items to deploy"); return files; } catch (IOException e) { throw new MojoExecutionException("Unable to get resources to deploy", e); } }
From source file:ch.ifocusit.livingdoc.plugin.baseMojo.AbstractAsciidoctorMojo.java
License:Apache License
protected void write(AsciiDocBuilder asciiDocBuilder, Format format, String outputFilename) throws MojoExecutionException { generatedDocsDirectory.mkdirs();// ww w . ja va2s .c o m File output = getOutput(outputFilename, Format.adoc); try { // write adco file asciiDocBuilder.writeToFile(generatedDocsDirectory.getAbsolutePath(), FilenameUtils.removeExtension(outputFilename), StandardCharsets.UTF_8); if (Format.html.equals(format)) { // convert adoc to html createAsciidoctor().convertFile(output, options()); } } catch (IOException e) { throw new MojoExecutionException( String.format("Unable to convert asciidoc file '%s' to html !", output.getAbsolutePath()), e); } }
From source file:ch.ifocusit.livingdoc.plugin.baseMojo.AbstractDocsGeneratorMojo.java
License:Apache License
/** * Simple write content to a file.//from w w w. j ava 2s . co m * * @param newContent : file content * @param output : destination file * @throws MojoExecutionException */ protected void write(final String newContent, final File output) throws MojoExecutionException { try { output.getParentFile().mkdirs(); IOUtils.write(newContent, new FileOutputStream(output), Charset.defaultCharset()); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to write output file '%s' !", output), e); } }
From source file:ch.ifocusit.livingdoc.plugin.baseMojo.AbstractGlossaryMojo.java
License:Apache License
/** * Main method.// w w w.j av a2s.co m */ @Override public void execute() throws MojoExecutionException, MojoFailureException { javaDocBuilder = buildJavaProjectBuilder(); appendTitle(asciiDocBuilder); if (glossaryMapping != null) { try { mappings = CsvParser.mapTo(DomainObject.class).stream(new FileReader(glossaryMapping)) .collect(Collectors.toList()); } catch (IOException e) { throw new MojoExecutionException("error reading mappings file", e); } } try { executeMojo(); } catch (Exception e) { throw new MojoExecutionException("error executing glossary template", e); } if (!somethingWasGenerated) { // nothing generated return; } write(asciiDocBuilder); }
From source file:ch.ifocusit.livingdoc.plugin.CommonGlossaryMojoDefinition.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { javaDocBuilder = buildJavaProjectBuilder(); if (!withoutTitle) { asciiDocBuilder.sectionTitleLevel1(getTitle()); }// w w w . jav a2 s .c o m if (glossaryMapping != null) { try { mappings = CsvParser.mapTo(MappingDefinition.class).stream(new FileReader(glossaryMapping)) .map(MappingDefinition::checkName).collect(Collectors.toList()); } catch (IOException e) { throw new MojoExecutionException("error reading mappings file", e); } } executeMojo(); write(asciiDocBuilder); }
From source file:ch.ifocusit.livingdoc.plugin.CommonMojoDefinition.java
License:Apache License
void write(final String newValue, final File output, Template template) throws MojoExecutionException { // update content final String newContent = template == null ? newValue : template.process(newValue); // create output try {/* w w w . j av a2 s .co m*/ output.getParentFile().mkdirs(); IOUtils.write(newContent, new FileOutputStream(output), Charset.defaultCharset()); } catch (IOException e) { throw new MojoExecutionException(String.format("Unable to write output file '%s' !", output), e); } }