首页 文章

弃用警告

提问于
浏览
13

我有这个代码:

task fatJar(type: Jar) << {
    manifest {
        attributes 'Implementation-Title': 'Gradle Jar File Example',
                'Implementation-Version': version,
                'Main-Class': 'mvc.MvcMain'
    }
    baseName = project.name + '-all'
    with jar
}

我收到了这个警告:

不建议在任务执行时配置复制任务的子规范,并计划在Gradle 4.0中将其删除 . 请考虑在配置时配置规范,或使用单独的任务进行配置 . 在build_b2xrs1xny0xxt8527sk0dvm2y $ _run_closure4.doCall

这个警告:

不推荐使用Task.leftShift(Closure)方法,并计划在Gradle 5.0中删除它 . 请改用Task.doLast(Action) .

如何重写我的任务?

1 回答

  • 0

    它可能看起来像这样;这应该至少解决其中一个警告:

    task fatJar(type: Jar) {
        manifest {
            attributes 'Implementation-Title': 'Gradle Jar File Example',
                       'Implementation-Version': version,
                       'Main-Class': 'mvc.MvcMain'
        }
        baseName = project.name + '-all'
        from {
            configurations.compile.collect {
                it.isDirectory() ? it : zipTree(it)
            } 
        }
        with jar
    }
    

相关问题