PayPal - The safer, easier way to pay online!

[ Previous | TOC | Next ]

Deploy your project

Preamble

Within this tutorial we will explain how to deploy your project. There are multiple sections since deploying the project is different from deploying the website/documentation.

Deploy the phar

Deploying the phar means to upload the project package somewhere so that others are able to find and use it. First of all you must tell maven where to upload it. Edit your pom.xml and add the following lines:

<project>
  ...
  <distributionManagement>
    <repository>
      <id>releases.mydomain.org</id>
      <name>My releases</name>
      <url>ftp://ftp.mydomain.org/repository/releases</url>
    </repository>
    <snapshotRepository>
      <id>snapshots.mydomain.org</id>
      <name>My snapshots</name>
      <url>ftp://ftp.mydomain.org/repository/snapshots</url>
    </snapshotRepository>
  </distributionManagement>
  ...
</project>
			

Within this example we use a ftp connection to upload the package. Maven does not need anything else since it assumes a simple file system layout fits your need. So it will create some folders containing your project and the correct versions. Note: It will work if you simply deploy the files via ftp to a folder visible from apache htdocs. The http url may be used to configure your team mates settings.xml (view the prepare php-maven section on an example). But we strongly recommend that you use the official php-maven repository since it is tuned for performance and since it will be available for every team mate automatically as soon as he configures the settings.xml as suggested. We will explain how to use the official repository for sharing your in the next tutorial chapter.

You may wonder where the credentials are stored? Of course it is not good to write them down in your pom.xml. This won't be a good idea to share your private passwords with the rest of the world. There is a small trick. We will put everything into the settings.xml. So here is the snippet for your settings.xml:

<settings>
   ...
   <servers>
     <server>
       <id>releases.mydomain.org</id>
       <username>FTP-USER</username>
       <password>FTP-PASSWORD</password>
       <filePermissions>660</filePermissions>
       <directoryPermissions>770</directoryPermissions>
     </server>
   </servers>
   ...
</settings>
			

Notice that we reuse the ids of the pom.xml. That's the hint for maven which credentials to be used for your ftp upoload. Now that was everything we need for uploading the version. let us give it a try:

mvn deploy

If everything is ok have a look at your web server and see the folders maven created and the files it uploaded. There is nothing to do for know. As soon as someone configures to use your http url (or maybe even an anonymous ftp) as repository maven will automatically find and download the pom and the phar.

Deploy the site

Deploying the site is similar to deploying the package. But it requires additional settings and one additional goal. First of all let us edit the pom.xml and add the following:

<project>
  ...
  <distributionManagement>
    ...
    <site>
      <id>project-site.mydomain.org</id>
      <name>My releases</name>
      <url>ftp://ftp.mydomain.org/documentation</url>
    </site>
    ...
  </distributionManagement>
  ...
</project>
			

As we said before we will add the credentials to the settings.xml. Simply use the correct server-id.

Execute the new goal:

mvn site-deploy

That's it. Simple, isn't it?

[ Previous | TOC | Next ]