mirror of
https://github.com/apache/sqoop.git
synced 2025-05-03 18:00:26 +08:00
Add "version" tool.
From: Aaron Kimball <aaron@cloudera.com> git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1149901 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
20cd34e90c
commit
15f5375d76
25
build.xml
25
build.xml
@ -46,6 +46,7 @@
|
||||
|
||||
<property name="build.dir" location="${basedir}/build" />
|
||||
<property name="build.bin.dir" location="${build.dir}/bin" />
|
||||
<property name="build.src.dir" location="${build.dir}/src" />
|
||||
<property name="build.classes" location="${build.dir}/classes"/>
|
||||
<property name="build.shim.dir" location="${build.dir}/shims"/>
|
||||
<property name="build.shim.classes" location="${build.shim.dir}/classes"/>
|
||||
@ -183,15 +184,37 @@
|
||||
<param name="hadoop.dist" value="cloudera" />
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<!-- generate the version information class. -->
|
||||
<target name="gen-version" depends="init">
|
||||
<exec executable="${script.src.dir}/write-version-info.sh"
|
||||
dir="${basedir}" failonerror="true">
|
||||
<arg value="${build.dir}" />
|
||||
<arg value="${version}" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- Compile core classes for the project -->
|
||||
<target name="compile"
|
||||
depends="init, ivy-retrieve-hadoop"
|
||||
depends="init, gen-version, ivy-retrieve-hadoop"
|
||||
description="Compile core classes for the project">
|
||||
<!-- don't use an out-of-date instrumented build. -->
|
||||
<delete dir="${cobertura.class.dir}" />
|
||||
<!-- ensure normal build target dir exists -->
|
||||
<mkdir dir="${build.classes}" />
|
||||
|
||||
<!-- Compile generated code first. -->
|
||||
<javac
|
||||
encoding="${build.encoding}"
|
||||
srcdir="${build.src.dir}"
|
||||
includes="**/*.java"
|
||||
destdir="${build.classes}"
|
||||
debug="${javac.debug}"
|
||||
deprecation="${javac.deprecation}">
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javac>
|
||||
|
||||
<!-- Compile the main code. -->
|
||||
<javac
|
||||
encoding="${build.encoding}"
|
||||
srcdir="${src.dir}"
|
||||
|
@ -73,6 +73,8 @@ public abstract class SqoopTool {
|
||||
"List available databases on a server");
|
||||
registerTool("list-tables", ListTablesTool.class,
|
||||
"List available tables in a database");
|
||||
registerTool("version", VersionTool.class,
|
||||
"Display version information");
|
||||
}
|
||||
|
||||
/**
|
||||
|
46
src/java/org/apache/hadoop/sqoop/tool/VersionTool.java
Normal file
46
src/java/org/apache/hadoop/sqoop/tool/VersionTool.java
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Licensed to Cloudera, Inc. under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Cloudera, Inc. 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.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.sqoop.tool;
|
||||
|
||||
import org.apache.hadoop.sqoop.SqoopOptions;
|
||||
import org.apache.hadoop.sqoop.SqoopVersion;
|
||||
import org.apache.hadoop.sqoop.cli.ToolOptions;
|
||||
|
||||
/**
|
||||
* Tool that prints Sqoop's version.
|
||||
*/
|
||||
public class VersionTool extends BaseSqoopTool {
|
||||
|
||||
public VersionTool() {
|
||||
super("version");
|
||||
}
|
||||
|
||||
@Override
|
||||
/** {@inheritDoc} */
|
||||
public int run(SqoopOptions options) {
|
||||
System.out.print(new SqoopVersion().toString());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHelp(ToolOptions opts) {
|
||||
System.out.println("usage: sqoop " + getToolName());
|
||||
}
|
||||
}
|
||||
|
57
src/scripts/write-version-info.sh
Executable file
57
src/scripts/write-version-info.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Licensed to Cloudera, Inc. under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# Cloudera, Inc. 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.
|
||||
|
||||
# This script writes the current version information to a generated source
|
||||
# file. It is intended to be run from the base directory of the project.
|
||||
#
|
||||
# Arguments are:
|
||||
# path to the root of the build directory
|
||||
# the version number
|
||||
#
|
||||
# e.g., $ write-version-info.sh ./build/ 1.0.0
|
||||
|
||||
buildroot=$1
|
||||
version=$2
|
||||
|
||||
outputdir=${buildroot}/src/org/apache/hadoop/sqoop
|
||||
outputfile=${outputdir}/SqoopVersion.java
|
||||
|
||||
signature=`git log -1 --pretty=format:%H`
|
||||
host=`hostname`
|
||||
compiledate=`date`
|
||||
|
||||
mkdir -p ${outputdir}
|
||||
cat > ${outputfile} <<EOF
|
||||
// generated by src/scripts/write-version-info.sh
|
||||
package org.apache.hadoop.sqoop;
|
||||
public final class SqoopVersion {
|
||||
public SqoopVersion() {
|
||||
}
|
||||
public static final String VERSION="${version}";
|
||||
public static final String GIT_HASH="${signature}";
|
||||
public static final String COMPILE_USER="${USER}";
|
||||
public static final String COMPILE_HOST="${host}";
|
||||
public static final String COMPILE_DATE="${compiledate}";
|
||||
public String toString() {
|
||||
return "Sqoop " + VERSION + "\n"
|
||||
+ "git commit id " + GIT_HASH + "\n"
|
||||
+ "Compiled by " + COMPILE_USER + "@" + COMPILE_HOST
|
||||
+ " on " + COMPILE_DATE + "\n";
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
Loading…
Reference in New Issue
Block a user