views:

126

answers:

2

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 wonder if there is a way to let the eclipse do it for me automatically.

A: 

You can probably do this with the Fat Jar Eclipse Plug-in.

You should probably consider start using Maven2 to manage your dependencies.

mgv
Thanks for your answer, Fat jar may help me in the future, but it's not what I need right now
gleery
A: 

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]

gleery