Gradle无法执行ant任务

时间:2018-01-20 00:18:34

标签: java gradle ant ivy

我正在尝试从gradle文件

运行ant任务

在我的 build.gradle 中,我导入了ant.importBuild 'build.xml' 文件

<project xmlns:ivy="antlib:org.apache.ivy.ant">

    <target name="simpleAntTask">
        <echo>I am a ant task</echo>
    </target>

    <target name="ivyTask">
        <ivy:buildnumber
            organisation="daniel"
            module="hello"/>
    </target>
</project>

在我的 build.xml 中,我有两个简单的任务

Gradle

simpleAntTask运行任务2:14:31: Executing external task 'simpleAntTask'... :simpleAntTask [ant:echo] I am a ant task BUILD SUCCESSFUL Total time: 0.565 secs 2:14:32: External task execution finished 'simpleAntTask'. 时,一切都按预期进行,打印正常:

ant

但是当我运行使用ivy任务的:ivyTask FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':ivyTask'. > Problem: failed to create task or type antlib:org.apache.ivy.ant:buildnumber Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any <presetdef>/<macrodef> declarations have taken place. No types or tasks have been defined in this namespace yet This appears to be an antlib declaration. Action: Check that the implementing library exists in one of: -ANT_HOME/lib -the IDE Ant configuration dialogs 任务时,Gradle会抛出错误:

    class ExerciseType extends AbstractType {

        /**
         * {@inheritdoc}
         */
        public function buildForm(FormBuilderInterface $builder, array $options) {
            $builder->add('name')
                    ->add('content')
                    ->add('language')
                    ->add('level')
                    ->add('skillsRequired')
                    ->add('skillsTargetted')
                    ->add('tags')
                    ->add('product', ProductType::class, array(
                        'required' => false,
                        'exercise'=> $builder->getData()
                        )
                    );
        }

        /**
         * {@inheritdoc}
         */
        public function configureOptions(OptionsResolver $resolver){
            $resolver->setDefaults(array(
                'data_class' => 'SchoolBundle\Entity\Exercise'
            ));
        }

        /**
         * {@inheritdoc}
         */
        public function getBlockPrefix(){
            return 'schoolbundle_exercise';
        }

class ProductType extends AbstractType {
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options){

        $builder->add('visibility')->add('price', MoneyType::class);

        $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
            $product = $event->getData();
            $form = $event->getForm();

            $field = (!$product || null === $product->getId()) ? 'publicationDate' : 'updateDate';
            $form->add($field, DateTimeType::class, array('data' => new \DateTime()));

        });

        $data = array(
            'data' => $options['exercise'],
            'class' => Exercise::class,
            'choice_label' => 'getName'
        );

        $builder->add('exercise', EntityType::class, $data);
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver){
        $resolver->setDefaults(array(
            'data_class' => 'MarketBundle\Entity\Product'
        ));

        $resolver->setRequired(array(
            'exercise'
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix(){
        return 'marketbundle_product';
    }


}

我在互联网上搜索了很长时间寻找解决方案,但找不到任何东西,
有什么我想念的吗?

0 个答案:

没有答案