<?xml version="1.0"?>
<!--
  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.
-->
<project default="seed" basedir="." name="Forrest Seed Targets">
<!-- ***************************************************************** -->
<!-- ***************************************************************** -->
<!-- **                                                             ** -->
<!-- **                                                             ** -->
<!-- **          PROJECT-TEMPLATE BUILDING ACTIONS                  ** -->
<!-- **                                                             ** -->
<!-- **                                                             ** -->
<!-- ***************************************************************** -->
<!-- ***************************************************************** -->
<!-- ===============================================================
        Copies a template structure over to your project dir.
       =============================================================== -->
  <target name="seed" depends="ensure-nocontent"
    description="Seeds a directory with a template project doc structure">
    <copy todir="${project.home}" overwrite="false">
      <fileset dir="${forrest.core}/fresh-site"/>
    </copy>
    <loadfile  property="template-project-created-message" srcFile="${forrest.core}/var/template-project-created-message-sample.txt">
      <filterchain>
        <expandproperties/>
      </filterchain>
    </loadfile>
    <echo>${template-project-created-message}</echo>
  </target>
  <target name="seed-sample" description="* Seeds a directory with a template project doc structure">
    <antcall target="seed"/>
  </target>
  <target name="seed-basic" depends="ensure-nocontent"
    description="* Seeds a basic example (1 file) and structure">
    <copy todir="${project.home}" overwrite="false">
      <fileset dir="${forrest.core}/template-sites/basic"/>
    </copy>
    <loadfile  property="template-project-created-message" srcFile="${forrest.core}/var/template-project-created-message-basic.txt">
      <filterchain>
        <expandproperties/>
      </filterchain>
    </loadfile>
    <echo>${template-project-created-message}</echo>
  </target>
  <target name="seed-benchmark" depends="ensure-nocontent"
    description="* Seeds a site to use for benchmarking measurements">
    <copy todir="${project.home}" overwrite="false">
      <fileset dir="${forrest.core}/template-sites/benchmark"/>
    </copy>
    <loadfile property="template-project-created-message" srcFile="${forrest.core}/var/template-project-created-message-basic.txt">
      <filterchain>
        <expandproperties/>
      </filterchain>
    </loadfile>
    <echo>${template-project-created-message}</echo>
  </target>
  <target name="seedTestBusiness"  depends="ensure-nocontent"
    description="A test business site">
    <property name="project.display.name" value="The Forresters"/>
    <property name="project.description" value="The Forresters is a (fictitious) company providing support for the users and developers of the Apache Forrest Project."/>
    <property name="project.domain" value="forrest.apache.org"/>
    <property name="project.url" value="http://forrest.apache.org"/>
    <property name="group.display.name" value="The Apache Software Foundation"/>
    <property name="group.description" value="The Apache Software Foundation provides support for the Apache community of open-source software projects."/>
    <property name="group.domain" value="www.apache.org"/>
    <property name="group.url" value="http://www.apache.org"/>
    <property name="copyright.owner" value="The Apache Software Foundation"/>
    <property name="search.provider" value="google"/>
    <property name="search.box.location" value="default"/>
    <property name="seed-template" value="business"/>
    <antcall target="-copyTemplate"/>
  </target>
  <target name="seed-business"  depends="ensure-nocontent, getProperties"
    description="A typical business site">
    <property name="seed-template" value="business"/>
    <antcall target="-copyTemplate"/>
  </target>
  <target name="getProperties" 
    depends="getProjectProperties, getGroupProperties, getSearchProperties"/>
  <target name="getProjectProperties">
    <input message="What is the name of the project you wish to create a site for?"
           addproperty="project.display.name"/>
    <input message="Provide a brief description of the project."
           addproperty="project.description"/>
    <input message="What is the domain for this project (not including protocol)?"
           addproperty="project.domain"/>
    <input message="What is the URL for this project?"
           addproperty="project.url"/>
  </target>
  <target name="getGroupProperties">
    <input message="What name of the group you wish to create a site for?"
           addproperty="group.display.name"/>
    <input message="Provide a brief description of the group."
           addproperty="group.description"/>
    <input message="What is the domain for this group (not including protocol)?"
           addproperty="group.domain"/>
    <input message="What is the URL for this group?"
           addproperty="group.url"/>
    <input message="Who is the copyright owner of the site?"
           addproperty="copyright.owner"/>
  </target>
  <target name="getSearchProperties">
    <input message="Which search provider would you like to use?"
           validargs="google,lucene"
           defaultvalue="google"
           addproperty="search.provider"/>
    <input message="Where would you like the search box to be located?"
           validargs="default,all,alt"
           defaultvalue="default"
           addproperty="search.box.location"/>
  </target>
  <target name="-copyTemplate">
    <copy todir="${project.home}" overwrite="false" filtering="true">
      <fileset dir="${forrest.core}/template-sites/${seed-template}"/>
      <filterset>
<!-- Project properties -->
        <filter token="project.display.name" value="${project.display.name}"/>
        <filter token="project.description" value="${project.description}"/>
        <filter token="project.domain" value="${project.domain}"/>
        <filter token="project.url" value="${project.url}"/>
<!-- Group properties -->
        <filter token="group.display.name" value="${group.display.name}"/>
        <filter token="group.description" value="${group.description}"/>
        <filter token="group.domain" value="${group.domain}"/>
        <filter token="group.url" value="${group.url}"/>
        <filter token="copyright.owner" value="${copyright.owner}"/>
<!-- Search properties -->
        <filter token="search.provider" value="${search.provider}"/>
        <filter token="search.box.location" value="${search.box.location}"/>
      </filterset>
    </copy>
  </target>
</project>
