2016-11-13 58 views
0

當我執行導入的螞蟻任務,我得到一個異常:搖籃不能使用ant可選的(例如ScriptRunner腳本任務)

java.lang.ClassNotFoundException: org.apache.tools.ant.util.optional.ScriptRunner 

我知道我使用腳本在很多地方在我的任務。我使用它們像這樣:

<script manager="bsf" language="beanshell" classpath="${bshJar}"><![CDATA[ 

我猜我莫名其妙必須添加一個依賴於螞蟻的Apache-BSF罐子。我試過

buildscript { 
    repositories { 
    mavenCentral() 
    } 
    dependencies { 
    classpath 'org.apache.ant:ant-apache-bsf:+' 
    } 
} 

// Confirm the classpath contains optional jar. 
// The jar contains the required class. 
buildscript.configurations.classpath.each { println it } 

def sc = new org.apache.tools.ant.util.optional.ScriptRunner(); 
println "sure we are able to create a script runner object: $sc" 

ant.importBuild "build.xml" 

沒有成功。 Gradle用戶指南中有一篇文章,標題爲42.9 Ant optional dependencies。不幸的是,我從這篇文章中唯一能理解的是我的解決方案不起作用。這裏給出的例子沒有幫助。

我該如何使用我的ant腳本任務?

回答

0

絕對不是接受的答案,只是一個解決方法

目前您使用Beanshell腳本,通過BSF引擎。您可能轉換你的腳本的Javascript,不需要任何依賴關係,因爲JDK 6語法是有點不同,但以下Ant任務的gradle中的螞蟻+工作開箱:

<script language="javascript"><![CDATA[