我想将静态 html 网页作为 maven 项目。我已经完成了本教程http://www.doclo.be/lieven/articles/personalsitewithmaven.html 中建议的项目。
我已将具有完整结构的静态 html 网页复制到 src/site/resources 目录中,并删除了 src/site 目录(而不是资源目录)中的所有文件/目录。
我在名为 maven-linkcheck-plugin 的报告部分插件中添加了 pom.xml 文件(它的用法在http://maven.apache.org/plugins/maven-linkcheck-plugin/usage.html上有描述)。
我想在项目中有类似 surefire 插件的东西,如果生成的网页上的链接有任何错误,它将导致构建失败。linkcheck 插件似乎只检查链接的有效性,并尝试检索所有链接的头部。例如,当引用不存在的 pdf 文件时,它不会产生任何错误。
要拥有我的项目,只需执行以下操作:
mvn archetype:create -DgroupId=com.mypage -DartifactId=mypage -DarchetypeArtifactId=maven-archetype-site-simple
cd mypage
rm -r src/site/*
mkdir src/site/resources
echo "<h1>my last web page, I promisse</h1> <a href="relativeUrlToNonexistentPage.html">Link text</a>" > src/site/resources/index.html
Run Code Online (Sandbox Code Playgroud)
比编辑 pom.xml 并在那里添加:
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.7</version>
<reportSets>
<reportSet>
<reports />
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-linkcheck-plugin</artifactId>
<version>1.1</version>
<configuration>
<excludedLinks>
<excludedLink>https://trackit.sk/app</excludedLink>
</excludedLinks>
</configuration>
</plugin> …Run Code Online (Sandbox Code Playgroud)