当前位置: 首页 > 知识库问答 >
问题:

sonar-maven-plugin:无法设置sonar.sources src/main/resources

穆智刚
2023-03-14

我对Maven声纳设置有问题。我需要在src/main/java和src/main/resources中包含我的所有项目文件,以便SonarQube将显示所有文件的结果,但排除src/main/resources/static/file中的一些文件。对于测试路径,它已经在src/test/java中默认设置

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.1.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->

    <!-- Sonar static analysis / Jacoco code coverage -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <start-class>com.Example.wp.WpCoreApplication</start-class>
    <java.version>1.8</java.version>
    <sonar.sources>src/main/java, src/main/resources</sonar.sources>
    <sonar.exclusions>src/main/resources/static/file</sonar.exclusions>
</properties>

<dependencies>
    <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-cassandra</artifactId> 
        </dependency> -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-neo4j</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.debatty</groupId>
        <artifactId>java-string-similarity</artifactId>
        <version>RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.11</version>
    </dependency>
</dependencies>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.7.2</version>
        </plugin>
    </plugins>
</reporting>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.19.1</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <argLine>${jacoco.agent.argLine}</argLine>
                    <skipTests>false</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
            </plugin>
            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>3.1.1</version>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.7.201606060606</version>
            <configuration>
                <dataFile>target/jacoco.exec</dataFile>
            </configuration>
            <executions>
                <execution>
                    <id>jacoco-initialize</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <propertyName>jacoco.agent.argLine</propertyName>
                        <destFile>target/jacoco.exec</destFile>
                    </configuration>
                </execution>
                <execution>
                    <id>jacoco-report</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>rpm-maven-plugin</artifactId>
            <version>2.1-alpha-3</version>
            <executions>
                <execution>
                    <id>attach-rpm</id>
                    <goals>
                        <goal>attached-rpm</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

但是当我用命令提示符运行我的maven-sonar时:mvn Sonar:Sonar。有这样的错误日志

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.865 s
[INFO] Finished at: 2016-11-28T14:46:40+07:00
[INFO] Final Memory: 68M/449M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:
3.1.1:sonar (default-cli) on project wp: The directory 'D:\PROJECT\wp-core\
src\main\resources' does not exist for Maven module com.sample:wp:jar:0.1.26. Pleas
e check the property sonar.sources -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception

我如何设置声纳,以便它可以扫描我所有的文件?我已经查看了文档和这个Stackoverflow

共有1个答案

卫阳炎
2023-03-14

您可能应该移除多余的空间。改变

<sonar.sources>src/main/java, src/main/resources</sonar.sources>

<sonar.sources>src/main/java,src/main/resources</sonar.sources>
 类似资料:
  • sonar-wordcheck-plugin 是一款用于 SonarQube 的高性能敏感词检测插件,支持代码内容检测、代码注释检测功能。 本插件是基于SonarQube代码质量检测工具编写的一个为了检测用户项目的代码及注释中是否包含敏感词(带有敏感政治倾向、暴力倾向、不健康色彩的词或不文明语等)的插件,通过sonar-scanner工具扫描项目后,若存在敏感词,在sonarqube管理平台的项目

  • 我正在使用Intellij IDEA 2016.1在一个导入的Maven项目中工作。Intellij只抱怨sonar maven插件。 我已经尝试在maven选项中重新导入,但Intellij仍然对这个插件感到疯狂。 Intellij中的错误信息是:未解决的插件org.codehaus.mojo: sonar-maven-plugin: 3.0.1

  • 在eclipse内部,当我做maven->Update项目时,我遇到了以下问题 我尝试了这里提供的解决方案无法计算构建计划:artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3在本地存储库中不可用 并且更新了我的Maven项目,但是我仍然遇到同样的问题,即使我试图在pom.xml文件中添加依赖项,但是没有成功地解决这个

  • 我正在尝试用Maven安装UIMA JDK。然而,总有一个警告 请帮助我解决此问题

  • 问题内容: 即使清除了settings.xml,尝试使用此快照依赖项时仍然出现此错误。给定依赖性: 并且(在POM中),插件存储库定义: 我留下了以下404错误。如果我实际导航到该存储库,那么它所寻找的jar就不存在了,只是陈旧的(我不熟悉Maven最终解析期望的依赖项名称的机制)。 有想法吗? 问题答案: 我重新检查了以下pom片段: 插件的SNAPSHOT已成功下载: 这很奇怪,因为我看不到任

  • 这是一个 Sonar 的插件,实现对 Objective-C 语言的分析。可分析角度包括: Complexity Design Documentation Duplications Issues Size Tests