5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-03 03:40:34 +08:00

SQOOP-949: Allow Sqoop to build on Windows OS

(Ahmed El Baz via Jarek Jarcec Cecho)
This commit is contained in:
Jarek Jarcec Cecho 2013-04-13 11:26:28 -07:00
parent 00d09b7b25
commit c4b0eac2d0
4 changed files with 247 additions and 22 deletions

View File

@ -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" />

View File

@ -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

View File

@ -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 %*

View File

@ -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%