简体   繁体   中英

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?

IE:

switch(profileName){ 

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

etc?

That's beyond Maven's capabilities. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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