我正在尝试将 Google Analytics 跟踪注入(inject)到我的 javadoc 中,但它不起作用。
我的 POM 文件中有以下内容:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<!-- GA Tracking code -->
<header>
<![CDATA[
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-1', 'auto');
ga('send', 'pageview');
</script>
]]>
</header>
</configuration>
</plugin>
</plugins>
</reporting>
运行 mvn javadoc:aggregate
会构建我的 Javadoc,而不会引发错误,但我的 header 却找不到。
我在这里缺少什么?
最佳答案
好的 - 我明白你在做什么不同的事情。
虽然我的其他答案提供了解决方法,但它没有正确解释问题的真正含义。但这个答案引导我找到了正确的答案,所以我想我不会删除它。
而你的POM
配置看起来正确,您真正应该运行的是
mvn site
而不是 <reporting>
中配置的任何特定插件的任何特定目标部分。阅读 vs. section ,我认为它应该是这样工作的,但似乎没有!它看起来像 <configuration>
当运行特定的报告目标时,报告插件的功能将被完全忽略,而此时它确实应该尝试检查一次属性是否存在。
无论如何,这就是 Maven
行为 - 所以这不是任何特定插件的错误。
mvn site
It uses only the parameters defined in the element of each reporting Plugin specified in the
<reporting>
element, i.e. site always ignores the parameters defined in the element of each plugin specified in<build>
.mvn aplugin:areportgoal
It uses firstly the parameters defined in the element of each reporting Plugin specified in the element; if a parameter is not found, it will look up to a parameter defined in the
<configuration>
element of each plugin specified in<build>
.
关于maven - 为什么我的 header 没有被 maven 注入(inject)到我的 javadoc 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27697173/