File: build.pl

package info (click to toggle)
libjaxen-java 1.0FCS-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,864 kB
  • ctags: 1,722
  • sloc: java: 10,771; xml: 7,834; perl: 99; makefile: 10
file content (140 lines) | stat: -rw-r--r-- 2,606 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/perl

use strict;
use Cwd;

my %options;
my $true;
my $false;

my $delim;

my $java_home;
my $classpath;
my @tools_classpath;
my @lib_classpath;

$true  = 1;
$false = 0;

if ( $^O =~ /win32/i || $^O =~/cygwin/ ) 
{
   $delim = ";";
}
else
{
   $delim = ":";
}

$| = 1;

## ------------------------------------------------------------------------
## ------------------------------------------------------------------------

if ( &checkJavaHome() ) 
{
	exit( 1 );
}

&setupJava();
&dumpBuildInfo();
&execAnt();

## ------------------------------------------------------------------------
## ------------------------------------------------------------------------

sub dumpBuildInfo()
{
	print "-----------------------------------------------\n\n";


	my $sec;
	my $min;
	my $hour;
	my $mday;
	my $mon;
	my $year;
	my $wday;
	my $yday;
	my $isdst;

	($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

	$year = $year + 1900;

	my $weekday = ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")[$wday];
	my $month   = ("January","February","March","April","May","June","July","August","September","October","November","December")[$mon];


	print "      date: $hour:$min:$sec $weekday $mday-$month-$year\n"; 
	print " directory: ", cwd(), "\n";

	my $targets;
	
	if ( $#ARGV >= 0 ) 
	{
		$targets = join ', ',  @ARGV;
	}
	else
	{
		$targets = '*default*';
	}
	print "   targets: $targets\n\n";

	print "-- CLASSPATH ----------------------------------\n";

	my $element;
	foreach $element ( split $delim, $classpath )
	{
		print "    $element\n";
	}

	print "-----------------------------------------------\n";
}

sub execAnt()
{
        if ( $^O =~/cygwin/ ) 
        {
	  system "$java_home/bin/java -cp '$classpath' org.apache.tools.ant.Main @ARGV";
	}
	else
	{
	  system "$java_home/bin/java -cp $classpath org.apache.tools.ant.Main @ARGV";
	}
}

sub setupJava()
{
	$java_home       = $ENV{"JAVA_HOME"};
	@tools_classpath = "$java_home/lib/tools.jar";

	@lib_classpath   = glob("./lib/*.jar");

	my $system_class_path;

	my @keys;

	$system_class_path = $ENV{"CLASSPATH"};

	$classpath = join $delim, @tools_classpath, @lib_classpath, $system_class_path;

	$ENV{"CLASSPATH"} = $classpath;
}


sub checkJavaHome()
{
	if ( $ENV{"JAVA_HOME"} eq "" )
	{
		print "ERROR: JAVA_HOME not found in your environment.\n\n";
		print "Please, set the JAVA_HOME variable in your environment\n";
		print "to match the location of the Java Virtual Machine\n";
		print "that you want to use.\n\n";
	
		return 1;
	}

	$java_home = $ENV{"JAVA_HOME"};
	return 0;
}