2013-06-04 79 views
1

我使用jenkins通過maven持續整合構建過程,並使用聲納進行代碼評審。詹金斯就業工作正常創建構建但聲納分析開始時,它拋出下面的錯誤..Sonar Squid通過maven與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:源目錄不符合包聲明software.bean 「 我在這個stucked問題。

下面

是我的項目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> 
+0

將'source directory'和'resource directory'定義到同一個'src'目錄的原因是什麼? –

+0

感謝您的意見charlee,我能夠解決這個問題。 –

回答

1

此錯誤意味着「的.java」源文件沒有位於正確的文件夾。

如果您的項目是Maven項目,那麼「.java」源文件可能位於<project>/src/main/java之內 - 就像約定所暗示的那樣。

但是,從我在POM中看到的內容來看,您已將源文件夾設置爲「src」而不是「src/main/java」。這就是你得到這個錯誤的原因。