ちょっとした ftp スクリプトに groovy を使用したくて、この投稿を見つけまし たhttp://www.hhhhq.org/blog/2009/05/01/ftp-using-groovy-and-ant/ぶどうを使用。すべての依存関係が解決され、キャッシュに存在します。しかし、Ant に他のライブラリでオプションのタスクを見つけさせることができません。それはいつも言う
Caught: : Problem: failed to create task or type ftp
Cause: the class org.apache.tools.ant.taskdefs.optional.net.FTP was not found.
This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
-ANT_HOME\lib
-the IDE Ant configuration dialogs
Do not panic, this is a common problem.
The commonest cause is a missing JAR.
This is not a bug; it is a configuration problem
at GrabTest.runMe(GrabTest.groovy:15)
at GrabTest.run(GrabTest.groovy:26)
Groovy バージョン: 1.6.5 JVM: 1.6.0_15
ここに私のソースコードがあります
@Grab(group='ant', module='ant', version='[1.6.5,)')
@Grab(group='ant', module='ant-nodeps', version='[1.0,)')
@Grab(group='ant', module='ant-apache-oro', version='[1.0,)')
@Grab(group='ant', module='ant-commons-net', version='[1.0,)')
@Grab(group='apache-oro', module='jakarta-oro', version='[2.0.8,)')
@Grab(group='commons-net', module='commons-net', version='[1.4,)')
def runMe() {
// works
println getClass().getClassLoader().loadClass("org.apache.tools.ant.taskdefs.optional.net.FTP")
def ant = new AntBuilder()
println getClass().getClassLoader() //groovy.lang.GroovyClassLoader$InnerLoader
println ant.getClass().getClassLoader() //org.codehaus.groovy.tools.RootLoader
ant.ftp( server:"ftp.foo.com",
userid:"user",
password:"passwd",
passive:"yes",
verbose:"yes",
remotedir:"/pub/incoming",
binary:"yes" ) {
fileset( dir:"." ) { include( name:"**/*.gz" ) }
}
}
runMe()
ご覧のとおり、クラスローダーが問題であると思われますが、Grape はそこに依存関係を注入していないようです。どうすればそれを機能させることができるか考えていますか?