use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class ProjectReactorBuilderTest method shouldDefineMultiModuleProjectWithBaseDir.
@Test
public void shouldDefineMultiModuleProjectWithBaseDir() {
ProjectDefinition rootProject = loadProjectDefinition("multi-module-with-basedir");
List<ProjectDefinition> modules = rootProject.getSubProjects();
assertThat(modules.size()).isEqualTo(1);
assertThat(modules.get(0).getKey()).isEqualTo("com.foo.project:com.foo.project.module1");
}
use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class ProjectReactorBuilderTest method shouldDefineMultiLanguageProjectWithDefinitionsAllInRootProject.
// SONARPLUGINS-2421
@Test
public void shouldDefineMultiLanguageProjectWithDefinitionsAllInRootProject() throws IOException {
ProjectDefinition rootProject = loadProjectDefinition("multi-language-definitions-all-in-root");
// CHECK ROOT
assertThat(rootProject.getKey()).isEqualTo("example");
assertThat(rootProject.getName()).isEqualTo("Example");
assertThat(rootProject.getVersion()).isEqualTo("1.0");
// CHECK MODULES
List<ProjectDefinition> modules = rootProject.getSubProjects();
assertThat(modules.size()).isEqualTo(2);
// Module 1
ProjectDefinition module1 = modules.get(0);
assertThat(module1.getBaseDir().getCanonicalFile()).isEqualTo(getResource(this.getClass(), "multi-language-definitions-all-in-root"));
assertThat(module1.sources()).contains("src/main/java");
// and module properties must have been cleaned
assertThat(module1.getWorkDir().getCanonicalFile()).isEqualTo(new File(getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_java-module"));
// Module 2
ProjectDefinition module2 = modules.get(1);
assertThat(module2.getBaseDir().getCanonicalFile()).isEqualTo(getResource(this.getClass(), "multi-language-definitions-all-in-root"));
assertThat(module2.sources()).contains("src/main/groovy");
// and module properties must have been cleaned
assertThat(module2.getWorkDir().getCanonicalFile()).isEqualTo(new File(getResource(this.getClass(), "multi-language-definitions-all-in-root"), ".sonar/example_groovy-module"));
}
use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class ProjectReactorBuilderTest method shouldDefineMultiModuleProjectWithPomFileAtRootLevel.
@Test
public void shouldDefineMultiModuleProjectWithPomFileAtRootLevel() throws IOException {
ProjectDefinition project = execMultiModule("multi-module-pom-in-root");
assertThat(project.sources()).containsExactlyInAnyOrder("pom.xml", "sources");
}
use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class RenameProject method build.
@Override
protected void build(ProjectReactor reactor) {
if (!settings.getBoolean("sonar.enableProjectBuilder")) {
return;
}
System.out.println("---> Renaming project");
// change name of root project
ProjectDefinition root = reactor.getRoot();
root.setName("Name changed by plugin");
}
use of org.sonar.api.batch.bootstrap.ProjectDefinition in project sonarqube by SonarSource.
the class CreateSubProjects method createSubProjectWithSourceDir.
private ProjectDefinition createSubProjectWithSourceDir(ProjectDefinition root) {
File baseDir = new File(root.getBaseDir(), "module_a");
ProjectDefinition subProject = ProjectDefinition.create();
subProject.setBaseDir(baseDir).setWorkDir(new File(baseDir, "target/.sonar"));
subProject.setKey("com.sonarsource.it.projects.batch:project-builder-module-a");
subProject.setVersion(root.getVersion());
subProject.setName("Module A");
subProject.addSources("src");
root.addSubProject(subProject);
return subProject;
}
Aggregations