Package org.sonar.runner.api

Examples of org.sonar.runner.api.ForkedRunner$ForkCommand


        this.analysisMode = analysisMode;
    }

    protected Runner createForProject(UserCredentials userCredentials, ProcessMonitor processMonitor) throws MvnModelInputException {
        int sourcesCounter = 0;
        ForkedRunner runner = ForkedRunner.create(processMonitor);
        projectHome = project.getProjectDirectory().getPath();
        Model model = mvnModelFactory.createModel(project);
        properties.setProperty("sonar.projectName", model.getName() != null ? model.getName() : model.getArtifactId());
        properties.setProperty("sonar.projectBaseDir", projectHome);
        properties.setProperty("sonar.projectVersion", model.getVersion());
        properties.setProperty("sonar.sourceEncoding", FileEncodingQuery.getEncoding(project.getProjectDirectory()).displayName());
        properties.setProperty("sonar.host.url", sonarUrl);
        properties.setProperty("sonar.java.source", SourceLevelQuery.getSourceLevel(project.getProjectDirectory()));
        int version = getMajorVersion(new SonarQube(sonarUrl).getVersion(userCredentials));
        if (version >= 4) {
            properties.setProperty("sonar.analysis.mode", analysisMode.toString().toLowerCase());
        } else {
            properties.setProperty("sonar.dryRun", "true");
        }
        properties.setProperty("sonar.projectDir", projectHome);
        properties.setProperty("project.home", projectHome);
        properties.setProperty("sonar.working.directory", projectHome + "/./.sonar");
        if (userCredentials != null) {
            properties.setProperty("sonar.login", userCredentials.getUsername());
            properties.setProperty("sonar.password", PassEncoder.decodeAsString(userCredentials.getPassword()));
        }
        boolean containsSources = configureSourcesAndBinariesProperties(null, project);
        if(containsSources) {
            sourcesCounter++;
        }

        SubprojectProvider subprojectProvider = project.getLookup().lookup(SubprojectProvider.class);
        boolean hasSubprojects = false;
        if (subprojectProvider != null) {
            Set<? extends Project> subprojects = subprojectProvider.getSubprojects();
            hasSubprojects = !subprojects.isEmpty();
            for (Project subproject : subprojects) {
                String module = subproject.getProjectDirectory().getNameExt();
                boolean moduleContainsSources = addModuleProperties(module, subproject);
                if (moduleContainsSources) {
                    if (modules.length() > 0) {
                        modules.append(',');
                    }
                    modules.append(module);
                    sourcesCounter++;
                }
            }
        }
        if (sourcesCounter == 0) {
            throw new SourcesNotFoundException();
        }
        String projectKey = model.getGroupId();
        if (!hasSubprojects) {
            projectKey += ":" + model.getArtifactId();
        }
        properties.setProperty("sonar.projectKey", projectKey);
        if (modules.length() > 0) {
            properties.setProperty("sonar.modules", modules.toString());
        }
        if (outConsumer != null) {
            runner.setStdOut(outConsumer);
        }
        wrapper = new WrapperConsumer(errConsumer);
        runner.setStdErr(wrapper);
        runner.addProperties(properties);
        return runner;
    }
View Full Code Here

TOP

Related Classes of org.sonar.runner.api.ForkedRunner$ForkCommand

Copyright © 2018 www.massapicom. 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.