代码之家  ›  专栏  ›  技术社区  ›  Adam Gent

Maven+Mercurial+站点部署问题

  •  4
  • Adam Gent  · 技术社区  · 14 年前

    当我做一个

    mvn site:deploy
    

    我得到传输错误:org.apache.maven网站.scm.NoSuchCommandScmException异常:没有这样的命令'list'。

    它就像它试图做一个“svn列表”,即使我使用mercurial。

    org.apache.maven网站四轮马车 货车scm org.apache.maven网站。scm maven scm提供程序 1.4

    对于我的站点部署,我有一个单独的mercurial存储库:

       <distributionManagement>
      <site>
       <id>googlecode</id>
       <name>googlecode site</name>
       <url>scm:hg:${project.site.scm}/</url>
      </site>
       </distributionManagement>
    

      <servers>
      <server>
        <id>googlecode</id>
        <username>...</username>
        <password>...</password>
      </server>
      </servers>
    
    3 回复  |  直到 14 年前
        1
  •  5
  •   hatboyzero    13 年前

    偶然发现这个问题,我想我可以为其他人提供一个答案,因为关于如何做到这一点的文档很少:

    很长一段时间以来,我一直在使用Mercurial的Google代码库中成功地托管我的网站。它工作得很好,我也有一些小问题

    我的POM里有这个 http://site.MYREPO.googlecode.com/hg

    <build>
        <plugins>
            ...
            <!--Deploy site with Mercurial (Hg)-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.0-beta-3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-api</artifactId>
                        <version>1.5</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.maven.scm</groupId>
                        <artifactId>maven-scm-provider-hg</artifactId>
                        <version>1.5</version>
                    </dependency>
                </dependencies>
            </plugin>
            ...
        </plugins>
    </build>
    
    <!--
        Distribution
    -->
    <distributionManagement>
        <!--Site deploy repository-->
        <site>
            <id>MYREPO.googlecode.com</id>
            <url>scm:hg:https://site.MYREPO.googlecode.com/hg</url>
        </site>
    </distributionManagement>
    

    然后你必须告诉Maven你的用户名和密码,所以把这个添加到你的Maven中 settings.xml 文件(注意@character是HTML编码的,因为Mercurial通常会阻塞它)

    <settings>
        <servers>
            <server>
                <id>MYREPO.googlecode.com</id>
                <username>MYEMAIL%40gmail.com</username>
                <password>MYPASSWORD</password>
            </server>
        </servers>
    </settings>
    

    mvn clean site site:deploy 参观 http://site.MYREPO.googlecode.com/hg/index.html

        2
  •  0
  •   Clinton    14 年前

    see here ). 我按照正常的ssh线路(授权的\u密钥等)配置它。在pom中有一些类似的东西:

      <!-- The location for generating the website. -->
      <distributionManagement>
        <site>
          <id>website</id>
          <url>scp://username@server.com/path/to/deploy/directory/</url>
        </site>
      </distributionManagement>
    

    hg push (use mercurial directly to push my changes to other developers).
    mvn site:deploy (deploys from my local machine using scp).
    
        3
  •  0
  •   rodche    11 年前

    因此,这里有一个替代解决方案,它也减少了对远程存储库的提交(不过,它需要一些手动工作)。

    首先,去你的谷歌代码项目, https://code.google.com/p/MYPROJECT ,选项卡“管理”、“源”并创建一个名为“站点”的新存储库(或您希望如何调用它)。然后,您必须提交并推送至少一个文件,方便地称为“索引.html“到那个存储库。

    第二,在父项目的pom.xml文件(仅限):

    <distributionManagement>
    <!-- ... other content ...-->
        <site>
            <id>MYPROJECT.googlecode.com</id>
            <name>MYPROJECT auto-generated site</name>
            <url>http://site.MYPROJECT.googlecode.com/hg</url>
        </site>
    </distributionManagement>
    

    还有-

    <url>http://site.MYPROJECT.googlecode.com/hg</url>
    

    注意:是的,它是“http:”而不是“https:”;在我的示例中,Maven不会使用URL来实际部署那里的站点内容(我不会执行site deploy);而是使用mvn site地点:舞台(见下文)。而且,你不必触摸设置.xml(在~/.m2/on*nix系统中)。

    cd THAT_DIR
    hg clone https://USERNAME@code.google.com/p/MYPROJECT.site/
    

    注意:如果存在,您不必再次克隆,只需执行hg pull、hg update(可以选择使用hg rm*和commit删除旧内容)。您也可以使用免费的SourceTree软件而不是控制台。

    mvn clean install site site:stage -DstagingDirectory=FullPathTo/MYPROJECT.site
    

    最后,切换到clone/stage目录,即/MYPROJECT.site网站,本地测试网站(打开索引.html在浏览器中),如果高兴的话:

    hg add *
    hg commit -m "re-generated MYPROJECT"
    hg push
    

    去看看吧 http://site.MYREPO.googlecode.com/hg/index.html 以及当时的来源和变化 https://code.google.com/p/MYPROJECT.site/