Ejemplo n.º 1
0
 private void addSubProjects(Project project, List<Resource> subProjects) {
   for (Project subProject : project.getModules()) {
     Project indexedSubProject = (Project) index.getResource(subProject);
     if (indexedSubProject != null) {
       subProjects.add(indexedSubProject);
     }
     addSubProjects(subProject, subProjects);
   }
 }
Ejemplo n.º 2
0
  void doStart(Project rootProject) {
    Bucket bucket = new Bucket(rootProject);
    buckets.put(rootProject, bucket);
    persistence.saveProject(rootProject, null);
    currentProject = rootProject;

    for (Project project : rootProject.getModules()) {
      addProject(project);
    }
  }
Ejemplo n.º 3
0
 private void addModule(Project parent, Project module) {
   ProjectDefinition parentDefinition = projectTree.getProjectDefinition(parent);
   java.io.File parentBaseDir = parentDefinition.getBaseDir();
   ProjectDefinition moduleDefinition = projectTree.getProjectDefinition(module);
   java.io.File moduleBaseDir = moduleDefinition.getBaseDir();
   module.setPath(new PathResolver().relativePath(parentBaseDir, moduleBaseDir));
   addResource(module);
   for (Project submodule : module.getModules()) {
     addModule(module, submodule);
   }
 }
Ejemplo n.º 4
0
  void doStart(Project rootProject) {
    Bucket bucket = new Bucket(rootProject);
    addBucket(rootProject, bucket);
    BatchComponent component = componentCache.add(rootProject, null);
    component.setInputComponent(new DefaultInputModule(rootProject.getEffectiveKey()));
    currentProject = rootProject;

    for (Project module : rootProject.getModules()) {
      addModule(rootProject, module);
    }
  }
Ejemplo n.º 5
0
  void doStart(Project rootProject) {
    Bucket bucket = new Bucket(rootProject);
    addBucket(rootProject, bucket);
    if (migration != null) {
      migration.checkIfMigrationNeeded(rootProject);
    }
    resourceCache.add(rootProject, null);
    currentProject = rootProject;

    for (Project module : rootProject.getModules()) {
      addModule(rootProject, module);
    }
  }
  @Test
  public void testSimpleProject() throws InterruptedException {

    final Project project = mockProject("project", true);
    when(project.getModules()).thenReturn(Collections.<Project>emptyList());

    fakeAnalysis(profiler, project);

    assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.MAVEN).totalTime())
        .isEqualTo(4L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.INIT)
                .getProfilingPerItem(new FakeInitializer())
                .totalTime())
        .isEqualTo(7L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.SENSOR)
                .getProfilingPerItem(new FakeSensor())
                .totalTime())
        .isEqualTo(10L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.DECORATOR)
                .getProfilingPerItem(new FakeDecorator1())
                .totalTime())
        .isEqualTo(20L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.PERSISTER)
                .getProfilingPerItem(new FakeScanPersister())
                .totalTime())
        .isEqualTo(40L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.POSTJOB)
                .getProfilingPerItem(new FakePostJob())
                .totalTime())
        .isEqualTo(30L);
    assertThat(profiler.currentModuleProfiling.getProfilingPerBatchStep("Free memory").totalTime())
        .isEqualTo(9L);
  }
  @Test
  public void testMultimoduleProject() throws InterruptedException {
    final Project project = mockProject("project root", true);
    final Project moduleA = mockProject("moduleA", false);
    final Project moduleB = mockProject("moduleB", false);
    when(project.getModules()).thenReturn(Arrays.asList(moduleA, moduleB));

    fakeAnalysis(profiler, moduleA);
    fakeAnalysis(profiler, moduleB);
    fakeAnalysis(profiler, project);

    assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.MAVEN).totalTime())
        .isEqualTo(4L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.INIT)
                .getProfilingPerItem(new FakeInitializer())
                .totalTime())
        .isEqualTo(7L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.SENSOR)
                .getProfilingPerItem(new FakeSensor())
                .totalTime())
        .isEqualTo(10L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.DECORATOR)
                .getProfilingPerItem(new FakeDecorator1())
                .totalTime())
        .isEqualTo(20L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.DECORATOR)
                .getProfilingPerItem(new FakeDecorator2())
                .totalTime())
        .isEqualTo(10L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.PERSISTER)
                .getProfilingPerItem(new FakeScanPersister())
                .totalTime())
        .isEqualTo(40L);
    assertThat(
            profiler
                .currentModuleProfiling
                .getProfilingPerPhase(Phase.POSTJOB)
                .getProfilingPerItem(new FakePostJob())
                .totalTime())
        .isEqualTo(30L);

    assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.MAVEN).totalTime())
        .isEqualTo(12L);
    assertThat(
            profiler
                .totalProfiling
                .getProfilingPerPhase(Phase.INIT)
                .getProfilingPerItem(new FakeInitializer())
                .totalTime())
        .isEqualTo(21L);
    assertThat(
            profiler
                .totalProfiling
                .getProfilingPerPhase(Phase.SENSOR)
                .getProfilingPerItem(new FakeSensor())
                .totalTime())
        .isEqualTo(30L);
    assertThat(
            profiler
                .totalProfiling
                .getProfilingPerPhase(Phase.DECORATOR)
                .getProfilingPerItem(new FakeDecorator1())
                .totalTime())
        .isEqualTo(60L);
    assertThat(
            profiler
                .totalProfiling
                .getProfilingPerPhase(Phase.DECORATOR)
                .getProfilingPerItem(new FakeDecorator2())
                .totalTime())
        .isEqualTo(30L);
    assertThat(
            profiler
                .totalProfiling
                .getProfilingPerPhase(Phase.PERSISTER)
                .getProfilingPerItem(new FakeScanPersister())
                .totalTime())
        .isEqualTo(120L);
    assertThat(
            profiler
                .totalProfiling
                .getProfilingPerPhase(Phase.POSTJOB)
                .getProfilingPerItem(new FakePostJob())
                .totalTime())
        .isEqualTo(90L);
  }
Ejemplo n.º 8
0
 private void scanRecursively(Project module) {
   for (Project subModules : module.getModules()) {
     scanRecursively(subModules);
   }
   scan(module);
 }
Ejemplo n.º 9
0
 private void addProject(Project project) {
   addResource(project);
   for (Project module : project.getModules()) {
     addProject(module);
   }
 }
Ejemplo n.º 10
0
 public boolean shouldExecuteOnProject(Project project) {
   // Should be only executed on leaf modules
   return project.getModules().isEmpty();
 }