Conditionally including Java files based on Visual Studio build config

Is there a good way to specify which .java files to compile as part of the build based on the build config? We need this so we can include different java code for the Google Play, Amazon, Ouya etc versions of our apps. We also need to include different 3rd party libraries for different versions e.g Flurry is needed for some configs and not others.

It doesn’t seem possible to specify a different build.xml for each config. If it was I could probably get that to do it.

I also tried including multiple different paths in the “Java source directory” option of the Ant Build property window, but only the last one gets used.

We have this working with plain old vs-android using multiple targets in build.xml and choosing the target in the “Ant build type” property.

		  description="Builds the application, including the Google Play API files, and signs it with the debug key.">

If we do this with NSight Tegra, it gives the error “Target “googleplay_debug” does not exist in the project “Android1”.”
That follows a build warning “Duplicated project name in import. Project Android1 defined first in C:\temp\Android1\Tegra-Android\Debug\nsight_tegra_build.xml and again in C:\temp\Android1\build.xml” which might account for it not working.

I’d love to get our projects building properly with NSight Tegra as it seems a really nice integration! Any help appreciated.

Hello Mike,

nsight_tegra_build.xml imports two files if they exist: nsight_tegra_build_overrides.xml and nsight_tegra_build_overrides_.xml, where is either debug or release, depending on your actual VS configuration. These files must be located next to the build.xml file and are used to override any of the things we are setting in the nsight_tegra_build.xml. Will this mechanism suffice for implementing the desirable build process in your case?

Also please ignore the warning about the duplicate project name, it’s a small drawback of the current build system implementation and should not affect the build process at all.

Hi Dmitry,

Do you mean these lines:

<import file="C:\code\MyProject\AndroidApk\nsight_tegra_build_overrides_release.xml" optional="true" />
  <import file="C:\code\MyProject\AndroidApk\nsight_tegra_build_overrides.xml" optional="true" />

These are generated for our “GooglePlay_Debug” configuration. We don’t just have “Debug” and “Release” configs, so I don’t think these overrides files will work - we need more flexibility than that as we have at least 9 different VS build configs.

Would it help to send you a test project exhibiting the problem with the “target does not exist” error? That’s the way we used to do it with vs-android.

Yes, that’d help. I’ll email you the instructions on how to do that.

Can you post the instructions here? I want to do the same (and have it working for some time in vsandroid)

You can refer to