kvm 0.0.1.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. data/.gitignore +3 -0
  2. data/.rvmrc +1 -0
  3. data/AGPL-3.0 +661 -0
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +32 -0
  6. data/LICENSE +23 -0
  7. data/README.md +73 -0
  8. data/Rakefile +48 -0
  9. data/bin/kvm +6 -0
  10. data/kvm.gemspec +28 -0
  11. data/lib/kvm.rb +286 -0
  12. data/lib/kvm/archive.rb +56 -0
  13. data/lib/kvm/artifact.rb +28 -0
  14. data/lib/kvm/db/jdbc_adapter.rb +71 -0
  15. data/lib/kvm/db/oracle.rb +23 -0
  16. data/lib/kvm/db/types.rb +11 -0
  17. data/lib/kvm/impex.rb +109 -0
  18. data/lib/kvm/log.rb +7 -0
  19. data/lib/kvm/resource.rb +72 -0
  20. data/lib/kvm/rice_release.rb +79 -0
  21. data/lib/kvm/rice_release_generated_dataset.rb +68 -0
  22. data/lib/kvm/source.rb +33 -0
  23. data/lib/kvm/subversion.rb +52 -0
  24. data/lib/kvm/version.rb +3 -0
  25. data/lib/kvm/wallet.rb +64 -0
  26. data/support/ant/INSTALL +2 -0
  27. data/support/ant/KEYS +1398 -0
  28. data/support/ant/LICENSE +272 -0
  29. data/support/ant/NOTICE +6 -0
  30. data/support/ant/README +97 -0
  31. data/support/ant/WHATSNEW +5467 -0
  32. data/support/ant/bin/ant +335 -0
  33. data/support/ant/bin/ant.bat +218 -0
  34. data/support/ant/bin/ant.cmd +93 -0
  35. data/support/ant/bin/antRun +24 -0
  36. data/support/ant/bin/antRun.bat +50 -0
  37. data/support/ant/bin/antRun.pl +66 -0
  38. data/support/ant/bin/antenv.cmd +98 -0
  39. data/support/ant/bin/complete-ant-cmd.pl +114 -0
  40. data/support/ant/bin/envset.cmd +131 -0
  41. data/support/ant/bin/lcp.bat +31 -0
  42. data/support/ant/bin/runant.pl +153 -0
  43. data/support/ant/bin/runant.py +102 -0
  44. data/support/ant/bin/runrc.cmd +60 -0
  45. data/support/ant/etc/ant-bootstrap.jar +0 -0
  46. data/support/ant/etc/changelog.xsl +148 -0
  47. data/support/ant/etc/checkstyle/checkstyle-frames.xsl +299 -0
  48. data/support/ant/etc/checkstyle/checkstyle-text.xsl +34 -0
  49. data/support/ant/etc/checkstyle/checkstyle-xdoc.xsl +130 -0
  50. data/support/ant/etc/coverage-frames.xsl +489 -0
  51. data/support/ant/etc/jdepend-frames.xsl +487 -0
  52. data/support/ant/etc/jdepend.xsl +276 -0
  53. data/support/ant/etc/junit-frames-xalan1.xsl +733 -0
  54. data/support/ant/etc/junit-frames.xsl +902 -0
  55. data/support/ant/etc/junit-noframes.xsl +478 -0
  56. data/support/ant/etc/log.xsl +203 -0
  57. data/support/ant/etc/maudit-frames.xsl +503 -0
  58. data/support/ant/etc/mmetrics-frames.xsl +1026 -0
  59. data/support/ant/etc/tagdiff.xsl +179 -0
  60. data/support/ant/fetch.xml +343 -0
  61. data/support/ant/get-m2.xml +121 -0
  62. data/support/ant/lib/README +3 -0
  63. data/support/ant/lib/ant-antlr.jar +0 -0
  64. data/support/ant/lib/ant-antlr.pom +76 -0
  65. data/support/ant/lib/ant-apache-bcel.jar +0 -0
  66. data/support/ant/lib/ant-apache-bcel.pom +72 -0
  67. data/support/ant/lib/ant-apache-bsf.jar +0 -0
  68. data/support/ant/lib/ant-apache-bsf.pom +75 -0
  69. data/support/ant/lib/ant-apache-log4j.jar +0 -0
  70. data/support/ant/lib/ant-apache-log4j.pom +70 -0
  71. data/support/ant/lib/ant-apache-oro.jar +0 -0
  72. data/support/ant/lib/ant-apache-oro.pom +75 -0
  73. data/support/ant/lib/ant-apache-regexp.jar +0 -0
  74. data/support/ant/lib/ant-apache-regexp.pom +71 -0
  75. data/support/ant/lib/ant-apache-resolver.jar +0 -0
  76. data/support/ant/lib/ant-apache-resolver.pom +70 -0
  77. data/support/ant/lib/ant-apache-xalan2.jar +0 -0
  78. data/support/ant/lib/ant-apache-xalan2.pom +95 -0
  79. data/support/ant/lib/ant-commons-logging.jar +0 -0
  80. data/support/ant/lib/ant-commons-logging.pom +71 -0
  81. data/support/ant/lib/ant-commons-net.jar +0 -0
  82. data/support/ant/lib/ant-commons-net.pom +76 -0
  83. data/support/ant/lib/ant-jai.jar +0 -0
  84. data/support/ant/lib/ant-jai.pom +85 -0
  85. data/support/ant/lib/ant-javamail.jar +0 -0
  86. data/support/ant/lib/ant-javamail.pom +79 -0
  87. data/support/ant/lib/ant-jdepend.jar +0 -0
  88. data/support/ant/lib/ant-jdepend.pom +73 -0
  89. data/support/ant/lib/ant-jmf.jar +0 -0
  90. data/support/ant/lib/ant-jmf.pom +66 -0
  91. data/support/ant/lib/ant-jsch.jar +0 -0
  92. data/support/ant/lib/ant-jsch.pom +75 -0
  93. data/support/ant/lib/ant-junit.jar +0 -0
  94. data/support/ant/lib/ant-junit.pom +101 -0
  95. data/support/ant/lib/ant-junit4.jar +0 -0
  96. data/support/ant/lib/ant-junit4.pom +71 -0
  97. data/support/ant/lib/ant-launcher.jar +0 -0
  98. data/support/ant/lib/ant-launcher.pom +58 -0
  99. data/support/ant/lib/ant-netrexx.jar +0 -0
  100. data/support/ant/lib/ant-netrexx.pom +99 -0
  101. data/support/ant/lib/ant-parent.pom +120 -0
  102. data/support/ant/lib/ant-swing.jar +0 -0
  103. data/support/ant/lib/ant-swing.pom +67 -0
  104. data/support/ant/lib/ant-testutil.jar +0 -0
  105. data/support/ant/lib/ant-testutil.pom +75 -0
  106. data/support/ant/lib/ant.jar +0 -0
  107. data/support/ant/lib/ant.pom +222 -0
  108. data/support/ant/lib/libraries.properties +65 -0
  109. data/test/data/files/rice-0.0.0.0-bin.tar.gz +0 -0
  110. data/test/data/svn/README.txt +5 -0
  111. data/test/data/svn/conf/authz +32 -0
  112. data/test/data/svn/conf/passwd +8 -0
  113. data/test/data/svn/conf/svnserve.conf +47 -0
  114. data/test/data/svn/db/current +1 -0
  115. data/test/data/svn/db/format +2 -0
  116. data/test/data/svn/db/fs-type +1 -0
  117. data/test/data/svn/db/fsfs.conf +37 -0
  118. data/test/data/svn/db/min-unpacked-rev +1 -0
  119. data/test/data/svn/db/rep-cache.db +0 -0
  120. data/test/data/svn/db/revprops/0/0 +5 -0
  121. data/test/data/svn/db/revprops/0/1 +13 -0
  122. data/test/data/svn/db/revs/0/0 +11 -0
  123. data/test/data/svn/db/revs/0/1 +0 -0
  124. data/test/data/svn/db/txn-current +1 -0
  125. data/test/data/svn/db/txn-current-lock +0 -0
  126. data/test/data/svn/db/uuid +1 -0
  127. data/test/data/svn/db/write-lock +0 -0
  128. data/test/data/svn/format +1 -0
  129. data/test/data/svn/hooks/post-commit.tmpl +50 -0
  130. data/test/data/svn/hooks/post-lock.tmpl +44 -0
  131. data/test/data/svn/hooks/post-revprop-change.tmpl +56 -0
  132. data/test/data/svn/hooks/post-unlock.tmpl +42 -0
  133. data/test/data/svn/hooks/pre-commit.tmpl +81 -0
  134. data/test/data/svn/hooks/pre-lock.tmpl +71 -0
  135. data/test/data/svn/hooks/pre-revprop-change.tmpl +66 -0
  136. data/test/data/svn/hooks/pre-unlock.tmpl +63 -0
  137. data/test/data/svn/hooks/start-commit.tmpl +65 -0
  138. data/test/data/svn/locks/db-logs.lock +3 -0
  139. data/test/data/svn/locks/db.lock +3 -0
  140. data/test/helper.rb +146 -0
  141. data/test/int_test_generate_sql.rb +58 -0
  142. data/test/test_archive.rb +35 -0
  143. data/test/test_generate_sql.rb +0 -0
  144. data/test/test_rice_release.rb +61 -0
  145. data/test/test_rice_release_generated_dataset.rb +12 -0
  146. data/test/test_source.rb +31 -0
  147. data/test/test_subversion.rb +20 -0
  148. metadata +298 -0
