use Cwd qw(abs_path getcwd);
use File::Path qw(make_path remove_tree);
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
$path = abs_path(dirname($exe));
$jarfile_name = "create-app-assembly-1.12.jar";
if ( m|app=(.*)| && -d $1 ) {
$app_path_root = abs_path($1);
$distro_jarfile = $jarfile = "$path/java/$jarfile_name";
$jarfile = "$path/../target/scala-2.12/$jarfile_name";
$jarfile = $distro_jarfile;
my $jardir = dirname($jarfile);
my $ff = File::Fetch->new(uri => 'http://casa.nrao.edu/download/devel/xml-casa/java/create-app-assembly-1.12.jar');
my $where = $ff->fetch( to => $jardir );
die "configuration error, cannot find jar file ($jarfile_name)" unless -e $jarfile;
@args = ( basename($java), '-jar', $jarfile );
die "cannot fork: $!" unless defined($pid = open(JAVA, "-|"));
while (my $line = <JAVA>) {
if ( $line =~ m|^created app directory\s+(.*)$| ) {
close(JAVA) or warn "kid exited $?";
exec { $java } @args or die "can't exec program: $!";