grails - 如何从 Grails 3 插件中排除类

标签 grails plugins gradle grails-plugin grails-3.0

我正在尝试将 Grails 2 插件转换为 Grails 3,但我无法从生成的 jar 中排除几个仅在测试中使用的域类。

documentation状态:

in your build.gradle you should exclude the compiled classes from the JAR file:

jar {
    exclude "com/demo/**/**"
}

...但是如果我尝试这样做,我会从 Gradle 收到以下错误: 在根项目“...”上找不到参数 [build_64zizslf5a7zfo329yz5tdsoi$_run_closure1@566c53c] 的方法 jar()

我可以发布整个堆栈跟踪,但它看起来不是很有帮助。我使用的是 Gradle 2.3,由 create-plugin 命令生成的默认 Gradle 包装器提供。我还没有对 build.gradle 进行任何其他更改,因为我的插件不需要任何外部依赖项。

最佳答案

查看该项目 https://github.com/jeffbrown/excludesdemo 。其中包括 https://github.com/jeffbrown/excludesdemo/tree/master/grails-app/domain 下的 2 个域类.

顶级 build.gradle 文件位于 https://github.com/jeffbrown/excludesdemo/blob/72896a3f88f617d530bbdde8976d5bfe8d1e820a/build.gradle#L73包含以下内容:

jar {
    exclude 'package1/**'
}

当您运行 ./gradlew jar 时,您应该会看到 build/libs/excludesdemo-0.1-SNAPSHOT.jar 生成的 jar 文件确实包含 package2/Author.class 并且不包含 package1/Person.class

关于grails - 如何从 Grails 3 插件中排除类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31074013/

相关文章:

java - 为什么 IntelliJ Idea 无法识别我的 Spek 测试?

grails - 无法从 Java 类访问域属性(在 src 文件夹中)

grails - 如何在Grails中保留表单参数

data-binding - Grails 数据绑定(bind)

grails - 无法解析配置 ':profile'的所有依赖项

DLLNotFoundException - Unity3D 插件

html - 在图库中使用 MixItUp 插件

gradle - 如何在 Gradle 中并行运行特定任务

grails - Grails插件版本兼容性

Android Gradle 支持库必须使用相同版本