Review Board 1.7.22


SQOOP-949: Allow Sqoop to build on Windows OS

Review Request #9961 - Created March 15, 2013 and updated

Ahmed El Baz
SQOOP-949
Reviewers
Sqoop
sqoop-trunk
Allow Sqoop to build on Windows OS
Associated Jira: https://issues.apache.org/jira/browse/SQOOP-949

Sqoop fails to build on Windows due to dependencies on Linux scripts like write-version-info.sh and create-tool-scripts.sh which fail to build on Windows without Cygwin.

The patch does the following:
- provide Windows scripts src/scripts/create-tool-scripts.cmd and src/scripts/write-version-info.cmd which perform the same logic as the .sh scripts on Linux.
- Update build.xml to invoke the appropriate script based on the host OS.
- Skip real-docs target on Windows OS builds since as it invokes Linux specific "make" executable
Verified builds are successful on both Linux and Windows, and Unit tests are fully passing on Linux. Fixes to unit tests on Windows will go in a separate patch
build.xml
Revision c097fe8 New Change
[20] 255 lines
[+20]
256
            value="OX.AC.UK"/>
256
            value="OX.AC.UK"/>
257

    
   
257

   
258
  <property name="java.security.krb5.kdc"
258
  <property name="java.security.krb5.kdc"
259
            value="kdc0.ox.ac.uk:kdc1.ox.ac.uk"/>
259
            value="kdc0.ox.ac.uk:kdc1.ox.ac.uk"/>
260

    
   
260

   

    
   
261
  <condition property="windows">

    
   
262
    <os family="windows" />

    
   
263
  </condition>

    
   
264

   

    
   
265
  <condition property="skip-real-docs">

    
   
266
    <or>

    
   
267
      <isset property="docs.uptodate" />

    
   
268
      <os family="windows" />

    
   
269
    </or>

    
   
270
  </condition>

    
   
271

   
261
  <if>
272
  <if>
262
    <isset property="sqoop.test.msserver.connector.factory"/>
273
    <isset property="sqoop.test.msserver.connector.factory"/>
263
    <then>
274
    <then>
264
      <echo message="Use ${sqoop.test.msserver.connector.factory}"/>
275
      <echo message="Use ${sqoop.test.msserver.connector.factory}"/>
265
    </then>
276
    </then>
[+20] [20] 58 lines
[+20]
324
    </path>
335
    </path>
325
  </target>
336
  </target>
326

    
   
337

   
327
  <!-- generate the version information class. -->
338
  <!-- generate the version information class. -->
328
  <target name="gen-version" depends="init">
339
  <target name="gen-version" depends="init">

    
   
340
    <if>

    
   
341
      <equals arg1="${windows}" arg2="true" />

    
   
342
      <then>

    
   
343
        <exec executable="${script.src.dir}/write-version-info.cmd"

    
   
344
            dir="${basedir}" failonerror="true">

    
   
345
          <arg value="${build.dir}" />

    
   
346
          <arg value="${version}" />

    
   
347
          <arg value="${git.hash}" />

    
   
348
        </exec>

    
   
349
      </then>

    
   
350
      <else>
329
    <exec executable="${script.src.dir}/write-version-info.sh"
351
        <exec executable="${script.src.dir}/write-version-info.sh"
330
        dir="${basedir}" failonerror="true">
352
            dir="${basedir}" failonerror="true">
331
      <arg value="${build.dir}" />
353
          <arg value="${build.dir}" />
332
      <arg value="${version}" />
354
          <arg value="${version}" />
333
      <arg value="${git.hash}" />
355
          <arg value="${git.hash}" />
334
    </exec>
356
        </exec>

    
   
357
      </else>

    
   
358
    </if>
335
  </target>
359
  </target>
336

    
   
360

   
337
  <!-- Compile core classes for the project -->
361
  <!-- Compile core classes for the project -->
338
  <target name="compile"
362
  <target name="compile"
339
      depends="init, gen-version, ivy-retrieve-hadoop"
363
      depends="init, gen-version, ivy-retrieve-hadoop"
[+20] [20] 79 lines
[+20]
419
      description="Create tool-specific wrapper scripts">
443
      description="Create tool-specific wrapper scripts">
420
    <!-- Take the list of available tools from 'sqoop help' and generate
444
    <!-- Take the list of available tools from 'sqoop help' and generate
421
         the wrapper scripts to invoke each of these.
445
         the wrapper scripts to invoke each of these.
422
      -->
446
      -->
423
    <mkdir dir="${build.bin.dir}" />
447
    <mkdir dir="${build.bin.dir}" />

    
   
448
    <if>

    
   
449
      <equals arg1="${windows}" arg2="true" />

    
   
450
      <then>

    
   
451
        <java classname="com.cloudera.sqoop.Sqoop"

    
   
452
            fork="true"

    
   
453
            failonerror="true"

    
   
454
            output="${build.dir}/tools-list"

    
   
455
            error="${build.dir}/script-gen-err">

    
   
456
          <jvmarg value="-Dhadoop.security.log.file=./build/security-audit.log" />

    
   
457
          <arg value="help" />

    
   
458
          <classpath refid="compile.classpath"/>

    
   
459
        </java>

    
   
460
        <exec executable="${script.src.dir}/create-tool-scripts.cmd"

    
   
461
            dir="${basedir}" failonerror="true">

    
   
462
          <arg value="${build.bin.dir}" />

    
   
463
          <arg value="${script.src.dir}/tool-script.cmd.template" />

    
   
464
          <arg value="${build.dir}/tools-list" />

    
   
465
        </exec>

    
   
466
      </then>

    
   
467
      <else>
424
    <java classname="com.cloudera.sqoop.Sqoop"
468
        <java classname="com.cloudera.sqoop.Sqoop"
425
        fork="true"
469
            fork="true"
426
        failonerror="true"
470
            failonerror="true"
427
        output="${build.dir}/tools-list"
471
            output="${build.dir}/tools-list"
428
        error="/dev/null">
472
            error="/dev/null">
[+20] [20] 5 lines
[+20]
434
        dir="${basedir}" failonerror="true">
478
            dir="${basedir}" failonerror="true">
435
      <arg value="${build.bin.dir}" />
479
          <arg value="${build.bin.dir}" />
436
      <arg value="${script.src.dir}/tool-script.sh.template" />
480
          <arg value="${script.src.dir}/tool-script.sh.template" />
437
      <arg value="${build.dir}/tools-list" />
481
          <arg value="${build.dir}/tools-list" />
438
    </exec>
482
        </exec>

    
   
483
      </else>

    
   
484
    </if>
439
  </target>
485
  </target>
440

    
   
486

   
441
  <target name="package"
487
  <target name="package"
442
      depends="jar-all,compile-all,docs,ivy-retrieve-redist,scripts"
488
      depends="jar-all,compile-all,docs,ivy-retrieve-redist,scripts"
443
      description="Create a redistributable package">
489
      description="Create a redistributable package">
[+20] [20] 490 lines
[+20]
934
  </target>
980
  </target>
935

    
   
981

   
936
  <target name="docs" depends="real-docs,relnotes,javadoc"
982
  <target name="docs" depends="real-docs,relnotes,javadoc"
937
      description="Build documentation"/>
983
      description="Build documentation"/>
938

    
   
984

   
939
  <target name="real-docs" depends="docs-uptodate,init" unless="docs.uptodate">
985
  <target name="real-docs" depends="docs-uptodate,init" unless="skip-real-docs">
940
    <exec executable="make" failonerror="true">
986
    <exec executable="make" failonerror="true">
941
      <arg value="-C" />
987
      <arg value="-C" />
942
      <arg value="${basedir}/src/docs" />
988
      <arg value="${basedir}/src/docs" />
943
      <arg value="BUILDROOT=${build.dir}" />
989
      <arg value="BUILDROOT=${build.dir}" />
944
      <arg value="VERSION=${version}" />
990
      <arg value="VERSION=${version}" />
[+20] [20] 282 lines
src/scripts/create-tool-scripts.cmd
New File
 
src/scripts/tool-script.cmd.template
New File
 
src/scripts/write-version-info.cmd
New File
 
  1. build.xml: Loading...
  2. src/scripts/create-tool-scripts.cmd: Loading...
  3. src/scripts/tool-script.cmd.template: Loading...
  4. src/scripts/write-version-info.cmd: Loading...