2

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.

Johann
  • 27,536
  • 39
  • 165
  • 279
  • IntelliJ has the exact same support for Gradle. That plugin is the same between it and Android Studio. – OneCricketeer Feb 03 '17 at 22:57
  • But the Android plugin is designed to manage the build for Android apps, meaning that its tasks are not compatible with a Java web-based app. – Johann Feb 04 '17 at 12:42
  • That's a Gradle configuration, not IDE related. https://docs.gradle.org/current/userguide/tutorial_java_projects.html – OneCricketeer Feb 04 '17 at 15:36
  • 1
    That's precisely what I mean. The gradle tasks for the Android plugin are specific to Android apps. You cannot use them for normal web-based java apps. The support for flavors is part of the Android plugin and not the IDE. Having the support for flavors but for a web based app under Java would be great too. – Johann Feb 04 '17 at 21:17
  • 1
    Not sure if you can see the deleted answer, but here's the link for Java flavors https://github.com/uklance/gradle-java-flavours – OneCricketeer Feb 04 '17 at 21:19
  • That isn't the standard java plugin. That is one developed by a third party guy: com.lazan.javaflavours – Johann Feb 05 '17 at 00:30
  • It answers your question... *Maybe there is a Gradle plugin specifically for this*, you `apply plugin` with it just like the regular `java` plugin, and you have the features mentioned – OneCricketeer Feb 05 '17 at 06:05

0 Answers0