2016-08-15 1574 views
0

我一直無法使用checkstyle檢查目標。我收到以下錯誤:Maven checkstyle插件 - 檢查目標找不到配置文件

Unable to find configuration file at location: ${project.parent.basedir}/.settings/my_checks.xml: Could not find resource '${project.parent.basedir}/.settings/my_checks.xml'.

我得到這個錯誤,當我使用命令mvn checkstyle:check,但如果我跑mvn checkstyle:checkstyle這個配置文件被發現,作爲預期。

插件配置如下所示。

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-checkstyle-plugin</artifactId> 
      <version>2.17</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>check</goal> 
        </goals> 
        <phase>test</phase> 
       </execution> 
      </executions>   
     </plugin> 

... 

    <properties> 
     <checkstyle.config.location>${project.parent.basedir}/.settings/my_checks.xml</checkstyle.config.location>   
    </properties> 

有什麼建議嗎?爲什麼checkstyle目標能夠工作,而不是檢查目標?

編輯:經過進一步審查,我瞭解到$ {project.parent.basedir}在運行檢查目標時不能解決。它在調用checkstyle目標時確實解決了。仍在尋找建議/解決方法...

回答

0

我的解決方法是使用$ {project.parent.basedir}變量並使用相對路徑。這適用於我的情況,因爲我所有的模塊都是並行目錄。

<checkstyle.config.location>../parent/.settings/my_checks.xml</checkstyle.config.location>