站点发布

 

1. Enabled WebDAV
See this guide to learn how to enable WebDAV access on Apache server 2.x .
2. Configure Where to Deploy

In pom.xml , configure where to deploy your site within “distributionManagement ” tag.

<distributionManagement>
    <site>
      <id>mkyongserver</id>
      <url>dav:http://127.0.0.1/sites/</url>
    </site>
</distributionManagement>

Note 
The “ dav ” prefix is added before the HTTP protocol, it means deploy your site via  WebDAV mechanism. Alternately, you can replace it with “ scp ” if your server is supported “scp” access.

Tell Maven to use “wagon-webdav-jackrabbit ” extension for deployment.

<build>



	<extensions>



		<extension>



			<groupId>


org.apache.maven.wagon</groupId>



			<artifactId>


wagon-webdav-jackrabbit</artifactId>



			<version>


1.0-beta-7</version>



		</extension>



	</extensions>



</build>


wagon-webdav 
Some claimed to use “ wagon-webdav “, but this is not working for me, so, use “ wagon-webdav-jackrabbit ” instead.
<extension>



            <groupId>


org.apache.maven.wagon</groupId>



            <artifactId>


wagon-webdav</artifactId>



            <version>


1.0-beta-2</version>



</extension>


See a full pom.xml file.

<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.mkyong.core</groupId>



  <artifactId>


mkyong-core</artifactId>



  <packaging>


jar</packaging>



  <version>


1</version>



  <name>


mkyong-core</name>



  <url>


http://maven.apache.org</url>



  <build>



	<extensions>



		<extension>



			<groupId>


org.apache.maven.wagon</groupId>



			<artifactId>


wagon-webdav-jackrabbit</artifactId>



			<version>


1.0-beta-7</version>



		</extension>



	</extensions>



  </build>



  <distributionManagement>



    <site>



      <id>


mkyongserver</id>



      <url>


dav:http://127.0.0.1/sites/</url>



    </site>



  </distributionManagement>



</project>


3. Configure WebDAV Authentication

Normally, WebDAV is required authentication access. So, you need to put the related authentication detail (username and password) in %MAVEN_PATH%/conf/settings.xml .

File : settings.xml

<servers>



	<server>



		<id>


mkyongserver</id>



		<username>


USERNAME</username>



		<password>


PASSWORD</password>



	</server>



</servers>


What is “mkyongserver” id ? 
The server id in Maven’s “ settings.xml ” file will be referenced by the site id in “ pom.xml ” file.
4. mvn site:deploy

Issue “mvn site:deploy ” :

D:\workspace-new\mkyong-core>
mvn site:deploy
[
INFO]
 Scanning for
 projects...
[
INFO]
 Searching repository for
 plugin with prefix: 'site'
.
[
INFO]
 ------------------------------------------------------------------------

[
INFO]
 Building mkyong-core
[
INFO]
    task-segment: [
site:deploy]

[
INFO]
 ------------------------------------------------------------------------

[
INFO]
 [
site:deploy {
execution: default-cli}
]

http://
127.0.0.1/
sites/
 - Session: Opened
//
......
#http://127.0.0.1/sites//./css/maven-base.css - Status code: 201

Transfer finished. 4594
 bytes copied in
 0.044
 seconds
18
 April 2011
 4
:23
:40
 PM org.apache.commons.httpclient.auth.AuthChallengeProcessor 
selectAuthScheme
INFO: digest authentication scheme selected
Uploading: ./
css/
maven-theme.css to http://
127.0.0.1/
sites/

//
......
Transfer finished. 10120
 bytes copied in
 0.142
 seconds
http://
127.0.0.1/
sites/
 - Session: Disconnecting
http://
127.0.0.1/
sites/
 - Session: Disconnected
[
INFO]
 ------------------------------------------------------------------------

[
INFO]
 BUILD SUCCESSFUL
[
INFO]
 ------------------------------------------------------------------------

[
INFO]
 Total time
: 5
 seconds
[
INFO]
 Finished at: Mon Apr 18
 16
:23
:43
 SGT 2011

[
INFO]
 Final Memory: 9M/
16M
[
INFO]
 ------------------------------------------------------------------------

D:\workspace-new\mkyong-core>

All your sites folders and files, under project folder – “target/site ” will be deployed to server automatically.

5. Output

In this case, you can access the deployed site via this URL : http://127.0.0.1/sites/ , see following figure :

auto deploy site with Maven
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值