栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Eclipse中使用Ant的类路径

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Eclipse中使用Ant的类路径

受@ leeand00提供的链接启发,我提出了以下解决方法。

首先,我编写了一个简单的Perl脚本(称为

genClasspath.pl
),该脚本生成
.classpath
Eclipse使用的文件。

#!/usr/bin/perluse strict;if (@ARGV != 2) {  print STDERR "Usage: $0 OUTFILe CLASSPATHSTRINGn";  print STDERR "e.g., $0 .classpath path1:path2:path3n";  exit 1;}my $OUTFILe         = $ARGV[0];my $CLASSPATHSTRING = $ARGV[1];open my $out_fh, '>', $OUTFILe or die "Couldn't open output file: $!";print $out_fh q{<?xml version="1.0" encoding="UTF-8"?><classpath>    <classpathentry kind="src" path="src"/>    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>    <classpathentry kind="output" path="build"/>};my @libs = split(":", $CLASSPATHSTRING);foreach my $thisLib (@libs){    print $out_fh "    <classpathentry kind="lib" path="$thisLib"/>n";}print $out_fh "</classpath>n";

然后,我将

build.xml
文件的内容调用此脚本
dep.runtime

<target name="compile" depends="init">    <javac srcdir="${src}" destdir="${build}" debug="on" includeantruntime="false">        <classpath refid="dep.runtime" />    </javac>    <property name="myclasspath" refid="dep.runtime"/>    <exec dir="." executable="../../scripts/genClasspath.pl" os="Linux">        <arg value=".classpath"/>        <arg value="${myclasspath}"/>    </exec></target>

唯一的问题是,在Eclipse中打开项目之前,我至少需要在命令行上运行一次Ant。但是,当我这样做时,Eclipse可以很好地编译和执行我的项目,因为类路径与Ant的完全相同。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/570587.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号