从 Grails 3 中的 WAR 打包中排除 files/directories
Excluding files/directories from WAR packaging in Grails 3
在我的 Grails 3.1.10 应用程序中,我在 src/main/webapp/ng
目录中有一些文件用于 Angular 应用程序,我想从打包到WAR 文件在 grails package
命令时。
在 Grails 2.x 应用程序中,我们通过 BuildConfig.groovy
设置实现了它:
grails.war.resources = { stagingDir, args ->
delete(dir: "${stagingDir}/ng/node_modules")
delete(dir: "${stagingDir}/ng/app")
delete(dir: "${stagingDir}/ng/bower_components")
}
我们如何在 Grails 3 中实现这一点?我试着搜索它,但没有找到任何东西。
后来我意识到 Grails 3 使用 Gradle 而 Grails 2 使用 Ant 任务。所以我在 Gradle 中搜索了排除内容的相同问题,因为 Grails 3 使用 Gradle 的 WAR plugin 并且来自文档:
Of course one can configure the different file-sets with a closure to
define excludes and includes.
这是从打包中排除 Grails 3 中的文件的解决方案。
将以下内容放入 Grails 3 应用程序的 build.gradle
文件中:
war {
exclude("ng/node_modules")
exclude("ng/bower_components")
exclude("ng/app")
exclude("ng/*.tar.gz")
exclude("ng/.*") // For example: exclude all the hidden files
}
在我的 Grails 3.1.10 应用程序中,我在 src/main/webapp/ng
目录中有一些文件用于 Angular 应用程序,我想从打包到WAR 文件在 grails package
命令时。
在 Grails 2.x 应用程序中,我们通过 BuildConfig.groovy
设置实现了它:
grails.war.resources = { stagingDir, args ->
delete(dir: "${stagingDir}/ng/node_modules")
delete(dir: "${stagingDir}/ng/app")
delete(dir: "${stagingDir}/ng/bower_components")
}
我们如何在 Grails 3 中实现这一点?我试着搜索它,但没有找到任何东西。
后来我意识到 Grails 3 使用 Gradle 而 Grails 2 使用 Ant 任务。所以我在 Gradle 中搜索了排除内容的相同问题,因为 Grails 3 使用 Gradle 的 WAR plugin 并且来自文档:
Of course one can configure the different file-sets with a closure to define excludes and includes.
这是从打包中排除 Grails 3 中的文件的解决方案。
将以下内容放入 Grails 3 应用程序的 build.gradle
文件中:
war {
exclude("ng/node_modules")
exclude("ng/bower_components")
exclude("ng/app")
exclude("ng/*.tar.gz")
exclude("ng/.*") // For example: exclude all the hidden files
}