简体   繁体   English

通过Maven与詹金斯·乔纳进行声纳分析时声纳鱿鱼错误

[英]Sonar Squid Error while sonar analysis with jenkins job through maven

I am using jenkins for continous integration build process through maven and using sonar for code review as well. 我正在使用jenkins通过maven进行持续集成构建过程,并使用声纳进行代码审查。 jenkins job is working fine for creating build but when sonar analysis starts, it throw below error.. jenkins作业可以很好地用于创建构建,但是当声纳分析开始时,它会抛出错误。

[ERROR] [19:19:47.494] Squid Error occurs when analysing :D:\Jenkins_New\jobs\Sample_Maven_Project\workspace\src\main\java\software\bean\UserBean.java

org.sonar.squid.api.AnalysisException: The source directory does not correspond to the package declaration software.bean " I'm stucked in this issue. org.sonar.squid.api.AnalysisException:源目录与软件包声明software.bean不对应。

below is my project pom.xml file 下面是我的项目pom.xml文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>nuc</groupId>
    <artifactId>nuc</artifactId>
    <version>0.1</version>
    <packaging>war</packaging>
    <name>nuc</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>neutrino-central-repository-Nexus</id>
            <name>Neutrino Central Repository</name>
            <url>http://10.1.50.56:9081/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>neutrino-central-plugin-repository-Nexus</id>
            <url>http://10.1.50.56:9081/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>

            <resource>
                <directory>WebContent</directory>
                <targetPath>/${project.build.directory}/${project.build.finalName}</targetPath> 
                <includes>
                    <include>**/*.*</include>
                </includes>
            </resource>



            <resource>
                <directory>src/META-INF</directory>
                <targetPath>/${project.build.directory}/META-INF</targetPath>
            </resource>
        </resources>
        <plugins>
        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
        </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
                    <webXml>WebContent/WEB-INF/web.xml</webXml>
                                    </configuration>
            </plugin>
        </plugins>
    </build>
</project>

This error means that the ".java" source files are not located in a correct folder. 此错误意味着“ .java”源文件不在正确的文件夹中。

If your project is a Maven project, chances are that the ".java" source files are located in <project>/src/main/java - like the convention suggests it. 如果您的项目是Maven项目,则“ .java”源文件很可能位于<project>/src/main/java -就像约定所建议的那样。

However, from what I see in your POM, you have set the source folder to be "src" instead of "src/main/java". 但是,根据我在POM中看到的内容,已将源文件夹设置为“ src”,而不是“ src / main / java”。 This is why you get this error. 这就是为什么您会收到此错误的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM