`
duyangsss
  • 浏览: 127372 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

站点发布

阅读更多

 

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics