开发者

How to export all dependency external libraries into a folder in eclipse automatically

开发者 https://www.devze.com 2022-12-25 04:09 出处:网络
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

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]

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号