Package org.apache.maven.bootstrap.model

Examples of org.apache.maven.bootstrap.model.Model


        Date fullStart = new Date();

        String basedir = System.getProperty( "user.dir" );

        File pom = new File( basedir, "pom.xml" );
        Model reader = readModel( pom, true );
        File jar = buildProject( reader );

        if ( "install".equals( goal ) )
        {
            install( reader, pom, jar );
        }

        for ( Iterator i = reader.getAllDependencies().iterator(); i.hasNext(); )
        {
            Dependency dep = (Dependency) i.next();

            FileUtils.copyFileToDirectory( resolver.getArtifactFile( dep ), jar.getParentFile() );
        }
View Full Code Here


    }

    private void cacheModels( File basedir, ArtifactResolver resolver )
        throws IOException, ParserConfigurationException, SAXException
    {
        Model model = readModel( new File( basedir, "pom.xml" ), false );

        for ( Iterator i = model.getModules().iterator(); i.hasNext(); )
        {
            String module = (String) i.next();

            cacheModels( new File( basedir, module ), resolver );
        }
View Full Code Here

        System.setProperty( "basedir", basedir.getAbsolutePath() );

        File file = new File( basedir, "pom.xml" );

        Model model = readModel( file, true );

        String key = model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getPackaging();
        if ( inProgress.contains( key ) )
        {
            return;
        }

        if ( model.getPackaging().equals( "pom" ) )
        {
            if ( buildModules )
            {
                for ( Iterator i = model.getModules().iterator(); i.hasNext(); )
                {
                    String module = (String) i.next();

                    buildProject( new File( basedir, module ), true );
                }
View Full Code Here

            }

            Dependency dependency = plugin.asDependencyPom();
            resolver.downloadDependencies( Collections.singletonList( dependency ) );
            File artifactFile = resolver.getArtifactFile( dependency );
            Model pluginReader = readModel( artifactFile, true );

            List dependencies = new ArrayList();
            for ( Iterator i = pluginReader.getAllDependencies().iterator(); i.hasNext(); )
            {
                Dependency d = (Dependency) i.next();
                if ( !d.getGroupId().equals( "org.apache.maven" ) )
                {
                    dependencies.add( d );
View Full Code Here

    public Model readModel( File file, boolean resolveTransitiveDependencies )
        throws ParserConfigurationException, SAXException, IOException
    {
        ModelReader reader = new ModelReader( resolver, resolveTransitiveDependencies );

        Model model = reader.parseModel( file, Collections.EMPTY_LIST );

        resolver.addBuiltArtifact( model.getGroupId(), model.getArtifactId(), "pom", file );

        String id = model.getGroupId() + ":" + model.getArtifactId();
        modelFileCache.put( id, file );

        modelCache.put( id, model );

        return model;
View Full Code Here

   * @param build specify whether make the build (compile, jar etc.) or not
   * @param pom the pom file
   * @throws Exception the exception
   */
  public void install(String basedir, boolean build, File pom) throws Exception {
    Model model = pomReader.readModel(pom, true);

    File jarFileToInstall;

    if(build) {
      jarFileToInstall = buildProject(model);
    }
    else {
      String artifactId = model.getArtifactId();
      File buildDirFile = new File(basedir, "target");
      String buildDir = buildDirFile.getAbsolutePath();

      jarFileToInstall = new File(buildDir, artifactId + ".jar");
    }

    install(model, pom, jarFileToInstall);

    String type = model.getPackaging();

    if (type.equalsIgnoreCase("pom")) {
      for (Object o : model.getModules()) {
        String module = (String) o;

        File modulePom = new File(pom.getParent(), module + File.separatorChar + "pom.xml");

        Model moduleReader = pomReader.readModel(modulePom, false);
        installPomFile(moduleReader, modulePom);
      }
    }
  }
View Full Code Here

      cacheModels(basedir);
    }

    File file = new File(basedir, "pom.xml");

    Model model = pomReader.readModel(file, true, fullDownload);

    String key = model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getPackaging();

    if (inProgress.contains(key)) {
      return;
    }

    if (model.getPackaging().equalsIgnoreCase("pom")) {
      if (buildModules) {
        for (Object o : model.getModules()) {
          String module = (String) o;

          buildProject(new File(basedir, module), true);
        }
      }
View Full Code Here

    return classpath;
  }

  private void cacheModels(File basedir)
          throws IOException, ParserConfigurationException, SAXException {
    Model model = pomReader.readModel(new File(basedir, "pom.xml"), false);

    for (Object o : model.getModules()) {
      String module = (String) o;

      cacheModels(new File(basedir, module));
    }
  }
View Full Code Here

  public Model readModel(File file, boolean resolveTransitiveDependencies, boolean fullDownload)
      throws ParserConfigurationException, SAXException, IOException {

    ModelReader modelReader = new ModelReader(resolver, resolveTransitiveDependencies, fullDownload);

    Model model = modelReader.parseModel(file, Collections.EMPTY_LIST);

    resolver.addBuiltArtifact(model.getGroupId(), model.getArtifactId(), "pom", file);

    String id = model.getGroupId() + ":" + model.getArtifactId();

    modelFileCache.put(id, file);
    modelCache.put(id, model);

    return model;
View Full Code Here

   * @throws Exception the exception
   */
  public List<URL> calculateDependencies(File pom, boolean ignore) throws Exception {
    List<URL> dependencies = new ArrayList<URL>();

    Model model = readModel(pom, true);

    if (!ignore && model.getPackaging() != null && model.getPackaging().equals("jar")) {
      Dependency currentDep = new Dependency(new ArrayList());
      currentDep.setGroupId(model.getGroupId());
      currentDep.setArtifactId(model.getArtifactId());
      currentDep.setVersion(model.getVersion());
      currentDep.setClassifier(model.getClassifier());

      model.getParentDependencies().put(currentDep.getConflictId(), currentDep);
    }

    for (Object o : model.getAllDependencies()) {
      Dependency dependency = (Dependency) o;

      //noinspection unchecked
      dependency.getRepositories().addAll(model.getRepositories());

      File file = getArtifactFile(dependency);

      if (!FileUtil.getExtension(file).equals("pom")) {
        dependencies.add(file.toURI().toURL());
      }
    }

    resolver.downloadDependencies(model.getAllDependencies());

    return dependencies;
  }
View Full Code Here

TOP

Related Classes of org.apache.maven.bootstrap.model.Model

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.