Package org.apache.maven.model.io

Examples of org.apache.maven.model.io.ModelReader


    private Model loadModel(final InputStream input, final String location)
        throws Exception {
        System.out.println( location );
        Map<String,String> options = new HashMap<String,String>();
        options.put(ModelProcessor.SOURCE, location);
        ModelReader reader = manager.getReaderFor(options);
        return reader.read(input, options);
    }
View Full Code Here


        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 );
        }
View Full Code Here

        System.out.println(sw.getBuffer().toString());
    }

    private Model readClojureModel(final String sourceFile) throws Exception {
        ModelReader reader = new ClojureModelReader();

        URL input = getClass().getResource(sourceFile);
        assertNotNull(input);

        Map<String,Object> options = new HashMap<String,Object>();
        options.put(ModelProcessor.SOURCE, input);
        return reader.read(input.openStream(), options);
    }
View Full Code Here

        Model model = readClojureModel("test.leiningen.1.clj");
        assertNotNull(model);
    }

    private Model readClojureModel(final String sourceFile) throws Exception {
        ModelReader reader = new ClojureModelReader();

        URL input = getClass().getResource(sourceFile);
        assertNotNull(input);

        Map<String,Object> options = new HashMap<String,Object>();
        options.put(ModelProcessor.SOURCE, input);
        return reader.read(input.openStream(), options);
    }
View Full Code Here

        File pom = new File( source.getLocation() );
        source =  new FileModelSource( new File( pom.getPath().replaceFirst( "[.]tesla[.]", "" ) ) );

        ((Map)options).put( ModelProcessor.SOURCE, source );

        ModelReader reader = manager.getReaderFor(options);
        Model model = reader.read(source.getInputStream(), options);

        MavenXpp3Writer xmlWriter = new MavenXpp3Writer();
        StringWriter xml = new StringWriter();
        xmlWriter.write( xml, model );

        FileUtils.fileWrite( pom, xml.toString() );

        // dump pom if filename is given via the pom properties
        String dump = model.getProperties().getProperty( "tesla.dump.pom" );
        if ( dump == null )
        {
            // just nice to dump the pom.xml via commandline switch
            dump = System.getProperty( "tesla.dump.pom" );
        }
        if ( dump != null )
        {
            File dumpPom =  new File( pom.getParentFile(), dump );
            if ( !dumpPom.exists() || ! FileUtils.fileRead( dumpPom ).equals( xml.toString() ) )
            {
                dumpPom.setWritable( true );
                FileUtils.fileWrite( dumpPom, xml.toString() );
                if ( "true".equals( model.getProperties().getProperty( "tesla.dump.readonly" ) ) )
                {
                    dumpPom.setReadOnly();
                }
            }
        }

        model.setPomFile(pom);
        return model;
    }
    else {
        ModelReader reader = manager.getReaderFor(options);
        return reader.read(input, options);
    }
  }
View Full Code Here

    System.out.println(w.toString());

    //
    // Read in the Atom POM
    //
    ModelReader atomModelReader = new AtomModelReader();
    StringReader r = new StringReader(w.toString());
    Model atomModel = atomModelReader.read(r, new HashMap<String, Object>());
    //
    // Test for fidelity
    //
    assertNotNull(atomModel);
    testMavenModelForCompleteness(atomModel);
View Full Code Here

    System.out.println(w.toString());

    //
    // Read in the Atom POM
    //
    ModelReader atomModelReader = new AtomModelReader();
    StringReader r = new StringReader(w.toString());
    Model atomModel = atomModelReader.read(r, new HashMap<String, Object>());
    //
    // Test for fidelity
    //
    assertNotNull(atomModel);
  }
View Full Code Here

  })
  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);
  }
View Full Code Here

  })
  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);
  }
View Full Code Here

  })
  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);
  }
View Full Code Here

TOP

Related Classes of org.apache.maven.model.io.ModelReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.