如何阻止 Gradle 复制构建文件夹中的资源

How to stop Gradle from copying resources in build folder

我的资源文件夹中有一个数据库 (.db-File),它被复制到我的 Java 代码的每个 运行 中(我想将该文件保留在那里,因为它是 'only' 一个大学项目,为了简单起见,我需要这个)。 复制会导致问题,在 运行 时间内通过代码所做的所有更改每次都会丢失,因为更改仅针对构建文件夹中的副本,而不是原始文件。

如何让Gradle停止复制此文件并强制它使用资源文件夹中的原始文件?

(类似问题,但没有 micronaut:Is it possible prevent copying of resources to build directory in Gradle project and directly use them from original location?

您可以在构建过程中排除某些文件。

build.gradle 文件:

sourceSets {
    main {
        resources {
            exclude '*.db-File'
        }
    }
}

Gradle 1.2: Exclude directory under resources sourceSets