首页

关于ideal的gradle项目运行报"Unnecessarily replacing a task that does not exist is not supported.."无法编译问题

标签:ideal,gradle项目,BUILD FAILED,Unnecessarily,delegatedBuild,无法编译     发布时间:2022-03-30   

一、问题描述

关于ideal开发工具下创建gradle项目,运行编译报“Unnecessarily replacing a task that does not exist is not supported.  Use create() or register() directly instead.  You attempted to replace a task named 'abc.main()', but there is no existing task with that name..”,控制台报错详情

10:15:26: Executing task 'abc.main()'...@b@@b@@b@FAILURE: Build failed with an exception.@b@@b@* Where:@b@Initialization script 'C:\Users\Think\AppData\Local\Temp\abc_main__.gradle' line: 18@b@@b@* What went wrong:@b@A problem occurred configuring root project 'aaa'.@b@> Could not create task ':abc.main()'.@b@   > Unnecessarily replacing a task that does not exist is not supported.  Use create() or register() directly instead.  You attempted to replace a task named 'abc.main()', but there is no existing task with that name.@b@@b@* Try:@b@Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.@b@@b@* Get more help at https://help.gradle.org@b@@b@Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.@b@Use '--warning-mode all' to show the individual deprecation warnings.@b@See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings@b@@b@BUILD FAILED in 190ms@b@Unnecessarily replacing a task that does not exist is not supported.  Use create() or register() directly instead.  You attempted to replace a task named 'abc.main()', but there is no existing task with that name.@b@10:15:26: Task execution finished 'abc.main()'.

二、解决方法

1、在项目路径.idea目录下面gradle.xml添加"delegatedBuild"编译配置

<option name="delegatedBuild" value="false" />

330-1副本.jpg

2、重新标记项目的源码节点

330-2.jpg

3、运行后可以正常编译执行

330-2.jpg

@b@