<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
<document>
  <header>
    <title>How to build Apache Droids?</title>
  </header>
  <body>
    <section id="Download">
      <title>Download</title>
      <p>Download the Droids code base (we refer to the resulting directory as
        $DROIDS_HOME):</p>
      <source>svn co https://svn.apache.org/repos/asf/incubator/droids/trunk droids</source>
    </section>
    <section id="env">
        <title>Setting up the Environment</title>
        <p>
          After downloading and extracting Droids, you need to add environment
          variables. The reason for this is so that the 'droids' command is
          available everywhere and it can locate its home directory and
          resources. It is beyond the scope of Droids to explain how to manage
          your operating system. 
        </p>
        <section>
          <title>In Unix/Linux:</title>
          <p class="instruction">
            change directory to the top-level of the droids distribution and do
            ...
          </p>
          <p class="instruction">
            ~/apache-droids$ export DROIDS_HOME=`pwd`
          </p>
          <p class="instruction">
            ~/apache-droids$ export PATH=$PATH:$DROIDS_HOME/bin
          </p>
          <section>
            <title>Permanently Setting The Environment Variables for Linux/Unix</title>
            <p>
              Export only changes the variables during that terminal session for
              that user, this is useful for testing. To permanently add the
              variable edit either <code>/etc/bash.bashrc</code> (for all users)
              or <code>~/.bash_profile</code> or <code>~/.bashrc</code> (for individual users). Add these
              lines to the end of the file you edit:
            </p>
            <source>
      DROIDS_HOME=/full/path/to/droids
      export DROIDS_HOME
      
      PATH=$PATH:$DROIDS_HOME/bin
      export PATH
          </source>
  </section>
        </section>
        <section>
          <title>Windows 2000</title>
          <p class="instruction">
            Go to "My Computer", "Properties", "Advanced", "Environment
            Variables"
          </p>
          <p class="instruction">
            add a new variable <code>DROIDS_HOME</code> as
            <code>C:\full\path\to\apache-droids</code>
          </p>
          <p class="instruction">
            edit <code>PATH</code> as <code>%PATH%;%DROIDS_HOME%\bin</code>
          </p>
        </section>
        <section>
          <title>In Windows XP:</title>
          <p class="instruction">
            Go to "My Computer", "Properties", "Advanced", "Environment
            Variables"
          </p>
          <p class="instruction">
            Create a New variable with name: DROIDS_HOME value:
            C:\full\path\to\apache-droids
          </p>
          <p class="instruction">
            Edit PATH by adding ;%DROIDS_HOME%\bin to the end of the current
            value.
          </p>
        </section>
      </section>
    <section id="Build">
      <title>Build</title>
      <p>Before building droids, create a file called build.properties to customize your Droid. 
      All properties that you can override can be found in the file default.properties.</p>
      <p>The normal case is to implement the following properties with your custom values:</p>
      <source><![CDATA[# The initial url to crawl (is likely the only property you do not want from default)
droids.initial.url=http://target-x.de/about.html
        
# The droid you want to use
droids.name=hello
        
# the regular expression file we want to use
droids.filter.regex=${droids.home}/regex-urlfilter.txt
        
# the root output dir for saving a crawl
droids.handler.save.dir=${droids.home}/export/]]></source>
      <p>
        <strong>After</strong> you create the above file you can go ahead and build droids
        like follows. The command will first download all libaries that we need with the help
        of Apache Ivy and then generate a jar.</p>
      <source><![CDATA[ant ivy.resolve droids.jar
...
[jar] Building jar: /home/thorsten/src/testing/droids/build/droids-initial.jar
BUILD SUCCESSFUL
Total time: 22 seconds]]></source>
    </section>
    <section id="BuildClean">
      <title>Build afer an update</title>
      <p>If you are doing an update of the svn repository you need to build droids again. You
        normally can drop the resolving of the dependencies but if you want to make sure that
        everything is up to date do the following:</p>
      <source>cd $DROIDS_HOME; svn up; ant ivy.resolve droids.clean droids.jar</source>
      <p>First we make an update of the code (cd $DROIDS_HOME; svn up;). Then we resolve all
        dependencies (ant ivy.resolve). We clean then our old build (ant droids.clean) and
        create a new version of the droids.jar (ant droids.jar).</p>
    </section>
  </body>
</document>
