diff --git a/build.xml b/build.xml index 8ac38726..e356ba6a 100644 --- a/build.xml +++ b/build.xml @@ -258,6 +258,17 @@ + + + + + + + + + + + @@ -326,12 +337,25 @@ - - - - - + + + + + + + + + + + + + + + + + @@ -421,21 +445,43 @@ the wrapper scripts to invoke each of these. --> - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/src/scripts/create-tool-scripts.cmd b/src/scripts/create-tool-scripts.cmd new file mode 100644 index 00000000..0ba79a1b --- /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 diff --git a/src/scripts/tool-script.cmd.template b/src/scripts/tool-script.cmd.template new file mode 100644 index 00000000..16ea73db --- /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 %* diff --git a/src/scripts/write-version-info.cmd b/src/scripts/write-version-info.cmd new file mode 100644 index 00000000..247f5f3c --- /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%