簡體   English   中英

Maven Checkstyle https配置

[英]Maven checkstyle https configuration

我有以下Maven Check Style插件配置

<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>

注意

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

可以通過瀏覽器下載file.xml,但需要登錄名和密碼。 有沒有辦法在Maven或插件配置中指定這些登錄名/密碼?

在下面,它使用Plexus ,而Plexus幾乎執行URL.openStream()

這個答案顯示了如何在Java代碼中將Authenticator用於此目的,但是我找不到與之對應的Maven。 我傾向於說這是不可能的。

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

我認為這個答案給出了一些有關如何在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的根目錄中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM