Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Copying necessary 3rd party libs to project lib folder using PERL script

{{#eclipseproject:technology.higgins|eclipse_custom_style.css}}

  • Save the following script as copyLibs.pl
#!/usr/bin/perl -w

use strict;

sub getLibs {
	my $lib_dir = shift;
	my @jars = `find $lib_dir -name "*.jar" -print`;
	my %LIBS = ();
	foreach my $j(@jars) {
		$j =~ s/\s+//g;
		my ($jar_name) = $j =~ /.*\/(.+?\.jar)$/;	
		$LIBS{$jar_name} = $j;
	}
	return %LIBS;
}

if(@ARGV < 3) {
	print "Usage: $0 path_to_workspace path_to_lib project_name\n";
	exit(0);
}

my ($workspace_dir, $lib_dir, $project_name) = @ARGV;

my %LIBS = getLibs($lib_dir);

open(D, "${workspace_dir}/${project_name}/dependencies.xml") or die $!;
my %JARS = ();
while(my $ln = <D>) {
	chomp $ln;
	if($ln =~ /\.jar/) {
		my ($jar) = $ln =~ /id=\"(.*?)\"/;
		$JARS{$jar}++;
	}	
}
close(D);

mkdir("${workspace_dir}/${project_name}/lib") unless (-d "${workspace_dir}/${project_name}/lib");

foreach my $j(keys %JARS) {
	if($LIBS{$j}) {
		if(-f "${workspace_dir}/${project_name}/lib/${j}") {
			print "$j already exists\n";
			system("chmod 755 ${workspace_dir}/${project_name}/lib/${j}");	
		}
		else {
			system("cp $LIBS{$j} ${workspace_dir}/${project_name}/lib");
			system("chmod 755 ${workspace_dir}/${project_name}/lib/${j}");
		}
	}
	else {
		print "$j does not exists in $lib_dir\n";	
	}
}
  • run copyLibs.pl
 ./copyLibs.pl path_to_workspace path_to_lib project_name
 
 where path_to_workspace is the absolute or relative path to the eclipse workspace folder of Higgins projects
       path_to_lib is the absolute or relative path to the local folder where the 3rd party libs are saved (3rd party libs can reside under sub-directories of path_to_lib)
       project_name is the higgins project name (e.g. org.eclipse.higgins.idas.registry)

Note: This script requires cygwin (for Windows only) and PERL installed on your machine. You can get cygwin from http://www.cygwin.com for Windows

Back to the top