<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed 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. See accompanying LICENSE file.
-->
<project>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-project-dist</artifactId>
    <version>2.0.0-alpha</version>
    <relativePath>../../hadoop-project-dist</relativePath>
  </parent>
  <groupId>org.apache.hadoop</groupId>
  <artifactId>hadoop-hdfs</artifactId>
  <version>2.0.0-alpha</version>
  <description>Apache Hadoop HDFS</description>
  <name>Apache Hadoop HDFS</name>
  <packaging>jar</packaging>

  <properties>
    <hadoop.component>hdfs</hadoop.component>
    <is.hadoop.component>true</is.hadoop.component>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjtools</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-annotations</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-common</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-common</artifactId>
      <scope>test</scope>
      <type>test-jar</type>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>commons-daemon</groupId>
      <artifactId>commons-daemon</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.avro</groupId>
      <artifactId>avro</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo.jspc</groupId>
        <artifactId>jspc-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>hdfs</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <compile>false</compile>
              <workingDirectory>${project.build.directory}/generated-src/main/jsp</workingDirectory>
              <webFragmentFile>${project.build.directory}/hdfs-jsp-servlet-definitions.xml</webFragmentFile>
              <packageName>org.apache.hadoop.hdfs.server.namenode</packageName>
              <sources>
                <directory>${basedir}/src/main/webapps/hdfs</directory>
                <includes>
                  <include>*.jsp</include>
                </includes>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>secondary</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <compile>false</compile>
              <workingDirectory>${project.build.directory}/generated-src/main/jsp</workingDirectory>
              <webFragmentFile>${project.build.directory}/secondary-jsp-servlet-definitions.xml</webFragmentFile>
              <packageName>org.apache.hadoop.hdfs.server.namenode</packageName>
              <sources>
                <directory>${basedir}/src/main/webapps/secondary</directory>
                <includes>
                  <include>*.jsp</include>
                </includes>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>datanode</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <compile>false</compile>
              <workingDirectory>${project.build.directory}/generated-src/main/jsp</workingDirectory>
              <webFragmentFile>${project.build.directory}/datanode-jsp-servlet-definitions.xml</webFragmentFile>
              <packageName>org.apache.hadoop.hdfs.server.datanode</packageName>
              <sources>
                <directory>${basedir}/src/main/webapps/datanode</directory>
                <includes>
                  <include>*.jsp</include>
                </includes>
              </sources>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo.jspc</groupId>
            <artifactId>jspc-compiler-tomcat5</artifactId>
            <version>2.0-alpha-3</version>
          </dependency>
          <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.4.1</version>
          </dependency>
          <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl104-over-slf4j</artifactId>
            <version>1.4.1</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/java</source>
                <source>${project.build.directory}/generated-src/main/jsp</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>compile-proto</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo file="target/compile-proto.sh">
                    PROTO_DIR=src/main/proto
                    JAVA_DIR=target/generated-sources/java
                    which cygpath 2> /dev/null
                    if [ $? = 1 ]; then
                      IS_WIN=false
                    else
                      IS_WIN=true
                      WIN_PROTO_DIR=`cygpath --windows $PROTO_DIR`
                      WIN_JAVA_DIR=`cygpath --windows $JAVA_DIR`
                    fi
                    mkdir -p $JAVA_DIR 2> /dev/null
                    for PROTO_FILE in `ls $PROTO_DIR/*.proto 2> /dev/null`
                    do
                        if [ "$IS_WIN" = "true" ]; then
                          protoc -I$WIN_PROTO_DIR --java_out=$WIN_JAVA_DIR $PROTO_FILE
                        else
                          protoc -I$PROTO_DIR --java_out=$JAVA_DIR $PROTO_FILE
                        fi
                    done
                </echo>
                <exec executable="sh" dir="${basedir}" failonerror="true">
                  <arg line="target/compile-proto.sh"/>
                </exec>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>create-web-xmls</id>
            <phase>compile</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <loadfile property="hdfs.servlet.definitions" srcFile="${project.build.directory}/hdfs-jsp-servlet-definitions.xml"/>
                <loadfile property="secondary.servlet.definitions" srcFile="${project.build.directory}/secondary-jsp-servlet-definitions.xml"/>
                <loadfile property="datanode.servlet.definitions" srcFile="${project.build.directory}/datanode-jsp-servlet-definitions.xml"/>
                <echoproperties destfile="${project.build.directory}/webxml.properties">
                  <propertyset>
                    <propertyref regex=".*.servlet.definitions"/>
                  </propertyset>
                </echoproperties>
                <filter filtersfile="${project.build.directory}/webxml.properties"/>
                <copy file="${basedir}/src/main/webapps/proto-hdfs-web.xml"
                      tofile="${project.build.directory}/webapps/hdfs/WEB-INF/web.xml"
                      filtering="true"/>
                <copy file="${basedir}/src/main/webapps/proto-secondary-web.xml"
                      tofile="${project.build.directory}/webapps/secondary/WEB-INF/web.xml"
                      filtering="true"/>
                <copy file="${basedir}/src/main/webapps/proto-datanode-web.xml"
                      tofile="${project.build.directory}/webapps/datanode/WEB-INF/web.xml"
                      filtering="true"/>
                <copy toDir="${project.build.directory}/webapps">
                  <fileset dir="${basedir}/src/main/webapps">
                    <exclude name="**/*.jsp"/>
                    <exclude name="**/proto-*-web.xml"/>
                  </fileset>
                </copy>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>create-log-dir</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <delete dir="${test.build.data}"/>
                <mkdir dir="${test.build.data}"/>
                <mkdir dir="${hadoop.log.dir}"/>

                <copy todir="${project.build.directory}/test-classes/webapps">
                  <fileset dir="${project.build.directory}/webapps">
                    <exclude name="proto-*-web.xml"/>
                  </fileset>
                </copy>
              </target>
            </configuration>
          </execution>
          <execution>
            <phase>pre-site</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <copy file="src/main/resources/hdfs-default.xml" todir="src/site/resources"/>
                <copy file="src/main/xsl/configuration.xsl" todir="src/site/resources"/>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <excludePackageNames>org.apache.hadoop.hdfs.protocol.proto</excludePackageNames>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>CHANGES.txt</exclude>
            <exclude>CHANGES.HDFS-1623.txt</exclude>
            <exclude>.idea/**</exclude>
            <exclude>src/main/conf/*</exclude>
            <exclude>src/main/docs/**</exclude>
            <exclude>dev-support/findbugsExcludeFile.xml</exclude>
            <exclude>dev-support/checkstyle*</exclude>
            <exclude>dev-support/jdiff/**</exclude>
            <exclude>dev-support/*tests</exclude>
            <exclude>src/main/native/*</exclude>
            <exclude>src/main/native/config/*</exclude>
            <exclude>src/main/native/m4/*</exclude>
            <exclude>src/test/empty-file</exclude>
            <exclude>src/test/all-tests</exclude>
            <exclude>src/test/resources/*.tgz</exclude>
            <exclude>src/test/resources/data*</exclude>
            <exclude>src/test/resources/editsStored*</exclude>
            <exclude>src/test/resources/empty-file</exclude>
            <exclude>src/main/webapps/datanode/robots.txt</exclude>
            <exclude>src/main/docs/releasenotes.html</exclude>
            <exclude>src/contrib/**</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>windows</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <os>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <windows.build>true</windows.build>
      </properties>
    </profile>
    <profile>
      <id>native</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>compile</id>
                <phase>compile</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <target>
                    <copy toDir="${project.build.directory}/native">
                      <fileset dir="${basedir}/src/main/native"/>
                    </copy>
                    <mkdir dir="${project.build.directory}/native/m4"/>
                  </target>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>make-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>compile</id>
                <phase>compile</phase>
                <goals>
                  <goal>autoreconf</goal>
                  <goal>configure</goal>
                  <goal>make-install</goal>
                </goals>
                <configuration>
                  <!-- autoreconf settings -->
                  <workDir>${project.build.directory}/native</workDir>
                  <arguments>
                    <argument>-i</argument>
                    <argument>-f</argument>
                  </arguments>

                  <!-- configure settings -->
                  <configureEnvironment>
                    <property>
                      <name>ac_cv_func_malloc_0_nonnull</name>
                      <value>yes</value>
                    </property>
                    <property>
                      <name>JVM_ARCH</name>
                      <value>${sun.arch.data.model}</value>
                    </property>
                  </configureEnvironment>
                  <configureOptions>
                  </configureOptions>
                  <configureWorkDir>${project.build.directory}/native</configureWorkDir>
                  <prefix>/usr/local</prefix>

                  <!-- make settings -->
                  <installEnvironment>
                    <property>
                      <name>ac_cv_func_malloc_0_nonnull</name>
                      <value>yes</value>
                    </property>
                    <property>
                      <name>JVM_ARCH</name>
                      <value>${sun.arch.data.model}</value>
                    </property>
                  </installEnvironment>

                  <!-- configure & make settings -->
                  <destDir>${project.build.directory}/native/target</destDir>

                </configuration>
              </execution>
              
              <!-- TODO wire here native testcases
              <execution>
                <id>test</id>
                <phase>test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <destDir>${project.build.directory}/native/target</destDir>
                </configuration>
              </execution>
              -->
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
