mvn site命令的疑惑
hyde860401
2010-11-19
小弟初学Maven,使用的是最新的3.0版本,根据官方手册在做一些例子,做到Maven的站点生成功能的时候卡住了,我的操作步骤如下:
1、先用"mvn archetype:generate"命令生成一个标准的site工程,即archetypeId选的是"18: internal -> maven-archetype-site (A more complex site project)",工程生成好后,我把src\site目录整个拷贝到我之前做的quickstart例子中去,修改pom.xml文件,最终结果如下: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>demo</groupId> <artifactId>demo</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>demo</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-project-info-reports-plugin</artifactId> <version>2.0.1</version> <reportSets> <reportSet> <reports> <report>index</report> <report>summary</report> </reports> </reportSet> </reportSets> </plugin> </plugins> </reporting> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>2.1.1</version> <configuration> <locales>en,fr</locales> </configuration> </plugin> </plugins> </build> </project> 2、修改拷贝过来的src\site\site.xml文件,最终结果如下: <?xml version="1.0" encoding="ISO-8859-1"?> <project name="Maven" xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> <bannerLeft> <name>Maven</name> <src>http://maven.apache.org/images/apache-maven-project.png</src> <href>http://maven.apache.org/</href> </bannerLeft> <bannerRight> <src>http://maven.apache.org/images/maven-small.gif</src> </bannerRight> <body> <links> <item name="Apache" href="http://www.apache.org/" /> <item name="Maven 1.0" href="http://maven.apache.org/"/> <item name="Maven 2" href="http://maven.apache.org/maven2/"/> </links> <menu name="Maven 2.0"> <item name="APT Format" href="format.html"/> <item name="FAQ" href="faq.html"/> <item name="Xdoc Example" href="xdoc.html"/> </menu> <menu ref="reports"/> </body> </project> 完成以上步骤后,按照官网描述的应该能够在生成的target\site\index.html页面中找到report目录,但是实际上没有,请问各位,我是不是哪个地方配置错误了?或者是遗漏了什么环节? |
|
hyde860401
2010-11-22
这个问题终于自己解决了,原来maven3已经把site插件的配置方式给改了,帖子里面是maven2的配置方式,已经不使用了,应该把pom.xml改成如下形式:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>demo</groupId> <artifactId>demo</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>demo</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>3.0-beta-2</version> <configuration> <!--<locales>en,fr</locales>--> <reportPlugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.7</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jxr-plugin</artifactId> <version>2.1</version> <configuration> <aggregate>true</aggregate> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-report-plugin</artifactId> <version>2.6</version> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.4</version> <configuration> <formats> <format>xml</format> <format>html</format> </formats> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>2.6</version> </plugin> </reportPlugins> </configuration> </plugin> </plugins> </build> </project> 参考文档:http://www.wakaleo.com/blog/292-site-generation-in-maven-3 感谢各位关注过的同学 ![]() |