0

We are using Jenkins to make our builds. We would like to switch boolean value in release build. Is it possible? Maybe it's better option to do this?

In C you could just define a value by passing -D and you call gcc -DUSE_ASD=1 asd.c

#ifdef USE_ASD
int debug = 0;
#else
int debug = 1;
#endif 
pixel
  • 24,905
  • 36
  • 149
  • 251

3 Answers3

0

This is not a problem anymore. With update of Android platform tools this type of flag was added.

pixel
  • 24,905
  • 36
  • 149
  • 251
0

You don't generally do this sort of thing in Java. You would more usually do something like establish a system property to control debug state.

static final boolean DEBUG = !Boolean.valueOf(System.getProperty("use.asd"));

And then set it on the command line when running Jenkins; I don't know the details of how to edit Jenkins's runtime but it amounts to adding -Duse.asd=true to the java command.

Sean Owen
  • 66,182
  • 23
  • 141
  • 173
  • But in Java You pass it runtime whereas in C it is set during compile time. Additionally we can't pass those arguments to JVM since we are using Dalvik VM and Android application package file (APK). – pixel Nov 18 '11 at 10:41
  • Yeah that's indeed a difference. There isn't a preprocessor in Java, really. You could use an Ant task to copy a template .java file, replacing some token with a true or false, and then compile -- faking a preprocessor with an Ant copy task? – Sean Owen Nov 18 '11 at 11:09
0

In Java, you can ask the compiler to generate debug tables using the -g option. For a release you might actually want a -g:none. This can be controlled either -

mithun
  • 316
  • 3
  • 3