简体   繁体   English

如何将groovy类导入build.gradle脚本?

[英]How can I import groovy class to build.gradle script?

I have this project structure: 我有这个项目结构:

在此输入图像描述

And I try to use these classes in build.gradle script: 我尝试在build.gradle脚本中使用这些类:

task generateStubs(type: XjcExecTask) {

But Gradle doesn't see this class XjcExecTask . 但是Gradle没有看到这个类XjcExecTask

I try to add import com.pavel.* to this script but it doesn't recognize. 我尝试将import com.pavel.*添加到此脚本但它无法识别。

If your custom Groovy classes XjcExecTask and WsimportExecTask purpose is to be used by your build script only (and not packaged into a library you will share to other projects), then you should move the builder subproject into a so-called buildSrc project: see detailed description in following guides: 如果您的自定义Groovy类XjcExecTaskWsimportExecTask目的仅由构建脚本使用(而不是打包到您将共享给其他项目的库中),那么您应该将builder子项目移动到所谓的buildSrc项目中:请参阅详细信息以下指南中的说明:

https://guides.gradle.org/writing-gradle-plugins/ https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:build_sources https://guides.gradle.org/writing-gradle-plugins/ https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:build_sources

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM