donaldp 01/11/09 03:15:14
Modified: . build.xml
Added: src/script complete-ant-cmd.pl
Log:
Add in a completiong script for nt build files.
Submitted by: Mike Williams <[EMAIL PROTECTED]>
Revision Changes Path
1.200 +5 -2 jakarta-ant/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/build.xml,v
retrieving revision 1.199
retrieving revision 1.200
diff -u -r1.199 -r1.200
--- build.xml 2001/11/08 12:58:20 1.199
+++ build.xml 2001/11/09 11:15:14 1.200
@@ -368,7 +368,7 @@
<include name="ant" />
<include name="antRun" />
</fixcrlf>
- <fixcrlf srcdir="${dist.bin}" includes="runant.pl" />
+ <fixcrlf srcdir="${dist.bin}" includes="*.pl" />
<chmod perm="ugo+rx" dir="${dist.dir}" type="dir" includes="**" />
<chmod perm="ugo+r" dir="${dist.dir}" type="file" includes="**" />
@@ -376,7 +376,7 @@
<fileset dir="${dist.bin}">
<include name="**/ant" />
<include name="**/antRun" />
- <include name="**/runant.pl" />
+ <include name="**/*.pl" />
</fileset>
</chmod>
</target>
@@ -506,6 +506,7 @@
<fixcrlf srcdir="${src.dist.dir}" eol="crlf" includes="*.bat" />
<fixcrlf srcdir="${src.dist.dir}" eol="lf">
<include name="**/*.sh" />
+ <include name="**/*.pl" />
<include name="**/ant" />
<include name="**/antRun" />
</fixcrlf>
@@ -550,11 +551,13 @@
<tarfileset dir="${dist.name}/.." mode="755" username="ant"
group="ant">
<include name="${dist.name}/bin/ant"/>
<include name="${dist.name}/bin/antRun"/>
+ <include name="${dist.name}/bin/*.pl"/>
</tarfileset>
<tarfileset dir="${dist.name}/.." username="ant" group="ant">
<include name="${dist.name}/**"/>
<exclude name="${dist.name}/bin/ant"/>
<exclude name="${dist.name}/bin/antRun"/>
+ <include name="${dist.name}/bin/*.pl"/>
</tarfileset>
</tar>
<gzip zipfile="${dist.base}/bin/${dist.name}-bin.tar.gz"
1.1 jakarta-ant/src/script/complete-ant-cmd.pl
Index: complete-ant-cmd.pl
===================================================================
#!/usr/bin/perl
#
# A script to allow Bash or Z-Shell to complete an Ant command-line.
#
# To install for Bash 2.0 or better, add the following to ~/.bashrc:
#
# $ complete -C complete-ant-cmd ant build.sh
#
# To install for Z-Shell 2.5 or better, add the following to ~/.zshrc:
#
# function ant_complete () {
# local args_line args
# read -l args_line
# set -A args $args_line
# set -A reply $(COMP_LINE=$args_line complete-ant-cmd ${args[1]} $1)
# }
# compctl -K ant_complete ant build.sh
#
# @author Mike Williams <[EMAIL PROTECTED]>
my $cmdLine = $ENV{'COMP_LINE'};
my $antCmd = $ARGV[0];
my $word = $ARGV[1];
my @completions;
if ($word =~ /^-/) {
list( restrict( $word, getArguments() ));
} elsif ($cmdLine =~ /-(f|buildfile)\s+\S*$/) {
list( getBuildFiles($word) );
} else {
list( restrict( $word, getTargets() ));
}
exit(0);
sub list {
for (@_) {
print "$_\n";
}
}
sub restrict {
my ($word, @completions) = @_;
grep( /^\Q$word\E/, @completions );
}
sub getArguments {
qw(-buildfile -debug -emacs -f -find -help -listener -logfile
-logger -projecthelp -quiet -verbose -version);
}
sub getBuildFiles {
my ($word) = @_;
grep( /\.xml$/, glob( "$word*" ));
}
sub getTargets {
# Look for build-file
my $buildFile = 'build.xml';
if ($cmdLine =~ /-(f|buildfile)\s+(\S+)/) {
$buildFile = $2;
}
return () unless (-f $buildFile);
# Run "ant -projecthelp" to list targets. Keep a cache of results in a
# cache-file.
my $cacheFile = $buildFile;
$cacheFile =~ s|(.*/)?(.*)|${1}.ant-targets-${2}|;
if ((!-e $cacheFile) || (-M $buildFile) < (-M $cacheFile)) {
open( CACHE, '>'.$cacheFile ) || die "can\'t write $cacheFile: $!\n";
open( HELP, "$antCmd -projecthelp -f '$buildFile'|" ) || return();
my %targets;
while( <HELP> ) {
if (/^\s+(\S+)/) {
$targets{$1}++;
}
}
my @targets = sort keys %targets;
for (@targets) { print CACHE "$_\n"; }
return @targets;
}
# Read the target-cache
open( CACHE, $cacheFile ) || die "can\'t read $cacheFile: $!\n";
my @targets;
while (<CACHE>) {
chop;
s/\r$//; # for Cygwin
push( @targets, $_ );
}
close( CACHE );
@targets;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>