我想在我的 ANT 命令中使用 FTP 标签从 FTP 位置接收文件。为了启用此功能,我在ANT的lib文件夹中复制了jakarta-oro-2.0.8.jar
和apache-commons-net.jar
。运行命令时出现以下错误:java.lang.Error: Unresolved compilation
问题:
The import org.apache.oro cannot be resolved
The import org.apache.oro cannot be resolved
The import org.apache.oro cannot be resolved
The import org.apache.oro cannot be resolved
The import org.apache.oro cannot be resolved
The import org.apache.oro cannot be resolved
Pattern cannot be resolved to a type
MatchResult cannot be resolved to a type
PatternMatcher cannot be resolved to a type
_matcher_ cannot be resolved
Perl5Matcher cannot be resolved to a type
pattern cannot be resolved
Perl5Compiler cannot be resolved to a type
MalformedPatternException cannot be resolved to a type
result cannot be resolved or is not a field
_matcher_ cannot be resolved
pattern cannot be resolved or is not a field
result cannot be resolved or is not a field
_matcher_ cannot be resolved
result cannot be resolved or is not a field
result cannot be resolved or is not a field
result cannot be resolved or is not a field
result cannot be resolved or is not a field
result cannot be resolved or is not a field
result cannot be resolved or is not a field
result cannot be resolved or is not a field
at org.apache.commons.net.ftp.parser.RegexFTPFileEntryParserImpl.<init>(RegexFTPFileEntryParserImpl.java:19)
at org.apache.commons.net.ftp.parser.ConfigurableFTPFileEntryParserImpl.<init>(ConfigurableFTPFileEntryParserImpl.java:57)
at org.apache.commons.net.ftp.parser.UnixFTPEntryParser.<init>(UnixFTPEntryParser.java:136)
at org.apache.commons.net.ftp.parser.UnixFTPEntryParser.<init>(UnixFTPEntryParser.java:119)
at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createUnixFTPEntryParser(DefaultFTPFileEntryParserFactory.java:169)
at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:94)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2359)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2142)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2188)
at org.apache.tools.ant.taskdefs.optional.net.FTP$FTPDirectoryScanner.forceRemoteSensitivityCheck(FTP.java:695)
at org.apache.tools.ant.taskdefs.optional.net.FTP$FTPDirectoryScanner.scan(FTP.java:372)
at org.apache.tools.ant.taskdefs.optional.net.FTP.transferFiles(FTP.java:1738)
at org.apache.tools.ant.taskdefs.optional.net.FTP.transferFiles(FTP.java:1850)
at org.apache.tools.ant.taskdefs.optional.net.FTP.execute(FTP.java:2539)
为什么 Ant 无法导入 ORO 依赖项?
ANT
1.6.5 是一个非常旧的 ANT 版本。以下示例已使用 ANT 1.9.0 进行了测试:
<project name="demo" default="build">
<target name="bootstrap">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/commons-net.jar" src="http://search.maven.org/remotecontent?filepath=commons-net/commons-net/3.3/commons-net-3.3.jar"/>
<get dest="${user.home}/.ant/lib/oro.jar" src="http://search.maven.org/remotecontent?filepath=oro/oro/2.0.8/oro-2.0.8.jar"/>
</target>
<target name="build">
<ftp server="ftp.apache.org" userid="anonymous" password="me@myorg.com">
<fileset dir="htdocs/manual"/>
</ftp>
</target>
</project>
引导目标会将缺少的 ftp 任务依赖项安装到 ANT 下次运行时将使用的位置。