2013-10-17 47 views
2

我已經Maven的CheckStyle的HTTPS配置

<configLocation>https://someUtl.com/file.xml</configLocation> 

file.xml以下Maven檢查風格插件配置

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-checkstyle-plugin</artifactId> 
    <configuration> 
     <consoleOutput>true</consoleOutput> 
     <configLocation>https://someUtl.com/file.xml</configLocation> 
    </configuration> 
    <executions> 
     <execution> 
      <phase>package</phase> 
      <goals> 
       <goal>check</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

注重可通過瀏覽器下載,但它需要一個登錄名和密碼。有沒有辦法在maven或插件配置中指定這些登錄名/密碼?

回答

3

在下面,這使用Plexus,而這幾乎是URL.openStream()

This answer顯示瞭如何在Java代碼中使用Authenticator,但是我無法找到相應的Maven等價物。我傾向於說這是不可能的。

或者,您可以在單獨的mojo執行中下載文件,然後將configLocation指向下載的文件,該文件可能位於target文件夾的任何位置。

我認爲this answer給出了一些關於如何在Maven中下載文件的好主意。他們的第一個原因是如果你的文件是一個Maven工件,你可以使用Maven Dependency Plugin

然後我們走完整圈,因爲如果您的Checkstyle配置包含在Maven工件中,您不必將configLocation設置爲遠程位置,但是您會將該工件添加爲Checkstyle的dependency插件執行。由於Maven根據依賴關係來定義所有內容,這就是我的出路,而這正是我如何設置自己的Checkstyle配置。

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-checkstyle-plugin</artifactId> 
    <executions> 
     <execution> 
     <goals> 
      <goal>check</goal> 
     </goals> 
     </execution> 
    </executions> 
    <dependencies> 
     <dependency> 
     <groupId>com.totaalsoftware.incidentmanager</groupId> 
     <artifactId>checkstyle-config</artifactId> 
     <version>2.0.0-SNAPSHOT</version> 
     </dependency> 
    </dependencies> 
    <configuration> 
     <configLocation>checkstyle.config.xml</configLocation> 
     ... 
    </configuration> 
    </plugin> 

顯然,在上述實例中,checkstyle.config.xml駐留在checkstyle-config JAR的根。