; may be used repeatedly,
defaults to $prefixes
--tmpdir= Set temporary directory to ; default $TMPDIR
--verbose Turn on verbose mode
USAGE
exit 1;
}
############################################################################
#
# This is main()
#
############################################################################
{
my %o;
%o = ('add' => [],
'classpath' => [],
'logfile' => [],
'prefix' => [],
'help' => \&Usage,
'extension' => [],
'tmpdir' => $TMPDIR,
'jar' => $JAR,
);
Getopt::Long::GetOptions(\%o, "verbose", "classpath=s@", "logfile=s@",
"prefix=s@", "output=s", "extension=s",
"noClassPath", "noPrefix", "noExtension",
"tmpdir=s", "jar=s", "help", "add=s@");
unshift(@{$o{'classpath'}}, @{$o{'add'}});
push(@{$o{'classpath'}}, @CLASSPATH) unless $o{'noClassPath'};
push(@{$o{'extension'}}, @EXTENSIONS) unless $o{'noExtension'};
push(@{$o{'prefix'}}, @PREFIXES) unless $o{'noPrefix'};
die "No JAR executable found in $o{'jar'}" unless -x $o{'jar'};
my $output = $o{'output'} || Usage("Missing output file name");
my %classes;
foreach my $f (@{$o{'logfile'}}) {
ParseFile(\%o, $f, \%classes);
}
foreach my $f (@{$o{'add'}}) {
AddFile(\%o, $f, \%classes);
}
my $dir = TmpDir(\%o);
foreach my $j (@{$o{'classpath'}}) {
ExtractJar(\%o, $j, \%classes, $dir);
}
while (my($key, $val) = each %classes) {
print "Warning: Missing class $key\n" if $val;
}
my $flags = $o{'verbose'} ? "cvf" : "cf";
my @cmd = ("\"$o{'jar'}\"", $flags, $o{'output'}, "-C", $dir, ".");
print join(" ", @cmd);
system @cmd;
File::Path::rmtree($dir, 0);
}
__END__
=head1 NAME
BuildAppletJar - Build JAR files for applets
=head1 SYNOPSIS
BuildAppletJar.pl --output=EjarfileE --logfile=ElogfileE
=head1 DESCRIPTION
This small Perl script parses one or more WWW server log files in
common log file format and attempts to detect class files, property
files and other files requested by applets. For example, if your
applets code base is
/myapplet
and there is a request for
/myapplet/mycompany/myclass.class
in the WWW servers log file, then the script assumes, that a file
F should be in the JAR file.
=head1 OPTIONS
=over
=item --add=EjarE
The contents of the directory EjarE or the JAR file EjarE
will be included into the generated JAR file completely. Additionally
the name EjarE will be prepended to the class file. See also
--classpath
=item --classpath=EjarE
The directory EjarE or the JAR file EjarE will be
prepended to the class file. Unlike the --add option, the contents
will not necessarily be included into the generated JAR file, only
if they are requested in the WWW servers log file. See also --add
and --noClassPath.
=item --extension=E.extE
By default only requests for files with the extensions E.classE
and E.propertiesE will be notices by the logfile parser. This
option allows to extend the list of extensions. See also --noExtension.
=item --jar=Ejar.exeE
Sets the path of the JAR binary. By default this will be searched in
the current execution path.
=item --logfile=EfileE
Sets the path of a WWW servers log file being parsed. You may use this
option multiple times.
=item --noClassPath
Cleans the default class path. Use --help to display the default
class path. See also --classpath and --add.
=item --noExtension
Cleans the default list of extensions. Use --help to display the
default list. See also --extension.
=item --noPrefix
Cleans the default list of prefixes. Use --help to display the
default list. See also --prefix.
=item --output
Sets the name of the JAR file being generated.
=item --prefix=E/prefixE
Sets the URL of your applets document or code base. For example, if your
applets class files are below
http://www.mycompany.com/myapplet/
then this should be /myapplet/. You may use this option multiple times.
See also --noPrefix.
=item --tmpdir=EdirE
Sets the name of a directory being used for temporary files.
=item --verbose
Turns on verbose mode.
=back
=head1 CPAN
This script is submitted to CPAN. The following sections are for
CPAN's automatic maintenance system and you can safely ignore them.
=head2 SCRIPT CATEGORIES
Web
=head2 PREREQUISITES
Archive::Zip
=head2 README
This script is for creating applet JAR files. The typical situation
is that you have some large libraries and know, that only parts
are required.
The idea is that you start working without JAR files, possibly
extracting library classes. The required classes are then determined
by looking into the WWW servers log files.
=head1 AUTHOR
Jochen Wiedmann
Software AG
Jochen.Wiedmann@SoftwareAG.com