Android using Gradle Build flavors in the code like an if case

BuildConfig.FLAVOR gives you combined product flavor. So if you have only one flavor dimension: productFlavors { normal { } admin { } } Then you can just check it: if (BuildConfig.FLAVOR.equals(“admin”)) { … } But if you have multiple flavor dimensions: flavorDimensions “access”, “color” productFlavors { normal { dimension “access” } admin { dimension “access” … Read more

Copy all files and folders using msbuild

I was searching help on this too. It took me a while, but here is what I did that worked really well. <Target Name=”AfterBuild”> <ItemGroup> <ANTLR Include=”..\Data\antlrcs\**\*.*” /> </ItemGroup> <Copy SourceFiles=”@(ANTLR)” DestinationFolder=”$(TargetDir)\%(RecursiveDir)” SkipUnchangedFiles=”true” /> </Target> This recursively copied the contents of the folder named antlrcs to the $(TargetDir).

C++ Build Systems – What to use? [closed]

+1 for, “Many, and they’re awful.” But, the “richest” and “most-scalable” is probably CMake, which is a Makefile-generator (also generates native MSVC++ *.proj/*.sln). Weird syntax, but once you learn it, it can allow you to nicely generate builds for different platforms. If I “started-fresh”, I’d probably use CMake. It should handle your list, although your … Read more

Go build: “Cannot find package” (even though GOPATH is set)

It does not work because your foobar.go source file is not in a directory called foobar. go build and go install try to match directories, not source files. Set $GOPATH to a valid directory, e.g. export GOPATH=”$HOME/go” Move foobar.go to $GOPATH/src/foobar/foobar.go and building should work just fine. Additional recommended steps: Add $GOPATH/bin to your $PATH … Read more

Recommended way to stop a Gradle build

I usually throw the relevant exception from the org.gradle.api package, for example InvalidUserDataException for when someone has entered something invalid, or GradleScriptException for more general errors. If you want to stop the current task or action, and move on to the next, you can also throw a StopActionException

WARNING in budgets, maximum exceeded for initial

Open angular.json file and find budgets keyword. It should look like: “budgets”: [ { “type”: “initial”, “maximumWarning”: “2mb”, “maximumError”: “5mb” } ] As you’ve probably guessed you can increase the maximumWarning value to prevent this warning, i.e.: “budgets”: [ { “type”: “initial”, “maximumWarning”: “4mb”, <=== “maximumError”: “5mb” } ] What does budgets mean? A performance … Read more

How do I build a solution programmatically in C#?

See .NET 4.0 MSBuild API introduction for an example using the .NET 4.0 MSBuild API: List<ILogger> loggers = new List<ILogger>(); loggers.Add(new ConsoleLogger()); var projectCollection = new ProjectCollection(); projectCollection.RegisterLoggers(loggers); var project = projectCollection.LoadProject(buildFileUri); // Needs a reference to System.Xml try { project.Build(); } finally { projectCollection.UnregisterAllLoggers(); } A simpler example: var project = new Project(buildFileUri, null, … Read more

setup_requires with Cython?

Starting from 18.0 release of setuptools (released on 2015-06-23) it is possible to specify Cython in setup_requires and pass *.pyx modules sources for regular setuptools.Extension: from setuptools import setup, Extension setup( # … setup_requires=[ # Setuptools 18.0 properly handles Cython extensions. ‘setuptools>=18.0’, ‘cython’, ], ext_modules=[ Extension( ‘mylib’, sources=[‘src/mylib.pyx’], ), ], )