1. 程式人生 > 實用技巧 >[Maven][maven-site-plugin]告警[WARNING] No project URL defined - decoration links will not be relativized

[Maven][maven-site-plugin]告警[WARNING] No project URL defined - decoration links will not be relativized

pom.xml中添加了maven-shade-plugin配置,片段如下:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.9.0</version>
                <configuration>
                    <locales>en_US</locales>
                    <outputDirectory>${project.build.directory}/site</outputDirectory>
                </configuration>
            </plugin>

執行mvn clean package site時報錯[WARNING] No project URL defined - decoration links will not be relativized!,詳細報錯如下:

[INFO] --- maven-site-plugin:3.9.0:site (default-site) @ APKToolBoxGUI ---
...
[INFO] Rendering site with default locale English (United States) (en_US)
[WARNING] No project URL defined - decoration links will not be relativized!
[INFO] Rendering content with org.apache.maven.skins:maven-default-skin:jar:1.3 skin.

這個WARNING指maven-site-plugin有個功能就是幫你將生成的site資訊中的絕對路徑改為相對路徑,比如地址是https://jiangxincode.github.io/ApkToolBoxGUI/findbugs.html,且知道基礎路徑是<https://jiangxincode.github.io/ApkToolBoxGUI那麼就可以幫你把地址改成相對的findbugs.html。預設情況下這個功能是開啟的,但是你如果沒有制定基礎路徑,外掛就沒有辦法幫你將絕對路徑改為相對路徑,所以會給出一個WARNING,詳細資訊可以檢視官網:http://maven.apache.org/plugins/maven-site-plugin/site-mojo.html

。原因知道了,解決方案就簡單了,如果你不需要改功能就直接通過配置關閉就可以了。

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.9.0</version>
                <configuration>
                    <locales>en_US</locales>
                    <outputDirectory>${project.build.directory}/site</outputDirectory>
                    <relativizeDecorationLinks>false</relativizeDecorationLinks>
                </configuration>
            </plugin>