How to export all dependency external libraries into a folder in eclipse automatically
I want to copy all external dependency libraries to a directory, but I don't want to do this job manually, since there are quite lot of libraries. I wonde开发者_StackOverflow中文版r if there is a way to let the eclipse do it for me automatically.
You can probably do this with the Fat Jar Eclipse Plug-in.
You should probably consider start using Maven2 to manage your dependencies.
I've written a perl script to do it for me.
#!/usr/bin/perl
use strict;
use File::Copy;
use File::Basename;
my $path = $ARGV[0];
my $outputdir = $ARGV[1];
open(CLASSPATH, "<$path") or die "can't open $path";
my @lines = <CLASSPATH>;
close(CLASSPATH);
foreach my $line (@lines) {
if ($line =~ m/<classpathentry kind="lib" path="(.*?)".*?\/>/) {
print "copying".$1."\n";
copy($1, $outputdir.basename($1)) or print "failed to copy $1\n";
}
}
usage example: perl export-jar.pl [eclipse-classpath-file] [export-dir]
精彩评论