Multi module POM - creating a site that works

前端 未结 9 1852
名媛妹妹
名媛妹妹 2020-12-08 22:06

I have a multi module application, and I’m trying to generate a Maven site for this app.

I have an aggregating POM that holds all the child modules, an inheritance PO

9条回答
  •  既然无缘
    2020-12-08 22:26

    It's over a year now since the last solution.

    I did not like this workaround, there has to be another solution "the maven way".

    So here it is:

    In the Maven Site Plugin FAQ: http://maven.apache.org/plugins/maven-site-plugin/faq.html#Use_of_url

    "On the other hand, the is used in a multi-module build to construct relative links [...]. In a multi module build it is important for the parent and child modules to have different URLs."

    You must declare the tag in every pom.xml with different URLs:

    Parent POM:

    
      
        mysite
        My Site
        ftp://server.example.com/htdocs/site/
      
    
    

    Child One POM:

    
      
        mysite
        My Site
        ftp://server.example.com/htdocs/site/one/
      
    
    

    Child Two POM:

    
      
        mysite
        My Site
        ftp://server.example.com/htdocs/site/two/
      
    
    

    Now the generation of the site, and the staging works as requested. The staged site is generated in parent/target/staging

    You can submit another staging directory with -D

    mvn -DstagingDirectory=D:/Temp/Site package site site:stage
    

    Note: goal package is needed, if child two has child one as dependency. With package, the goal site is executed without the error that a dependency is missing in the repository.

    Edit: It is necessary to provide a for each artifact that uses the same pathes as in the . This is, because the index.html generated with the report-info-plugin uses the to calculate relative pathes, but the site:stage uses the .

提交回复
热议问题