简体   繁体   English

使用Maven配置文件选择的Java Switch

[英]Java Switch using Maven Profile Selection

Is there a way to grab a project's maven profile that was used to compile it to use as an argument in the code as part of an if/else or switch conditional in java code? 有没有一种方法可以获取项目的Maven概要文件,该概要文件用于将其编译为代码中的参数,作为if / else或在Java代码中切换条件的一部分?

IE: IE:

switch(profileName){ 

"profile1": do this
"profile2": do that
 default: something else
}

etc? 等等?

That's beyond Maven's capabilities. 这超出了Maven的能力。 An alternative would be to define multiple profiles that will define your plugins and lifecycles. 一种替代方法是定义多个配置文件,这些配置文件将定义您的插件和生命周期。

Alternatively if you want to go the scripting route and be able to handle dynamic data in your build system then you could use Gradle 另外,如果您想走脚本路线并能够处理构建系统中的动态数据,则可以使用Gradle

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

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