Search in sources :

Example 11 with DefaultInputProject

use of org.sonar.api.batch.fs.internal.DefaultInputProject in project sonarqube by SonarSource.

the class ProjectLockTest method setUp.

@Before
public void setUp() throws IOException {
    baseDir = tempFolder.newFolder();
    worDir = new File(baseDir, ".sonar");
    lock = new ProjectLock(new DefaultInputProject(ProjectDefinition.create().setBaseDir(baseDir).setWorkDir(worDir)));
}
Also used : DefaultInputProject(org.sonar.api.batch.fs.internal.DefaultInputProject) File(java.io.File) Before(org.junit.Before)

Example 12 with DefaultInputProject

use of org.sonar.api.batch.fs.internal.DefaultInputProject in project sonarqube by SonarSource.

the class DefaultInputProjectTest method testGetters.

@Test
public void testGetters() throws IOException {
    ProjectDefinition def = ProjectDefinition.create();
    def.setKey("projectKey");
    def.setName("projectName");
    File baseDir = temp.newFolder();
    def.setBaseDir(baseDir);
    def.setDescription("desc");
    File workDir = temp.newFolder();
    def.setWorkDir(workDir);
    def.setSources("file1");
    def.setTests("test1");
    AbstractProjectOrModule project = new DefaultInputProject(def);
    assertThat(project.key()).isEqualTo("projectKey");
    assertThat(project.getName()).isEqualTo("projectName");
    assertThat(project.getOriginalName()).isEqualTo("projectName");
    assertThat(project.definition()).isEqualTo(def);
    assertThat(project.getBaseDir()).isEqualTo(baseDir.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS));
    assertThat(project.getDescription()).isEqualTo("desc");
    assertThat(project.getWorkDir()).isEqualTo(workDir.toPath());
    assertThat(project.getEncoding()).isEqualTo(Charset.defaultCharset());
    assertThat(project.properties()).hasSize(5);
    assertThat(project.isFile()).isFalse();
}
Also used : DefaultInputProject(org.sonar.api.batch.fs.internal.DefaultInputProject) AbstractProjectOrModule(org.sonar.api.batch.fs.internal.AbstractProjectOrModule) File(java.io.File) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 13 with DefaultInputProject

use of org.sonar.api.batch.fs.internal.DefaultInputProject in project sonarqube by SonarSource.

the class InputProjectProvider method provide.

@Bean("DefaultInputProject")
public DefaultInputProject provide(ProjectBuildersExecutor projectBuildersExecutor, ProjectReactorValidator validator, ProjectReactor projectReactor, ScannerComponentIdGenerator scannerComponentIdGenerator, WorkDirectoriesInitializer workDirectoriesInit) {
    // 1 Apply project builders
    projectBuildersExecutor.execute(projectReactor);
    // 2 Validate final reactor
    validator.validate(projectReactor);
    // 3 Create project
    DefaultInputProject project = new DefaultInputProject(projectReactor.getRoot(), scannerComponentIdGenerator.getAsInt());
    workDirectoriesInit.execute(project);
    LOG.info("Project key: {}", project.key());
    LOG.info("Base dir: {}", project.getBaseDir().toAbsolutePath().toString());
    LOG.info("Working dir: {}", project.getWorkDir().toAbsolutePath().toString());
    LOG.debug("Project global encoding: {}, default locale: {}", project.getEncoding().displayName(), Locale.getDefault());
    return project;
}
Also used : DefaultInputProject(org.sonar.api.batch.fs.internal.DefaultInputProject) Bean(org.springframework.context.annotation.Bean)

Example 14 with DefaultInputProject

use of org.sonar.api.batch.fs.internal.DefaultInputProject in project sonarqube by SonarSource.

the class CpdExecutorTest method setUp.

@Before
public void setUp() throws IOException {
    File outputDir = temp.newFolder();
    baseDir = temp.newFolder();
    when(publisher.getWriter()).thenReturn(new ScannerReportWriter(outputDir));
    DefaultInputProject project = TestInputFileBuilder.newDefaultInputProject("foo", baseDir);
    componentStore = new InputComponentStore(mock(BranchConfiguration.class), sonarRuntime);
    executor = new CpdExecutor(settings, index, publisher, componentStore, executorService);
    reader = new ScannerReportReader(outputDir);
    batchComponent1 = createComponent("src/Foo.php", 5);
    batchComponent2 = createComponent("src/Foo2.php", 5);
    batchComponent3 = createComponent("src/Foo3.php", 5);
}
Also used : ScannerReportReader(org.sonar.scanner.protocol.output.ScannerReportReader) DefaultInputProject(org.sonar.api.batch.fs.internal.DefaultInputProject) InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Before(org.junit.Before)

Aggregations

DefaultInputProject (org.sonar.api.batch.fs.internal.DefaultInputProject)14 Test (org.junit.Test)8 File (java.io.File)7 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)7 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)6 InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)6 Before (org.junit.Before)5 ScannerReportReader (org.sonar.scanner.protocol.output.ScannerReportReader)5 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)4 ProjectInfo (org.sonar.scanner.ProjectInfo)4 AbstractProjectOrModule (org.sonar.api.batch.fs.internal.AbstractProjectOrModule)3 Component (org.sonar.scanner.protocol.output.ScannerReport.Component)3 ScannerReportWriter (org.sonar.scanner.protocol.output.ScannerReportWriter)3 BranchConfiguration (org.sonar.scanner.scan.branch.BranchConfiguration)3 Path (java.nio.file.Path)2 InputFile (org.sonar.api.batch.fs.InputFile)2 LinkedList (java.util.LinkedList)1 SonarRuntime (org.sonar.api.SonarRuntime)1 InputPath (org.sonar.api.batch.fs.InputPath)1 DefaultInputModule (org.sonar.api.batch.fs.internal.DefaultInputModule)1