Сбой задачи Ant ‹junit› на Jenkins из-за ошибки NoSuchMethodError: org.apache.tools.ant.types.resources.Resources.setCache(Z)V

Я запускаю задачи ant в версии 1.7.1 Ant, используя плагин ant jenkins. Сбой сборки из-за следующей ошибки -

BUILD FAILED
java.lang.NoSuchMethodError: org.apache.tools.ant.types.resources.Resources.setCache(Z)V
    at org.apache.tools.ant.taskdefs.optional.junit.BatchTest.<init>(BatchTest.java:57)
    at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.createBatchTest(JUnitTask.java:556)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.IntrospectionHelper$CreateNestedCreator.create(IntrospectionHelper.java:1252)
    at org.apache.tools.ant.IntrospectionHelper$Creator.create(IntrospectionHelper.java:1169)
    at org.apache.tools.ant.UnknownElement.handleChild(UnknownElement.java:550)
    at org.apache.tools.ant.UnknownElement.handleChildren(UnknownElement.java:346)
    at org.apache.tools.ant.UnknownElement.configure(UnknownElement.java:198)
    at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:160)
    at org.apache.tools.ant.Task.perform(Task.java:347)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
    at org.apache.tools.ant.Main.runBuild(Main.java:758)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

Задача:

<target name="test" depends="compile-test" description="to run junits">
    <mkdir dir="${build.report}"/>

    <property name="junit.path" refid="junit.class.path"/>
    <!--<echo message="JUnit classpath ==> ${junit.path}"/>-->

    <junit printsummary="yes" fork="no" haltonerror="no" haltonfailure="no">
        <classpath refid="junit1.class.path"/>

        <formatter type="plain" usefile="false"/>
        <formatter type="xml"/>
        <batchtest todir="${build.report}">
            <fileset dir="${src.test}">
                <include name="**/Test*.java"/>
            </fileset>
        </batchtest>
    </junit>
</target>

Та же задача отлично работает на моем локальном компьютере с той же настройкой (включая версию ant). Может кто-нибудь, пожалуйста, посоветуйте, какова возможная основная причина здесь?


person Devendra Sharma    schedule 19.02.2018    source источник
comment
Я обнаружил, что метод setCache() недоступен в дистрибутиве ant 1.7.1, но в более поздних версиях.   -  person Devendra Sharma    schedule 21.02.2018


Ответы (1)


Я проверил дистрибутив Ant 1.7.1 и обнаружил, что такого метода нет.

org.apache.tools.ant.types.resources.Resources.setCache

Хотя странно, что я использую тот же дистрибутив (ant-1.7.1) в своей локальной сети, и он работает нормально. В моей системе нет другого дистрибутива. Тогда как он получает ссылку на любую более позднюю версию, содержащую этот метод? Происходит ли какое-либо неявное разрешение зависимостей в случае введения задачи ant ?

Примечание. Сервер Jenkins работает на другом компьютере и указывает на ту же версию дистрибутива ant, которая развернута на этом компьютере.

person Devendra Sharma    schedule 21.02.2018