You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2013/04/13 20:27:21 UTC
git commit: SQOOP-949: Allow Sqoop to build on Windows OS
Updated Branches:
refs/heads/trunk 00d09b7b2 -> c4b0eac2d
SQOOP-949: Allow Sqoop to build on Windows OS
(Ahmed El Baz via Jarek Jarcec Cecho)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/c4b0eac2
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/c4b0eac2
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/c4b0eac2
Branch: refs/heads/trunk
Commit: c4b0eac2d0bd954d1c6cae2db158124908fbf055
Parents: 00d09b7
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Sat Apr 13 11:26:28 2013 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Sat Apr 13 11:26:28 2013 -0700
----------------------------------------------------------------------
build.xml | 90 ++++++++++++++++++++-------
src/scripts/create-tool-scripts.cmd | 57 +++++++++++++++++
src/scripts/tool-script.cmd.template | 26 ++++++++
src/scripts/write-version-info.cmd | 96 +++++++++++++++++++++++++++++
4 files changed, 247 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/c4b0eac2/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 8ac3872..e356ba6 100644
--- a/build.xml
+++ b/build.xml
@@ -258,6 +258,17 @@
<property name="java.security.krb5.kdc"
value="kdc0.ox.ac.uk:kdc1.ox.ac.uk"/>
+ <condition property="windows">
+ <os family="windows" />
+ </condition>
+
+ <condition property="skip-real-docs">
+ <or>
+ <isset property="docs.uptodate" />
+ <os family="windows" />
+ </or>
+ </condition>
+
<if>
<isset property="sqoop.test.msserver.connector.factory"/>
<then>
@@ -326,12 +337,25 @@
<!-- 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}" />
- <arg value="${git.hash}" />
- </exec>
+ <if>
+ <equals arg1="${windows}" arg2="true" />
+ <then>
+ <exec executable="${script.src.dir}/write-version-info.cmd"
+ dir="${basedir}" failonerror="true">
+ <arg value="${build.dir}" />
+ <arg value="${version}" />
+ <arg value="${git.hash}" />
+ </exec>
+ </then>
+ <else>
+ <exec executable="${script.src.dir}/write-version-info.sh"
+ dir="${basedir}" failonerror="true">
+ <arg value="${build.dir}" />
+ <arg value="${version}" />
+ <arg value="${git.hash}" />
+ </exec>
+ </else>
+ </if>
</target>
<!-- Compile core classes for the project -->
@@ -421,21 +445,43 @@
the wrapper scripts to invoke each of these.
-->
<mkdir dir="${build.bin.dir}" />
- <java classname="com.cloudera.sqoop.Sqoop"
- fork="true"
- failonerror="true"
- output="${build.dir}/tools-list"
- error="/dev/null">
- <jvmarg value="-Dhadoop.security.log.file=./build/security-audit.log" />
- <arg value="help" />
- <classpath refid="compile.classpath"/>
- </java>
- <exec executable="${script.src.dir}/create-tool-scripts.sh"
- dir="${basedir}" failonerror="true">
- <arg value="${build.bin.dir}" />
- <arg value="${script.src.dir}/tool-script.sh.template" />
- <arg value="${build.dir}/tools-list" />
- </exec>
+ <if>
+ <equals arg1="${windows}" arg2="true" />
+ <then>
+ <java classname="com.cloudera.sqoop.Sqoop"
+ fork="true"
+ failonerror="true"
+ output="${build.dir}/tools-list"
+ error="NUL">
+ <jvmarg value="-Dhadoop.security.log.file=./build/security-audit.log" />
+ <arg value="help" />
+ <classpath refid="compile.classpath"/>
+ </java>
+ <exec executable="${script.src.dir}/create-tool-scripts.cmd"
+ dir="${basedir}" failonerror="true">
+ <arg value="${build.bin.dir}" />
+ <arg value="${script.src.dir}/tool-script.cmd.template" />
+ <arg value="${build.dir}/tools-list" />
+ </exec>
+ </then>
+ <else>
+ <java classname="com.cloudera.sqoop.Sqoop"
+ fork="true"
+ failonerror="true"
+ output="${build.dir}/tools-list"
+ error="/dev/null">
+ <jvmarg value="-Dhadoop.security.log.file=./build/security-audit.log" />
+ <arg value="help" />
+ <classpath refid="compile.classpath"/>
+ </java>
+ <exec executable="${script.src.dir}/create-tool-scripts.sh"
+ dir="${basedir}" failonerror="true">
+ <arg value="${build.bin.dir}" />
+ <arg value="${script.src.dir}/tool-script.sh.template" />
+ <arg value="${build.dir}/tools-list" />
+ </exec>
+ </else>
+ </if>
</target>
<target name="package"
@@ -935,7 +981,7 @@
<target name="docs" depends="real-docs,relnotes,javadoc"
description="Build documentation"/>
- <target name="real-docs" depends="docs-uptodate,init" unless="docs.uptodate">
+ <target name="real-docs" depends="docs-uptodate,init" unless="skip-real-docs">
<exec executable="make" failonerror="true">
<arg value="-C" />
<arg value="${basedir}/src/docs" />
http://git-wip-us.apache.org/repos/asf/sqoop/blob/c4b0eac2/src/scripts/create-tool-scripts.cmd
----------------------------------------------------------------------
diff --git a/src/scripts/create-tool-scripts.cmd b/src/scripts/create-tool-scripts.cmd
new file mode 100644
index 0000000..0ba79a1
--- /dev/null
+++ b/src/scripts/create-tool-scripts.cmd
@@ -0,0 +1,57 @@
+@echo off
+rem
+rem Copyright 2011 The Apache Software Foundation
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements. See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership. The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+setlocal EnableDelayedExpansion
+
+set outdir=%1
+set template=%2
+set toollistfile=%3
+
+rem Count the number of lines in the toollist file
+set lineCount=0
+FOR /F "tokens=*" %%A in (%toollistfile%) do (
+ set /A lineCount=!lineCount! + 1
+)
+set /A lastCommand=%lineCount% - 1
+
+rem Create a tool-script for each tool
+set currentLine=0
+FOR /F "tokens=*" %%A in (%toollistfile%) do (
+ call :parseCommand SUBCOMMANDMARKER %%A
+)
+
+rem For each line in the template file, replace token [1], with token [2]
+rem and write the updated script as the target tool script
+:parseCommand
+if %currentLine% GTR 1 if %currentLine% LSS %lastCommand% (
+ rem Get the script name for the current tool
+ set toolScriptTarget=%outdir%\sqoop-%2.cmd
+
+ rem Replace the source token with target token, and write the result to
+ rem target script
+ for /f "tokens=*" %%i in (%template%) do (
+ set line=%%i
+ echo !line:%1=%2!>> !toolScriptTarget!
+ )
+)
+set /A currentLine=%currentLine%+1
+goto :eof
+
+endlocal
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/sqoop/blob/c4b0eac2/src/scripts/tool-script.cmd.template
----------------------------------------------------------------------
diff --git a/src/scripts/tool-script.cmd.template b/src/scripts/tool-script.cmd.template
new file mode 100644
index 0000000..16ea73d
--- /dev/null
+++ b/src/scripts/tool-script.cmd.template
@@ -0,0 +1,26 @@
+@echo off
+:: 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.
+
+setlocal
+
+set prgm=%~f0
+set bin=%~dp0
+if "%bin:~-1%" == "\" (
+ set bin=%bin:~0,-1%
+)
+
+call "%bin%\sqoop.cmd" SUBCOMMANDMARKER %*
http://git-wip-us.apache.org/repos/asf/sqoop/blob/c4b0eac2/src/scripts/write-version-info.cmd
----------------------------------------------------------------------
diff --git a/src/scripts/write-version-info.cmd b/src/scripts/write-version-info.cmd
new file mode 100644
index 0000000..247f5f3
--- /dev/null
+++ b/src/scripts/write-version-info.cmd
@@ -0,0 +1,96 @@
+@echo off
+rem
+rem Copyright 2011 The Apache Software Foundation
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements. See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership. The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+rem Arguments are:
+rem path to the root of the build directory
+rem the version number
+rem the git hash of the current checkout. If empty, auto-detect.
+rem
+rem e.g., $ write-version-info.cmd ./build/ 1.0.0
+
+set buildroot=%1
+set version=%2
+set specifiedgithash=%3
+
+set outputdir=%buildroot%\src\com\cloudera\sqoop
+set outputfile=%outputdir%\SqoopVersion.java
+
+set newoutputdir=%buildroot%\src\org\apache\sqoop
+set newoutputfile=%newoutputdir%\SqoopVersion.java
+
+set signature=%specifiedgithash%
+if "%signature%"=="" (
+ FOR /F "tokens=*" %%X IN (
+ '"git log -1 --pretty=format:%%H"'
+ ) DO SET signature=%%X
+)
+
+set host=%COMPUTERNAME%
+set compiledate=%date%-%time%
+
+mkdir %outputdir%
+
+(
+ echo.// generated by src/scripts/write-version-info.cmd
+ echo.package com.cloudera.sqoop;
+ echo.
+ echo./**
+ echo. * @deprecated use org.apache.sqoop.SqoopVersion instead
+ echo. * @see org.apache.sqoop.SqoopVersion
+ echo. */
+ echo.public final class SqoopVersion extends org.apache.sqoop.SqoopVersion {
+ echo. public SqoopVersion^(^) {
+ echo. super^(^);
+ echo. }
+ echo. public static final String VERSION =
+ echo. org.apache.sqoop.SqoopVersion.VERSION;
+ echo. public static final String GIT_HASH =
+ echo. org.apache.sqoop.SqoopVersion.GIT_HASH;
+ echo. public static final String COMPILE_USER =
+ echo. org.apache.sqoop.SqoopVersion.COMPILE_USER;
+ echo. public static final String COMPILE_DATE =
+ echo. org.apache.sqoop.SqoopVersion.COMPILE_DATE;
+ echo.}
+) > %outputfile%
+
+mkdir %newoutputdir%
+
+(
+ echo.// generated by src/scripts/write-version-info.cmd
+ echo.package org.apache.sqoop;
+ echo.
+ echo.public class SqoopVersion {
+ echo. public SqoopVersion^(^) {
+ echo. }
+ echo.
+ echo. public static final String VERSION="%version%";
+ echo. public static final String GIT_HASH="%signature%";
+ echo. public static final String COMPILE_USER="%USER%";
+ echo. public static final String COMPILE_DATE="%compiledate%";
+ echo.
+ echo. @Override
+ echo. public String toString^(^) {
+ echo. return "Sqoop " + VERSION + "\n"
+ echo. + "git commit id " + GIT_HASH + "\n"
+ echo. + "Compiled by " + COMPILE_USER
+ echo. + " on " + COMPILE_DATE + "\n";
+ echo. }
+ echo.}
+) > %newoutputfile%