Meta::Baseline::Lang::Java - doing Java specific stuff in the baseline.


Meta documentation Contained in the Meta distribution.

Index


Code Index:

NAME

Top

Meta::Baseline::Lang::Java - doing Java specific stuff in the baseline.

COPYRIGHT

Top

LICENSE

Top

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.

DETAILS

Top

	MANIFEST: Java.pm
	PROJECT: meta
	VERSION: 0.40

SYNOPSIS

Top

	package foo;
	use Meta::Baseline::Lang::Java qw();
	my($resu)=Meta::Baseline::Lang::Java::env();

DESCRIPTION

Top

This package contains stuff specific to Java in the baseline: 0. produce code to set Java specific vars in the baseline. 1. check Java files for correct Java syntax in the baseline. 0. produce minimal java usage. 1. check no numbers are in the code. 2. check correct customs for package names (all lower letter alpha caracters and numbers with no special chars separatered by "."). etc...

FUNCTIONS

Top

	get_jars()
	env()
	c2deps($)
	c2clas($)
	c2html($)
	c2chec($)
	class2file($)
	my_file($$)
	TEST($)

FUNCTION DOCUMENTATION

Top

get_jars()

This routine return a path segment to be added to java tool running in order for all baseline jars to be considered.

env()

This routine returns a hash of environment variables which are essential for running Java binaries.

c2deps($)

This routine will produce a file desribing the dependencies of the java source file to the cook mechanism. This method returns an error code.

c2clas($)

This routine will compile the java file. This method returns an error code.

c2html($)

This routine will create an html document from the java source file using java doc. This method returns an error code.

c2chec($)

This routine will apply different validataion methods on the source code which the compiler does not apply. This method returns an error code.

class2file($)

This method will convert a java class name to a file.

my_file($$)

This method will return true if the file received should be handled by this module.

TEST($)

Test suite for this module. This currently just runs the Env stuff and checks whats the output bash script.


Meta documentation Contained in the Meta distribution.

#!/bin/echo This is a perl module and should not be run

package Meta::Baseline::Lang::Java;

use strict qw(vars refs subs);
use Meta::Utils::File::Path qw();
use Meta::Baseline::Aegis qw();
use Meta::Baseline::Utils qw();
use Meta::Utils::File::Mkdir qw();
use Meta::Utils::File::Move qw();
use Meta::Baseline::Lang qw();
use Meta::Utils::Output qw();
use Meta::Utils::Env qw();

our($VERSION,@ISA);
$VERSION="0.40";
@ISA=qw(Meta::Baseline::Lang);

#sub get_jars();
#sub env();
#sub c2deps($);
#sub c2clas($);
#sub c2html($);
#sub c2chec($);
#sub class2file($);
#sub my_file($$);
#sub TEST($);

#__DATA__

sub get_jars() {
	my($jar0)=Meta::Baseline::Aegis::which("java/jars/classes12.jar");
	my($jar1)=Meta::Baseline::Aegis::which("java/jars/jaxp.jar");
	my($jar2)=Meta::Baseline::Aegis::which("java/jars/parser.jar");
	my($jar3)=Meta::Baseline::Aegis::which("java/jars/servlet.jar");
	return(join(':',$jar0,$jar1,$jar2,$jar3));
}

sub env() {
	my(%hash);
	my($class)="";
	my($sear)=Meta::Baseline::Aegis::search_path_list();
	for(my($i)=0;$i<=$#$sear;$i++) {
		my($curr)=$sear->[$i];
		$class=Meta::Utils::File::Path::add_path($class,
			$curr."/java/lib",":");
		$class=Meta::Utils::File::Path::add_path($class,
			$curr."/java/import/lib",":");
	}
	$hash{"CLASSPATH"}=$class;
	return(\%hash);
}

