论坛首页 综合技术论坛

Maven 多项目站点生成问题

浏览 6268 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-07-05  
hello every body:

  (I use maven maven-2.0.7)

  I have a problem with Maven web site when referring to directory structures that contain more
then one Maven project.

  I build a project named headache with two modules:
   headache ---   1. NumOps
            |          ^
            |          |
            |---  2. PosImp

   (PosImp module depends on NumOps module)


  and I defined dependencyManagement in the project pom.xml like this
   <dependencyManagement>
      <dependencies>
      <dependency>
         <groupId>com.ibm.devworks</groupId>
          <artifactId>NumOps</artifactId>
         <version>${project.version}</version>
      </dependency>
      <dependency>
         <groupId>com.ibm.devworks</groupId>
          <artifactId>PosImp</artifactId>
         <version>${project.version}</version>
      </dependency>
      </dependencies>
</dependencyManagement>

  When I execute: mvn test , mvn package , everything is ok,

  but When I execute: mvn site  there is an error:
........
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) com.ibm.devworks:NumOps:jar:1.0-SNAPSHOT

  Try downloading the file manually from the project website.

  Then, install it using the command:
      mvn install:install-file -DgroupId=com.ibm.devworks -DartifactId=NumOps \
          -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:       mvn deploy:deploy-file
-DgroupId=com.ibm.devworks -DartifactId=NumOps \
          -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file \
           -Durl=[url] -DrepositoryId=[id]

  Path to dependency:
        1) com.ibm.devworks:PosImp:jar:1.0-SNAPSHOT
        2) com.ibm.devworks:NumOps:jar:1.0-SNAPSHOT

----------
1 required artifact is missing.


It seems the <dependencyManagement> did not work? Is this a bug or I should execute "mvn install"
before "mvn site" ?

----------------------------
The full pom.xml script
----------------------------
(root pom.xml)

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.ibm.devworks</groupId>
  <artifactId>headache</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>war of star</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <modules>
    <module>NumOps</module>
    <module>PosImp</module>
  </modules>
  
  <dependencyManagement>
<dependencies>
      <dependency>
         <groupId>com.ibm.devworks</groupId>
  <artifactId>NumOps</artifactId>
         <version>${project.version}</version>
      </dependency>
      <dependency>
         <groupId>com.ibm.devworks</groupId>
  <artifactId>PosImp</artifactId>
         <version>${project.version}</version>
      </dependency>
      
      </dependencies>
</dependencyManagement>

</project>

(NumOps pom.xml)

<?xml version="1.0"?><project>
  <parent>
    <artifactId>headache</artifactId>
    <groupId>com.ibm.devworks</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.ibm.devworks</groupId>
  <artifactId>NumOps</artifactId>
  <name>NumOps</name>

</project>

(PosImp pom.xml)
<?xml version="1.0"?><project>
  <parent>
    <artifactId>headache</artifactId>
    <groupId>com.ibm.devworks</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.ibm.devworks</groupId>
  <artifactId>PosImp</artifactId>
  <name>PosImp</name>
<dependencies>
    <dependency>
         <groupId>com.ibm.devworks</groupId>
         <artifactId>NumOps</artifactId>
      </dependency>
</dependencies>      
</project>
   发表时间:2007-07-05  
二楼是第二个问题

假如mvn install 项目后 mvn site 生成的site target中不包含子项目的连接。子项目的site分别被放在了子项目的target/site目录中,
感觉这对于整个项目站点的发布造成了一些问题。

希望有使用maven配制多个项目经验的同志一起来讨论这个问题。
0 请登录后投票
   发表时间:2007-07-05  
你的依赖项 库里面没有 而且下不到 所以提示你在本地下下来后自己安装到mvn的本地库里面而已,不是吗?
0 请登录后投票
   发表时间:2007-07-05  
site:site的goal只是用來在local端產生web site,你還需要透過site:deploy後
url跟目錄的layout就會正常了
要執行site:deploy需要在pom.xml做如下設定
<distributionManagement>
		<site>
			<id>website</id>
			<url>file:///opt/sites/my-sites/${project.artifactId}</url>
		</site>
</distributionManagement>

上面的設定是deploy到本機,如果你要deploy到其他服務器
需要透過其他的protocal
如果項目間是parent-children的關係,可以在site.xml的descriptor設定
讓每個應目項共享文項,並在裡面加上
		<menu ref="modules" />

讓子項目可以顯示在功能表區
0 请登录后投票
   发表时间:2007-07-05  
site:site的goal只是用來在local端產生web site,你還需要透過site:deploy後
url跟目錄的layout就會正常了
要執行site:deploy需要在pom.xml做如下設定
<distributionManagement>
		<site>
			<id>website</id>
			<url>file:///opt/sites/my-sites/${project.artifactId}</url>
		</site>
</distributionManagement>

上面的設定是deploy到本機,如果你要deploy到其他服務器
需要透過其他的protocal
如果項目間是parent-children的關係,可以在site.xml的descriptor設定
讓每個應目項共享文項,並在裡面加上
		<menu ref="modules" />

讓子項目可以顯示在功能表區
0 请登录后投票
   发表时间:2007-07-05  
感谢 DraculaCwg 的回复!

使用
	
   <distributionManagement>  
        <site>  
            <id>website</id>  
            <url>file:///tmp/headache/my-site/${project.artifactId}</url> 
        </site>  
  </distributionManagement>

<menu ref="modules"/> 


又碰到个问题
生成的目录 my-site下目录结构为

my-site--headache   主工程
       |-PosImp     子工程
       |-NumOps     子工程


访问/my-site/headache/index.html
可以看到
Modules
 NumOps 
 PosImp 

但是分别指向 /my-site/headache/NumOps/index.html
           /my-site/headache/PosImp/index.html

这样,根据上面的目录无法访问到子项目的index.html页面。 而且,我的工程的src/site/下面也没有为子项目定义index页面。。。我应该为子项目定义index页面么?如何定义?
再有,子项目中生成的页面没有包括对工程整体页面的引用。就是说如果现在导航到子项目中就不可以方便的导航回去了。
0 请登录后投票
   发表时间:2007-07-05  
找到原因了!


不在工程的总体pom.xml 中定义<report> 项目,子项目中就会自动生成index.html文件.

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	   <artifactId>
	     maven-project-info-reports-plugin
	   </artifactId>
		<reportSets>
	          	<reportSet>
				<reports>
				   <report>index</report>
		    		   <report>dependencies</report>
				</reports>
			</reportSet>
		</reportSets>
</plugin>


目前还未发现怎么修改子项目的index.html文件显示的内容。
0 请登录后投票
论坛首页 综合技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics