执行导入的ant任务时,出现异常:
java.lang.ClassNotFoundException: org.apache.tools.ant.util.optional.ScriptRunner
我知道我在任务中的许多地方都使用了脚本。我这样使用它们:
<script manager="bsf" language="beanshell" classpath="${bshJar}"><![CDATA[
我想我必须以某种方式向ant-apache-bsf jar添加依赖项。我试过了
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 脚本任务?
最佳答案
绝对不是要接受的答案,只是解决方法。
当前,您通过BSF引擎使用Beanshell脚本。您可以将脚本转换为Javascript ,从JDK 6开始就不需要任何依赖。语法有点不同,但是以下ant任务可以在gradle + ant中直接使用:
<script language="javascript"><![CDATA[