我在我的代码库中有一个自定义的Ant任务,需要使用Gradle。有很多关于如何使用打包在jar文件中的任务的例子,但这是不同的。如何设置Gradle自定义ant任务类路径?
我taskdef
应该是这个样子:
ant.taskdef(
name: 'generator',
classname: 'MyGenerator',
classpath: ???
)
的classpath
应包括一切bin/
(其中我的代码被编译到)和都在构建脚本的dependencies
节中列出的罐子。如何填补空白?
我试过了几个不同的东西,导致像The <taskdef> type doesn't support nested text data
或典型的NoClassDefFoundError
这样的晦涩信息。
没错,但是对于我描述的情况来说,依赖关系会是什么?我的情况不同是我需要'classpath'作为一个目录加上所有的'compile'依赖。 – david
如果这真的是你想要的,使用'classpath:sourceSets.main.runtimeClasspath.asPath'。确保在任务操作中执行此操作,而不是在配置时执行此操作。 –
@PeterNiederwieser将其作为答案,我会将其标记为已接受 – david