Permalink
Browse files

HIVE-990. Incorporate CheckStyle into Hive's build.xml. (Carl Steinba…

…ch via zshao)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hive/trunk@901035 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 7d58e6b commit 84a96667844810e9925598886201de444d9b60d4 @zshao zshao committed Jan 20, 2010
Showing with 686 additions and 41 deletions.
  1. +3 −0 CHANGES.txt
  2. +104 −14 build-common.xml
  3. +7 −0 build.properties
  4. +45 −5 build.xml
  5. +195 −0 checkstyle/checkstyle-noframes-sorted.xsl
  6. +190 −0 checkstyle/checkstyle.xml
  7. +42 −0 ivy.xml
  8. +69 −21 ivy/ivysettings.xml
  9. +29 −0 ivy/libraries.properties
  10. +2 −1 shims/build.xml
View
@@ -14,6 +14,9 @@ Trunk - Unreleased
HIVE-983. Function from_unixtime takes long.
(Ning Zhang via zshao)
+ HIVE-990. Incorporate CheckStyle into Hive's build.xml.
+ (Carl Steinbach via zshao)
+
OPTIMIZATIONS
BUG FIXES
View
@@ -36,13 +36,6 @@
<property name="hadoop.conf.dir" location="${hadoop.root}/conf"/>
- <property name="javac.debug" value="on"/>
- <property name="javac.version" value="1.5"/>
- <property name="javac.optimize" value="on"/>
- <property name="javac.deprecation" value="off"/>
- <property name="javac.args" value=""/>
- <property name="javac.args.warnings" value=""/> <!-- -Xlint:unchecked"/ -->
-
<!-- configuration needed for tests -->
<property name="test.src.dir" value="${basedir}/src/test"/>
<property name="test.src.data.dir" value="${hive.root}/data"/>
@@ -69,19 +62,116 @@
<path refid="classpath"/>
</path>
- <import file="${hive.root}/ivy/get_ivy.xml"/>
+ <!-- IVY properties set here -->
+ <property name="build.ivy.dir" location="${build.dir.hive}/ivy"/>
+ <property name="build.ivy.lib.dir" location="${build.ivy.dir}/lib"/>
+ <property name="build.ivy.report.dir" location="${build.ivy.dir}/report"/>
+ <property name="build.ivy.maven.dir" location="${build.ivy.dir}/maven"/>
+ <condition property="ivy.home" value="${env.IVY_HOME}">
+ <isset property="env.IVY_HOME" />
+ </condition>
+ <property name="ivy.home" value="${user.home}/.ant" />
+ <property name="ivy.conf.dir" location="${hive.root}/ivy"/>
+ <loadproperties srcfile="${ivy.conf.dir}/libraries.properties"/>
+ <property name="ivy.jar" location="${build.ivy.lib.dir}/ivy-${ivy.version}.jar"/>
+ <property name="ivysettings.xml" location="${ivy.conf.dir}/ivysettings.xml" />
+ <property name="ivy.org" value="org.apache.hadoop"/>
+ <property name="mvn.repo" value="http://repo2.maven.org/maven2"/>
+ <property name="repo" value="snapshots"/>
+ <property name="asfrepo" value="https://repository.apache.org/content/repositories/${repo}"/>
+ <property name="ant_task_repo_url" value="${mvn.repo}/org/apache/maven/maven-ant-tasks/${ant-task.version}/maven-ant-tasks-${ant-task.version}.jar"/>
+ <property name="ivy_repo_url" value="${mvn.repo}/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
+
+ <!--this is the naming policy for artifacts we want pulled down-->
+ <property name="ivy.artifact.retrieve.pattern" value="${ant.project.name}/[conf]/[artifact]-[revision].[ext]"/>
+
+ <target name="ivy-init-dirs">
+ <mkdir dir="${build.ivy.dir}" />
+ <mkdir dir="${build.ivy.lib.dir}" />
+ <mkdir dir="${build.ivy.report.dir}" />
+ <mkdir dir="${build.ivy.maven.dir}" />
+ </target>
- <target name="settings-ivy" depends="init-ivy">
- <ivy:settings file="${hive.root}/ivy/ivysettings.xml"/>
+ <target name="ivy-probe-antlib" >
+ <condition property="ivy.found">
+ <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
+ </condition>
</target>
- <target name="resolve" description="--> retrieve dependencies with ivy" depends="settings-ivy">
- <ivy:retrieve pattern="${build.dir.hadoop}/[artifact]-[revision].[ext]"/>
+ <target name="ivy-download" depends="ivy-init-dirs"
+ description="To download ivy" unless="offline">
+ <get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
</target>
- <available property="hadoopcore.${hadoop.version.ant-internal}.install.done" file="${build.dir.hadoop}/hadoop-${hadoop.version.ant-internal}.installed"/>
+ <!--
+ To avoid Ivy leaking things across big projects, always load Ivy in the same classloader.
+ Also note how we skip loading Ivy if it is already there, just to make sure all is well.
+ -->
+ <target name="ivy-init-antlib" depends="ivy-download,ivy-init-dirs,ivy-probe-antlib" unless="ivy.found">
+ <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
+ loaderRef="ivyLoader">
+ <classpath>
+ <pathelement location="${ivy.jar}"/>
+ </classpath>
+ </typedef>
+ <fail >
+ <condition >
+ <not>
+ <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
+ </not>
+ </condition>
+ You need Apache Ivy 2.0 or later from http://ant.apache.org/
+ It could not be loaded from ${ivy_repo_url}
+ </fail>
+ </target>
+
+
+ <property name="ivyresolvelog" value="download-only"/>
+ <property name="ivyretrievelog" value="quite"/>
+
+ <target name="ivy-init" depends="ivy-init-antlib" >
+ <!--Configure Ivy by reading in the settings file
+ If anyone has already read in a settings file into this settings ID, it gets priority
+ -->
+ <ivy:settings id="${ant.project.name}.ivy.settings" file="${ivysettings.xml}"/>
+ </target>
+
+ <target name="ivy-resolve" depends="ivy-init">
+ <ivy:resolve settingsRef="${ant.project.name}.ivy.settings"
+ log="${ivyresolvelog}"/>
+ </target>
+
+ <target name="ivy-resolve-checkstyle" depends="ivy-init">
+ <ivy:resolve settingsRef="${ant.project.name}.ivy.settings" conf="checkstyle"
+ log="${ivyresolvelog}"/>
+ </target>
+
+ <target name="ivy-retrieve" depends="ivy-resolve"
+ description="Retrieve Ivy-managed artifacts">
+ <ivy:retrieve settingsRef="${ant.project.name}.ivy.settings"
+ pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}"
+ log="${ivyresolvelog}"/>
+ </target>
+
+ <target name="ivy-retrieve-checkstyle" depends="ivy-resolve-checkstyle"
+ description="Retrieve Ivy-managed artifacts for the checkstyle configurations">
+ <ivy:retrieve settingsRef="${ant.project.name}.ivy.settings"
+ pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}"
+ log="${ivyresolvelog}"/>
+ <ivy:cachepath pathid="checkstyle-classpath" conf="checkstyle"/>
+ </target>
+
+ <target name="ivy-retrieve-hadoop-source" depends="ivy-init"
+ description="Retrieve Ivy-managed Hadoop source artifacts" >
+ <ivy:retrieve settingsRef="${ant.project.name}.ivy.settings"
+ pattern="${build.dir.hadoop}/[artifact]-[revision].[ext]"/>
+ </target>
+
+ <available property="hadoopcore.${hadoop.version.ant-internal}.install.done"
+ file="${build.dir.hadoop}/hadoop-${hadoop.version.ant-internal}.installed"/>
- <target name="install-hadoopcore-internal" depends="resolve" unless="hadoopcore.${hadoop.version.ant-internal}.install.done">
+ <target name="install-hadoopcore-internal" depends="ivy-retrieve-hadoop-source"
+ unless="hadoopcore.${hadoop.version.ant-internal}.install.done">
<untar src="${build.dir.hadoop}/hadoop-${hadoop.version.ant-internal}.tar.gz" dest="${build.dir.hadoop}" compression="gzip"/>
<chmod file="${hadoop.root}/bin/hadoop" perm="+x"/>
<touch file="${build.dir.hadoop}/hadoop-${hadoop.version.ant-internal}.installed"/>
View
@@ -3,6 +3,13 @@ name=hive
version=0.6.0
year=2009
+javac.debug=on
+javac.version=1.6
+javac.optimize=on
+javac.deprecation=off
+javac.args=
+javac.args.warnings=
+
hadoop.version=0.20.0
hadoop.mirror=http://archive.apache.org/dist
View
@@ -25,11 +25,6 @@
<property file="${user.home}/build.properties" />
<property file="${basedir}/build.properties" />
- <!-- This is the version added to the manifest, which must be manually rev'ed
- whenever a branch version is created. The non-numberic/dot characters are
- silently dropped from the Implementation-Version when added to the manifest. -->
- <property name="version" value="0.6.0-dev"/>
-
<property name="target.dir" location="${build.dir.hive}/dist"/>
<property name="target.lib.dir" location="${target.dir}/lib"/>
<property name="target.conf.dir" location="${target.dir}/conf"/>
@@ -48,6 +43,9 @@
<property name="final.name" value="${name}-${version}"/>
<property name="dev.final.name" value="${final.name}-dev"/>
<property name="bin.final.name" value="${final.name}-bin"/>
+ <property name="checkstyle.conf.dir" location="${hive.root}/checkstyle"/>
+ <property name="checkstyle.build.dir" location="${build.dir.hive}/checkstyle"/>
+
<!-- ====================================================== -->
<!-- Macro definitions -->
@@ -474,4 +472,46 @@
</macro_tar>
</target>
+
+ <!-- ================================================================== -->
+ <!-- Checkstyle -->
+ <!-- ================================================================== -->
+
+ <import file="${hive.root}/build-common.xml"/>
+
+ <target name="checkstyle" depends="ivy-retrieve-checkstyle,check-for-checkstyle"
+ if="checkstyle.present"
+ description="Run Checkstyle on source files">
+ <taskdef resource="checkstyletask.properties">
+ <classpath refid="checkstyle-classpath"/>
+ </taskdef>
+
+ <mkdir dir="${checkstyle.build.dir}"/>
+
+ <checkstyle config="${checkstyle.conf.dir}/checkstyle.xml"
+ failOnViolation="false">
+ <fileset dir="${hive.root}/cli/src" includes="**/*.java"/>
+ <fileset dir="${hive.root}/common/src" includes="**/*.java"/>
+ <fileset dir="${hive.root}/contrib/src/java" includes="**/*.java"/>
+ <fileset dir="${hive.root}/hwi/src/java" includes="**/*.java"/>
+ <fileset dir="${hive.root}/jdbc/src/java" includes="**/*.java"/>
+ <fileset dir="${hive.root}/metastore/src/java" includes="**/*.java"/>
+ <fileset dir="${hive.root}/ql/src/java" includes="**/*.java"/>
+ <fileset dir="${hive.root}/serde/src/java" includes="**/*.java"/>
+ <fileset dir="${hive.root}/service/src/java" includes="**/*.java"/>
+ <fileset dir="${hive.root}/shims/src" includes="**/*.java"/>
+ <formatter type="xml" toFile="${checkstyle.build.dir}/checkstyle-errors.xml"/>
+ </checkstyle>
+
+ <xslt style="${checkstyle.conf.dir}/checkstyle-noframes-sorted.xsl"
+ in="${checkstyle.build.dir}/checkstyle-errors.xml"
+ out="${checkstyle.build.dir}/checkstyle-errors.html"/>
+ </target>
+
+ <target name="check-for-checkstyle">
+ <available property="checkstyle.present" resource="checkstyletask.properties">
+ <classpath refid="checkstyle-classpath"/>
+ </available>
+ </target>
+
</project>
Oops, something went wrong.

0 comments on commit 84a9666

Please sign in to comment.