Beispiel #1
0
  /** Construct the ExertionSorter */
  public ExertionSorter(Exertion topLevelJob) throws ContextException, SortingException {

    dag = new DAG();
    projectMap = new HashMap();
    contextIdsMap = new HashMap<String, String>();
    revContextIdsMap = new HashMap<String, String>();
    this.topLevelJob = topLevelJob;

    addVertex(this.topLevelJob);

    try {
      getMapping(this.topLevelJob);
      checkParentCycle(this.topLevelJob);

      List sortedProjects = new ArrayList();
      for (Iterator i = TopologicalSorter.sort(dag).iterator(); i.hasNext(); ) {
        String id = (String) i.next();
        sortedProjects.add(projectMap.get(id));
      }

      this.sortedProjects = Collections.unmodifiableList(sortedProjects);
      reorderJob(this.topLevelJob, this.sortedProjects);
    } catch (CycleDetectedException ce) {
      throw new SortingException(ce.getMessage());
    }
  }
Beispiel #2
0
  private void maven(String[] goals) {
    if (goals == null) {
      return;
    }

    MavenEmbedder maven = new MavenEmbedder();
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    maven.setClassLoader(classLoader);
    maven.setLogger(new MavenEmbedderConsoleLogger());
    for (String goal : goals) {
      try {
        maven.start();
        File targetDirectory = new File(System.getProperty("user.dir"), "work");
        File pomFile = new File(targetDirectory, "pom.xml");
        MavenProject pom;
        pom = maven.readProjectWithDependencies(pomFile);
        EventMonitor eventMonitor =
            new DefaultEventMonitor(new PlexusLoggerAdapter(new MavenEmbedderConsoleLogger()));
        maven.execute(
            pom,
            Collections.singletonList(goal),
            eventMonitor,
            new ConsoleDownloadMonitor(),
            null,
            targetDirectory);
      } catch (MavenEmbedderException e) {
        e.printStackTrace();
      } catch (ArtifactResolutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ArtifactNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ProjectBuildingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (CycleDetectedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (LifecycleExecutionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (BuildFailureException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (DuplicateProjectException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }