如何使用maven生成下载站点 [英] how to generate download-site using maven

查看:83
本文介绍了如何使用maven生成下载站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 构建jar包和网站[DONE]

  2. 通过scp将其部署到远程服务器[DONE]

  3. 该站点应包含具有已部署jar文件的链接的下载页面[MISSING]

我不想使用archiva或类似的工具。我只想在网站上有一个(静态的,生成的)页面,其中包含所有已建立的jar的链接(或仅适用于最新的构建)。



我试过:


  1. put < item name =Downloadshref =download.html/> code>到site.xml

  2. mvn commons:download-page

  3. mvn 部署站点:部署

我得到的:
这些命令将jar文件复制到远程服务器:

  {deploy-dir} /com.acme.etc/ArtifactID/0.0。 2-SNAPSHOT / ArtifactID-0.0.2-SNAPSHOT.jar 

生成的下载页面指向



  {deploy-dir} / target / site / [preferred] /commons/ArtifactID/binaries/ArtifactID-bin.tar.gz 

生成的下载页面中还有一些标签,如 [if-any标志] [end]的。我想服务器应该执行脚本而不是显示html。但是,我不能这样做,因为服务器不属于我。



我想有一个简单的方法(可能完全不同)来完成这个任务,可以吗请指出如何以最简单但自动化的方式。



谢谢。

解决方案


(...)该网站应包含下载页面,其中包含部署的jar文件的链接[MISSING]


据我所知,这并不支持开箱即用,我不知道任何插件这样做( commons-build-plugin Apache Commons builds)。



你最好是添加一个自定义页面,包括Maven表达式到Maven站点,并对其进行过滤,以生成到产品版本的工件的链接。这实际上是Maven网站本身正在做的。从创建内容文档:


过滤



注意
网站插件版本2.0-beta-6或更高版本。



要将属性过滤到任何
支持的文档格式,请添加
.vm 扩展名到文件名。



例如,Maven
网站的模块包含a
src / site / apt / download.apt.vm
文件,它使用表达式
$ {currentVersion } 在POM中设置的
属性中过滤



注意: Velocity用于应用过滤。因为Velocity在内部使用
点符号,您不能
在属性中使用点。



如果您在
中声明这些属性您的POM

 < properties> 
<! - 这将无法正常工作,因为该属性的名称中有一个点 - >
< my.property>我的值< /my.property>
<! - 这将工作,因为属性的名称没有点 - >
< myProperty>我的其他值< / myProperty>
< / properties>

然后使用表达式
$ {my.property} 在您的文档中,
将无法正常工作。如果您使用
表达式 $ {myProperty} ,则
工作正常。



I am new to Maven and trying to accomplish a simple task:

  1. build jar package and web site [DONE]
  2. deploy them to remote server via scp [DONE]
  3. the site should contain download page with links to the deployed jar files [MISSING]

I do not want to use archiva or similar tools. I just want to have a (static, generated) page on the web site with the links to all the built jars (or only to the latest build).

I tried:

  1. put <item name="Downloads" href="download.html"/> into the site.xml
  2. mvn commons:download-page
  3. mvn deploy site:deploy

What I get: these commands copies the jar file to remote server:

{deploy-dir}/com.acme.etc/ArtifactID/0.0.2-SNAPSHOT/ArtifactID-0.0.2-SNAPSHOT.jar

the generated download page points to

{deploy-dir}/target/site/[preferred]/commons/ArtifactID/binaries/ArtifactID-bin.tar.gz

Also there are some labels in the generated download page, like [if-any logo][end]. I suppose server should execute the script instead of displaying html. However, I can not do this as the server does not belong to me.

I guess there is a simple way (maybe totally different) to accomplish this task, could you please point out how to do it in the most simple, but automated way.

Thank you.

解决方案

(...) the site should contain download page with links to the deployed jar files [MISSING]

To my knowledge, this is not supported out of the box and I'm not aware of any plugin doing this (the commons-build-plugin is a specific plugin for Apache Commons builds).

You're best best is to add a custom page including Maven expression to the Maven site and to filter it to generate links to the latests version of artifacts. This is actually what the Maven site itself is doing. From the Creating Content documentation:

Filtering

Note: This feature is available in version 2.0-beta-6 or later of the Site Plugin.

To filter properties into any supported documentation format, add a .vm extension to the filename.

For example, the module for the Maven website contains a src/site/apt/download.apt.vm file, which uses the expression ${currentVersion} to filter in a property set in the POM

Note: Velocity is used to apply the filtering. Because Velocity uses a dot-notation internally you can not use dots in your properties.

If you declare these properties in your POM

<properties>
  <!-- This will not work because the name of the property has a dot in it -->
  <my.property>My value</my.property>
  <!-- This will work because the name of the property has no dot in it -->
  <myProperty>My other value</myProperty>
</properties>

and then use the expression ${my.property} in your document, it will not work. If you instead use the expression ${myProperty} it will work just fine.

这篇关于如何使用maven生成下载站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