相当于Gradle的Maven配置文件 [英] Maven profiles equivalent of Gradle
问题描述
我试图在我的spring引导项目构建中实现一个简单的场景:包括/排除依赖关系,并根据环境打包war或jar。例如,对于环境 package war等。 我知道这不是基于XML的配置,我基本上可以在我的build.gradle中编写if语句,但是在那里一个推荐的方式来实现这一点? 我可以声明一些常见的依赖关系并将它们引用到一个文件中,而不是创建多个构建文件吗? 是否有基于构建目标环境更改构建配置的最佳实践? I'm trying to achieve a simple scenario in my spring boot project build: including / excluding dependencies and packaging war or jar depending on the environment. So for example, for the environment I know it is not XML based configuration anymore and I can basically write if statements in my build.gradle but is there a recommended way of achieving this? Can I declare some common dependencies and refer them in a single file instead of creating multiple build files? Is there a best practice changing build configuration based on the build target environment?
这篇关于相当于Gradle的Maven配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! dev
包含devtools和包jar,对于生成的
$ b
ext {
devDependencies = ['org.foo:dep1:1.0','org.foo:dep2:1.0']
prodDependencies = ['org.foo:dep3:1.0 ','org.foo:dep4:1.0']
isProd = System.properties ['env'] =='prod'
isDev = System.properties ['env'] =='dev'
}
apply plugin:'java'
dependencies {
compile'org.foo: common:1.0'
if(isProd){
compile prodDependencies
}
if(isDev){
compile devDependencies
}
}
if(isDev)tasks.withType(War).all {it.enabled = false}
dev
include devtools and package jar, for prod
package war etc.ext {
devDependencies = ['org.foo:dep1:1.0', 'org.foo:dep2:1.0']
prodDependencies = ['org.foo:dep3:1.0', 'org.foo:dep4:1.0']
isProd = System.properties['env'] == 'prod'
isDev = System.properties['env'] == 'dev'
}
apply plugin: 'java'
dependencies {
compile 'org.foo:common:1.0'
if (isProd) {
compile prodDependencies
}
if (isDev) {
compile devDependencies
}
}
if (isDev) tasks.withType(War).all { it.enabled = false }