Examples of ProjectDefinition


Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

      rebuildModuleHierarchy(paths, defs);
    } catch (IOException e) {
      throw new IllegalStateException("Cannot configure project", e);
    }

    ProjectDefinition rootProject = defs.get(root);
    if (rootProject == null) {
      throw new IllegalStateException(UNABLE_TO_DETERMINE_PROJECT_STRUCTURE_EXCEPTION_MESSAGE);
    }
    return rootProject;
  }
View Full Code Here

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

      for (Object m : pom.getModules()) {
        String moduleId = (String) m;
        File modulePath = new File(pom.getBasedir(), moduleId);
        MavenProject module = findMavenProject(modulePath, paths);

        ProjectDefinition parentProject = defs.get(pom);
        if (parentProject == null) {
          throw new IllegalStateException(UNABLE_TO_DETERMINE_PROJECT_STRUCTURE_EXCEPTION_MESSAGE);
        }
        ProjectDefinition subProject = defs.get(module);
        if (subProject == null) {
          throw new IllegalStateException(UNABLE_TO_DETERMINE_PROJECT_STRUCTURE_EXCEPTION_MESSAGE);
        }
        parentProject.addSubProject(subProject);
      }
View Full Code Here

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

  }

  private void configureModules(List<MavenProject> poms, Map<String, MavenProject> paths, Map<MavenProject, ProjectDefinition> defs) throws IOException {
    for (MavenProject pom : poms) {
      paths.put(pom.getFile().getCanonicalPath(), pom);
      ProjectDefinition def = ProjectDefinition.create();
      merge(pom, def);
      defs.put(pom, def);
    }
  }
View Full Code Here

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

      projectsByDef.put(def, project);
      projects.add(project);
    }

    for (Map.Entry<ProjectDefinition, Project> entry : projectsByDef.entrySet()) {
      ProjectDefinition def = entry.getKey();
      Project project = entry.getValue();
      for (ProjectDefinition module : def.getSubProjects()) {
        projectsByDef.get(module).setParent(project);
      }
    }

    // Configure
View Full Code Here

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

      bucketsByDeprecatedKey.put(resource.getDeprecatedKey(), bucket);
    }
  }

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

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

  /**
   * From root to given project
   */
  static List<ProjectDefinition> getTopDownParentProjects(ProjectDefinition project) {
    List<ProjectDefinition> result = Lists.newArrayList();
    ProjectDefinition p = project;
    while (p != null) {
      result.add(0, p);
      p = p.getParent();
    }
    return result;
  }
View Full Code Here

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

  @Rule
  public ExpectedException thrown = ExpectedException.none();

  @Test
  public void bootstrap() throws Exception {
    ProjectDefinition def = mock(ProjectDefinition.class);
    MavenSession session = mock(MavenSession.class);
    MavenProject rootProject = new MavenProject();
    rootProject.setExecutionRoot(true);
    List<MavenProject> projects = Arrays.asList(rootProject);
    when(session.getSortedProjects()).thenReturn(projects);
View Full Code Here

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

  @Test
  public void test_default_directories() throws Exception {
    File baseDir = temp.newFolder("base");
    File workDir = temp.newFolder("work");
    ProjectDefinition module = ProjectDefinition.create().setBaseDir(baseDir).setWorkDir(workDir);

    ModuleFileSystemInitializer initializer = new ModuleFileSystemInitializer(module, mock(TempFolder.class), pathResolver);

    assertThat(initializer.baseDir().getCanonicalPath()).isEqualTo(baseDir.getCanonicalPath());
    assertThat(initializer.workingDir().getCanonicalPath()).isEqualTo(workDir.getCanonicalPath());
View Full Code Here

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

    File testDir = new File(baseDir, "src/test/java");
    FileUtils.forceMkdir(testDir);
    File binaryDir = new File(baseDir, "target/classes");
    FileUtils.forceMkdir(binaryDir);

    ProjectDefinition project = ProjectDefinition.create()
      .setBaseDir(baseDir)
      .setBuildDir(buildDir)
      .addSourceDirs("src/main/java", "src/main/unknown")
      .addTestDirs("src/test/java", "src/test/unknown")
      .addBinaryDir("target/classes");
View Full Code Here

Examples of org.sonar.api.batch.bootstrap.ProjectDefinition

    assertThat(module2.getProperties().getProperty("module2.sonar.projectKey")).isNull();
  }

  @Test
  public void shouldDefineMultiModuleProjectWithConfigFile() throws IOException {
    ProjectDefinition rootProject = loadProjectDefinition("multi-module-with-configfile");
    List<ProjectDefinition> modules = rootProject.getSubProjects();
    assertThat(modules.size()).isEqualTo(1);
    ProjectDefinition module = modules.get(0);
    assertThat(module.getKey()).isEqualTo("com.foo.project:com.foo.project.module1");
    // verify the base directory that has been changed in this config file
    assertThat(module.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-module-with-configfile/any-folder"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.