I like the way Android Studio integrates with Gradle to let you create different build configurations (flavors). Effectively, you can have a class duplicated using the same package name but where the root package is located under a folder that corresponds to a build flavor. For example, if I have a Production flavor and a Development flavor I could have folders like this:
Production Flavor: app > src > production > java > com > mycompany > file.java
Development Flavor: app > src > development > java > com > mycompany > file.java
Android Studio handles this nicely within the IDE and lets you easily select which flavor to build and will compile your code from those sources that correspond to the selected flavor.
I'm using IntelliJ for doing web development but IntelliJ doesn't have the same kind of support for Gradle the way Android Studio does. I don't have a problem executing Gradle tasks manually if I have to.
Has anyone used Gradle to manage web development in a way that lets you build variants (flavors)? Maybe there is a Gradle plugin specifically for this? If not, I suppose I could write my own.