sub c2deps($) {
	my($buil)=@_;
	my($srcx)=$buil->get_srcx();
	my($modu)=$buil->get_modu();
	my($targ)=$buil->get_targ();
	my($path)=$buil->get_path();
	open(FILE,"> ".$targ) || throw Meta::Error::Simple("unable to open file [".$targ."]");
	Meta::Baseline::Utils::cook_emblem_print(*FILE);
	print FILE "cascade ".$srcx."=\n";
	my($obje)=Meta::Utils::Parse::Text->new();
	$obje->init_file($srcx);
	while(!$obje->get_over()) {
		my($line)=$obje->get_line();
		if($line=~/^import meta\..*;$/) {
#			Meta::Utils::Output::print("line is [".$line."]\n");
			my($class)=($line=~/^import (.*);$/);
			my($file)=class2file($class);
			print FILE $file."\n";
		}
		$obje->next();
	}
	$obje->fini();
	print FILE ";\n";
	close(FILE) || throw Meta::Error::Simple("unable to close file [".$targ."]");
	return(1);
}

sub c2clas($) {
	my($buil)=@_;
	my($srcx)=$buil->get_srcx();
	my($modu)=$buil->get_modu();
	my($targ)=$buil->get_targ();
	my($path)=$buil->get_path();
	my($jarx)=get_jars();
	my(@lptc)=split(":",$path);
	my(@lpts)=split(":",$path);
	for(my($i)=0;$i<=$#lptc;$i++) {
		$lptc[$i].="/clas/java/lib";
		$lpts[$i].="/java/lib";
#		Meta::Utils::File::Mkdir::mkdir_check($lptc[$i]);
	}
	my($pthc)=join(":",$jarx,@lptc);
	my($pths)=join(":",$jarx,@lpts);
	my($prog)="/local/tools/j2sdk1.4.1_01/bin/javac";
	my(@args);
	push(@args,"-O");
	# Add this if you want errors about deprecated features.
	# push(@args,"-deprecation");
	push(@args,"-nowarn");
	push(@args,"-classpath");
	push(@args,$pthc);
	push(@args,"-sourcepath");
	push(@args,$pths);
	push(@args,"-d");
	push(@args,"clas/java/lib");
	push(@args,$srcx);
	if(0) {
		for(my($i)=0;$i<=$#args;$i++) {
			Meta::Utils::Output::print("arg [".$i."] is [".$args[$i]."]\n");
		}
	}
	my($scod)=Meta::Utils::System::system_nodie($prog,\@args);
#	if($scod) {
#		my($name,$path,$suff)=File::Basename::fileparse($srcx,"\.java");
#		my($crea)=$path.$name.".class";
#		Meta::Utils::File::Move::mv($crea,$targ);
#	}
	return($scod);
#	open(FILE,"> ".$targ) || throw Meta::Error::Simple("unable to open file [".$targ."]");
#	Meta::Baseline::Utils::cook_emblem_print(*FILE);
#	close(FILE) || throw Meta::Error::Simple("unable to close file [".$targ."]");
#	return(1);
}

sub c2html($) {
	my($buil)=@_;
	my($srcx)=$buil->get_srcx();
	my($modu)=$buil->get_modu();
	my($targ)=$buil->get_targ();
	my($path)=$buil->get_path();
	my($dire)=File::Basename::dirname($targ);
	my($scod)=Meta::Utils::System::system_err_silent_nodie("javadoc",[$srcx,"-d","html/java/lib","-classpath",$path,"-noindex"]);
	#if(!(-f $targ)) {
	#	Meta::Baseline::Utils::file_emblem($targ);
	#}
	return($scod);
}

sub c2chec($) {
	my($buil)=@_;
	Meta::Baseline::Utils::file_emblem($buil->get_targ());
	return(1);
}

sub class2file($) {
	my($class)=@_;
#	Meta::Utils::Output::print("class is [".$class."]\n");
	$class=~s/\./\//g;
	$class="java/lib/".$class.".java";
	return($class);
}

sub my_file($$) {
	my($self,$file)=@_;
	if($file=~/^java\/.*\.java$/) {
		return(1);
	}
	if($file=~/^java\/.*\.jar$/) {
		return(1);
	}
	return(0);
}

sub TEST($) {
	my($context)=@_;
	my($hash)=Meta::Baseline::Lang::Java::env();
	Meta::Utils::Env::bash_cat($hash);
	return(1);
}

1;

__END__