@@ -0,0 +1,93 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one or more
3
+ contributor license agreements. See the NOTICE file distributed with
4
+ this work for additional information regarding copyright ownership.
5
+ The ASF licenses this file to You under the Apache License, Version 2.0
6
+ (the "License"); you may not use this file except in compliance with
7
+ the License. You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ Run ant
18
+ */
19
+
20
+ '@echo off'
21
+ parse arg mode envarg '::' antarg
22
+
23
+ if mode\='.' & mode\='..' & mode\='/' then do
24
+ envarg = mode envarg
25
+ mode = ''
26
+ end
27
+
28
+ if antarg = '' then do
29
+ antarg = envarg
30
+ envarg = ''
31
+ end
32
+
33
+ x = setlocal()
34
+
35
+ env="OS2ENVIRONMENT"
36
+ antenv = _getenv_('antenv')
37
+ if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"'
38
+
39
+ if mode = '' then mode = _getenv_('ANT_MODE' '..')
40
+ if mode \= '/' then do
41
+ runrc = _getenv_('runrc')
42
+ antrc = _getenv_('antrc' 'antrc.cmd')
43
+ if mode = '..' then mode = '-r'
44
+ else mode = ''
45
+ interpret 'call "' || runrc || '"' antrc '"' || mode || '"'
46
+ end
47
+
48
+ if _testenv_() = 0 then do
49
+ say 'Ant environment is not set properly'
50
+ x = endlocal()
51
+ exit 16
52
+ end
53
+
54
+ settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME
55
+
56
+ java = _getenv_('javacmd' 'java')
57
+ opts = value('ANT_OPTS',,env)
58
+ args = value('ANT_ARGS',,env)
59
+ lcp = value('LOCALCLASSPATH',,env)
60
+ cp = value('CLASSPATH',,env)
61
+ if value('ANT_USE_CP',,env) \= '' then do
62
+ if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';'
63
+ lcp = lcp || cp
64
+ 'SET CLASSPATH='
65
+ end
66
+ if lcp\='' then lcp = '-classpath' lcp
67
+
68
+ cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg
69
+ launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists')
70
+ if launcher = '' then entry = 'org.apache.tools.ant.Main'
71
+ else entry = 'org.apache.tools.ant.launch.Launcher'
72
+ java opts lcp entry settings args antarg
73
+
74
+ x = endlocal()
75
+
76
+ return rc
77
+
78
+ _testenv_: procedure expose env ANT_HOME JAVA_HOME
79
+ ANT_HOME = value('ANT_HOME',,env)
80
+ if ANT_HOME = '' then return 0
81
+ JAVA_HOME = value('JAVA_HOME',,env)
82
+ if JAVA_HOME = '' then return 0
83
+ cp = translate(value('CLASSPATH',,env))
84
+ if pos(translate(ANT_HOME), cp) = 0 then return 0
85
+ if pos(translate(JAVA_HOME), cp) = 0 then return 0
86
+ return 1
87
+
88
+ _getenv_: procedure expose env
89
+ parse arg envar default
90
+ if default = '' then default = envar
91
+ var = value(translate(envar),,env)
92
+ if var = '' then var = default
93
+ return var
@@ -0,0 +1,24 @@
1
+ #! /bin/sh
2
+
3
+ # Licensed to the Apache Software Foundation (ASF) under one or more
4
+ # contributor license agreements. See the NOTICE file distributed with
5
+ # this work for additional information regarding copyright ownership.
6
+ # The ASF licenses this file to You under the Apache License, Version 2.0
7
+ # (the "License"); you may not use this file except in compliance with
8
+ # the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ # Args: DIR command
19
+ cd "$1"
20
+ CMD="$2"
21
+ shift
22
+ shift
23
+
24
+ exec "$CMD" "$@"
@@ -0,0 +1,50 @@
1
+ @echo off
2
+
3
+ REM Licensed to the Apache Software Foundation (ASF) under one or more
4
+ REM contributor license agreements. See the NOTICE file distributed with
5
+ REM this work for additional information regarding copyright ownership.
6
+ REM The ASF licenses this file to You under the Apache License, Version 2.0
7
+ REM (the "License"); you may not use this file except in compliance with
8
+ REM the License. You may obtain a copy of the License at
9
+ REM
10
+ REM http://www.apache.org/licenses/LICENSE-2.0
11
+ REM
12
+ REM Unless required by applicable law or agreed to in writing, software
13
+ REM distributed under the License is distributed on an "AS IS" BASIS,
14
+ REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ REM See the License for the specific language governing permissions and
16
+ REM limitations under the License.
17
+
18
+ if "%OS%"=="Windows_NT" @setlocal
19
+ if "%OS%"=="WINNT" @setlocal
20
+
21
+ if ""%1""=="""" goto runCommand
22
+
23
+ rem Change drive and directory to %1
24
+ if "%OS%"=="Windows_NT" goto nt_cd
25
+ if "%OS%"=="WINNT" goto nt_cd
26
+ cd ""%1""
27
+ goto end_cd
28
+ :nt_cd
29
+ cd /d ""%1""
30
+ :end_cd
31
+ shift
32
+
33
+ rem Slurp the command line arguments. This loop allows for an unlimited number
34
+ rem of arguments (up to the command line limit, anyway).
35
+ set ANT_RUN_CMD=%1
36
+ if ""%1""=="""" goto runCommand
37
+ shift
38
+ :loop
39
+ if ""%1""=="""" goto runCommand
40
+ set ANT_RUN_CMD=%ANT_RUN_CMD% %1
41
+ shift
42
+ goto loop
43
+
44
+ :runCommand
45
+ rem echo %ANT_RUN_CMD%
46
+ %ANT_RUN_CMD%
47
+
48
+ if "%OS%"=="Windows_NT" @endlocal
49
+ if "%OS%"=="WINNT" @endlocal
50
+
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/perl
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one or more
4
+ # contributor license agreements. See the NOTICE file distributed with
5
+ # this work for additional information regarding copyright ownership.
6
+ # The ASF licenses this file to You under the Apache License, Version 2.0
7
+ # (the "License"); you may not use this file except in compliance with
8
+ # the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ #######################################################################
19
+ #
20
+ # antRun.pl
21
+ #
22
+ # wrapper script for invoking commands on a platform with Perl installed
23
+ # this is akin to antRun.bat, and antRun the SH script
24
+ #
25
+ # created: 2001-10-18
26
+ # author: Jeff Tulley jtulley@novell.com
27
+ #######################################################################
28
+ #be fussy about variables
29
+ use strict;
30
+
31
+ #turn warnings on during dev; generates a few spurious uninitialised var access warnings
32
+ #use warnings;
33
+
34
+ #and set $debug to 1 to turn on trace info (currently unused)
35
+ my $debug=1;
36
+
37
+ #######################################################################
38
+ # change drive and directory to "%1"
39
+ my $ANT_RUN_CMD = @ARGV[0];
40
+
41
+ # assign current run command to "%2"
42
+ chdir (@ARGV[0]) || die "Can't cd to $ARGV[0]: $!\n";
43
+ if ($^O eq "NetWare") {
44
+ # There is a bug in Perl 5 on NetWare, where chdir does not
45
+ # do anything. On NetWare, the following path-prefixed form should
46
+ # always work. (afaict)
47
+ $ANT_RUN_CMD .= "/".@ARGV[1];
48
+ }
49
+ else {
50
+ $ANT_RUN_CMD = @ARGV[1];
51
+ }
52
+
53
+ # dispose of the first two arguments, leaving only the command's args.
54
+ shift;
55
+ shift;
56
+
57
+ # run the command
58
+ my $returnValue = system $ANT_RUN_CMD, @ARGV;
59
+ if ($returnValue eq 0) {
60
+ exit 0;
61
+ }
62
+ else {
63
+ # only 0 and 1 are widely recognized as exit values
64
+ # so change the exit value to 1
65
+ exit 1;
66
+ }
@@ -0,0 +1,98 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one or more
3
+ contributor license agreements. See the NOTICE file distributed with
4
+ this work for additional information regarding copyright ownership.
5
+ The ASF licenses this file to You under the Apache License, Version 2.0
6
+ (the "License"); you may not use this file except in compliance with
7
+ the License. You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+
18
+ '@echo off'
19
+ call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
20
+ call SysLoadFuncs
21
+
22
+ /* Prepare the parameters for later use */
23
+ parse arg argv
24
+ mode = ''
25
+ args = ''
26
+ opts = ''
27
+ cp = ''
28
+ lcp = ''
29
+
30
+ do i = 1 to words(argv)
31
+ param = word(argv, i)
32
+ select
33
+ when param='-lcp' then mode = 'l'
34
+ when param='-cp' | param='-classpath' then mode = 'c'
35
+ when abbrev('-opts', param, 4) then mode = 'o'
36
+ when abbrev('-args', param, 4) then mode = 'a'
37
+ otherwise
38
+ select
39
+ when mode = 'a' then args = space(args param, 1)
40
+ when mode = 'c' then cp = space(cp param, 1)
41
+ when mode = 'l' then lcp = space(lcp param, 1)
42
+ when mode = 'o' then opts = space(opts param, 1)
43
+ otherwise
44
+ say 'Option' param 'ignored'
45
+ end
46
+ end
47
+ end
48
+
49
+ env="OS2ENVIRONMENT"
50
+ antconf = _getenv_('antconf' 'antconf.cmd')
51
+ runrc = _getenv_('runrc')
52
+ interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC'
53
+ ANT_HOME = value('ANT_HOME',,env)
54
+ JAVA_HOME = value('JAVA_HOME',,env)
55
+ classpath = value('CLASSPATH',,env)
56
+ classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS")
57
+ if classes \= '' then classpath = prepend(classpath classes)
58
+ classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS")
59
+ if classes \= '' then classpath = prepend(classpath classes)
60
+
61
+ classpath = prepend(classpath ANT_HOME || '\lib\ant-launcher.jar')
62
+ 'SET CLASSPATH=' || classpath
63
+
64
+ /* Setting classpathes, options and arguments */
65
+ envset = _getenv_('envset')
66
+ if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"'
67
+ if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"'
68
+ if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"'
69
+ if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"'
70
+
71
+ exit 0
72
+
73
+ addpath: procedure
74
+ parse arg path elem
75
+ if elem = '' then do
76
+ if path\='' & right(path, 1)\=';' then path = path || ';'
77
+ return path
78
+ end
79
+ if substr(path, length(path)) = ';' then glue = ''
80
+ else glue = ';'
81
+ if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';'
82
+ return path
83
+
84
+ prepend: procedure
85
+ parse arg path elem
86
+ if elem = '' then do
87
+ if path\='' & right(path, 1)\=';' then path = path || ';'
88
+ return path
89
+ end
90
+ if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path
91
+ return path
92
+
93
+ _getenv_: procedure expose env
94
+ parse arg envar default
95
+ if default = '' then default = envar
96
+ var = value(translate(envar),,env)
97
+ if var = '' then var = default
98
+ return var
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/perl
2
+ #
3
+ # Licensed to the Apache Software Foundation (ASF) under one or more
4
+ # contributor license agreements. See the NOTICE file distributed with
5
+ # this work for additional information regarding copyright ownership.
6
+ # The ASF licenses this file to You under the Apache License, Version 2.0
7
+ # (the "License"); you may not use this file except in compliance with
8
+ # the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+ # A script to allow Bash or Z-Shell to complete an Ant command-line.
19
+ #
20
+ # To install for Bash 2.0 or better, add the following to ~/.bashrc:
21
+ #
22
+ # $ complete -C complete-ant-cmd ant build.sh
23
+ #
24
+ # To install for Z-Shell 2.5 or better, add the following to ~/.zshrc:
25
+ #
26
+ # function ant_complete () {
27
+ # local args_line args
28
+ # read -l args_line
29
+ # set -A args $args_line
30
+ # set -A reply $(COMP_LINE=$args_line complete-ant-cmd ${args[1]} $1)
31
+ # }
32
+ # compctl -K ant_complete ant build.sh
33
+ #
34
+ # @author Mike Williams <mikew@cortexebusiness.com.au>
35
+
36
+ my $cmdLine = $ENV{'COMP_LINE'};
37
+ my $antCmd = $ARGV[0];
38
+ my $word = $ARGV[1];
39
+
40
+ my @completions;
41
+ if ($word =~ /^-/) {
42
+ list( restrict( $word, getArguments() ));
43
+ } elsif ($cmdLine =~ /-(f|buildfile)\s+\S*$/) {
44
+ list( getBuildFiles($word) );
45
+ } else {
46
+ list( restrict( $word, getTargets() ));
47
+ }
48
+
49
+ exit(0);
50
+
51
+ sub list {
52
+ for (@_) {
53
+ print "$_\n";
54
+ }
55
+ }
56
+
57
+ sub restrict {
58
+ my ($word, @completions) = @_;
59
+ grep( /^\Q$word\E/, @completions );
60
+ }
61
+
62
+ sub getArguments {
63
+ qw(-buildfile -debug -emacs -f -find -help -listener -logfile
64
+ -logger -projecthelp -quiet -verbose -version);
65
+ }
66
+
67
+
68
+ sub getBuildFiles {
69
+ my ($word) = @_;
70
+ grep( /\.xml$/, glob( "$word*" ));
71
+ }
72
+
73
+ sub getTargets {
74
+
75
+ # Look for build-file
76
+ my $buildFile = 'build.xml';
77
+ if ($cmdLine =~ /-(f|buildfile)\s+(\S+)/) {
78
+ $buildFile = $2;
79
+ }
80
+ return () unless (-f $buildFile);
81
+
82
+ # Run "ant -projecthelp" to list targets. Keep a cache of results in a
83
+ # cache-file.
84
+ my $cacheFile = $buildFile;
85
+ $cacheFile =~ s|(.*/)?(.*)|${1}.ant-targets-${2}|;
86
+ if ((!-e $cacheFile) || (-z $cacheFile) || (-M $buildFile) < (-M $cacheFile)) {
87
+ open( CACHE, '>'.$cacheFile ) || die "can\'t write $cacheFile: $!\n";
88
+ open( HELP, "$antCmd -projecthelp -f '$buildFile'|" ) || return();
89
+ my %targets;
90
+ while( <HELP> ) {
91
+ if (/^\s+(\S+)/) {
92
+ $targets{$1}++;
93
+ }
94
+ }
95
+ my @targets = sort keys %targets;
96
+ for (@targets) { print CACHE "$_\n"; }
97
+ return @targets;
98
+ }
99
+
100
+ # Read the target-cache
101
+ open( CACHE, $cacheFile ) || die "can\'t read $cacheFile: $!\n";
102
+ my @targets;
103
+ while (<CACHE>) {
104
+ chop;
105
+ s/\r$//; # for Cygwin
106
+ push( @targets, $_ );
107
+ }
108
+ close( CACHE );
109
+ @targets;
110
+
111
+ }
112
+
113
+
114
+