@Override public Model read( File input, Map<String, ?> options ) throws IOException { return reader.read( input, options ); }
protected ModelReader newModelReader() { return new DefaultModelReader(); }
/** * Creates a new parser exception with the specified details. * * @param message The error message, may be {@code null}. * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. * @param cause The nested cause of this error, may be {@code null}. */ public ModelParseException( String message, int lineNumber, int columnNumber, Throwable cause ) { super( message ); initCause( cause ); this.lineNumber = lineNumber; this.columnNumber = columnNumber; }
private Model read( Reader reader, boolean strict, InputSource source ) throws IOException { try { if ( source != null ) { return new MavenXpp3ReaderEx().read( reader, strict, source ); } else { return new MavenXpp3Reader().read( reader, strict ); } } catch ( XmlPullParserException e ) { throw new ModelParseException( e.getMessage(), e.getLineNumber(), e.getColumnNumber(), e ); } }
@SuppressWarnings({ "unchecked" }) public void translate(final Reader input, final Map<String, ?> inputOptions, final Writer output, final Map<String, ?> outputOptions) throws IOException, ModelParseException { assert input != null; assert output != null; ModelReader reader = manager.getReaderFor(inputOptions); Model model = reader.read(input, inputOptions); ModelWriter writer = manager.getWriterFor(outputOptions); writer.write(output, (Map<String, Object>) outputOptions, model); }
@Override public Model read(final Reader input, final Map<String, ?> options) throws IOException { assert input != null; Model model; try { model = doRead(input, options); } catch (Throwable t) { t = StackTraceUtils.sanitize(t); if (t instanceof IOException) { throw (IOException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Error) { throw (Error) t; } throw new RuntimeException(t); } // FIXME: Looks like there are cases where the model is loaded more than once executeManager.install(model, options); if (log.isDebugEnabled()) { DefaultModelWriter writer = new DefaultModelWriter(); StringWriter buff = new StringWriter(); writer.write(buff, null, model); log.debug("Read groovy model: \n" + buff); } return model; }
@Override public Model read( File input, Map<String, ?> options ) throws IOException { Objects.requireNonNull( input, "input cannot be null" ); Model model = read( new FileInputStream( input ), options ); model.setPomFile( input ); return model; }
@Override public void write( File output, Map<String, Object> options, Model model ) throws IOException { Objects.requireNonNull( output, "output cannot be null" ); Objects.requireNonNull( model, "model cannot be null" ); output.getParentFile().mkdirs(); write( WriterFactory.newXmlWriter( output ), options, model ); }
line = e.getLineNumber(); column = e.getColumnNumber();
.setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() ) .setException( e ) ); .setMessage( "Malformed POM " + modelSource.getLocation() + ": " + e.getMessage() ) .setException( e ) ); .setMessage( "Non-parseable POM " + modelSource.getLocation() + ": " + e.getMessage() ) .setException( e ) ); throw problems.newModelBuildingException();
public Model read(Reader input, Map<String, ?> options) throws IOException, ModelParseException { if (input == null) { throw new IllegalArgumentException("XML Reader is null."); } Model model = null; try { model = reader.read(input); } catch (XmlPullParserException e) { throw new ModelParseException(e.getMessage(), -1, -1, e); } return model; } }
@SuppressWarnings({ "unchecked" }) public void translate(final File input, final Map<String, ?> inputOptions, final File output, final Map<String, ?> outputOptions) throws IOException, ModelParseException { assert input != null; assert output != null; ModelReader reader = manager.getReaderFor(inputOptions); Model model = reader.read(input, inputOptions); ModelWriter writer = manager.getWriterFor(outputOptions); writer.write(output, (Map<String, Object>) outputOptions, model); }
@Override public Model read( Reader input, Map<String, ?> options ) throws IOException { return reader.read( input, options ); }
DefaultModelWriter writer = new DefaultModelWriter(); writer.write(buff, options, model);
@Override public void write( OutputStream output, Map<String, Object> options, Model model ) throws IOException { Objects.requireNonNull( output, "output cannot be null" ); Objects.requireNonNull( model, "model cannot be null" ); String encoding = model.getModelEncoding(); // TODO Use StringUtils here if ( encoding == null || encoding.length() <= 0 ) { encoding = "UTF-8"; } try ( final Writer out = new OutputStreamWriter( output, encoding ) ) { write( out, options, model ); } }
@SuppressWarnings({ "unchecked" }) public void translate(final InputStream input, final Map<String, ?> inputOptions, final OutputStream output, final Map<String, ?> outputOptions) throws IOException, ModelParseException { assert input != null; assert output != null; ModelReader reader = manager.getReaderFor(inputOptions); Model model = reader.read(input, inputOptions); ModelWriter writer = manager.getWriterFor(outputOptions); writer.write(output, (Map<String, Object>) outputOptions, model); }
@Override public Model read( InputStream input, Map<String, ?> options ) throws IOException { return reader.read( input, options ); }
protected Model modelFromNativePom(Log log) throws MojoExecutionException, MojoFailureException { Map<String, ModelSource> options = new HashMap<String, ModelSource>(); options.put(ModelProcessor.SOURCE, new FileModelSource(nativePom)); assert modelManager != null; try { ModelReader reader = modelManager.getReaderFor(options); if (reader == null) { throw new MojoExecutionException("no model reader found for " + nativePom); } if (log.isDebugEnabled()) { log.debug("Parsing native pom " + nativePom); } return reader.read(nativePom, options); } catch (IOException e) { throw new MojoFailureException("error parsing " + nativePom, e); } } }