0

I'd like to check some flags in the code and some values in xml files before starting building a java project. What's the best way to do it? Would you write a java class to do it? Would you use only scripts?

I'm using Ant and I need to check that some flags that are set as static variable in my classes have the proper value. I can write unit test but in that case they would be executed after the build. I need to do it before it.

I should also add that I'm using Windows

4 Answers4

0

A lot of things are possible if you put your question so generic. What is your build environment? If you use Maven, you could write a Maven plugin for it (In Java or Groovy). If you use ant, maybe a groovy script and the Groovy Ant Task can help.

What are some of the things you want to check? Maybe tools like PMD, checkstyle or findbugs do what you need ?

Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211
  • yes I'm using Ant and I need to check that some flags that are set as static variable in my classes have the proper value –  Apr 12 '12 at 14:50
0

If values in your program are required to be consistent with values in an XML file, you're better off reading the values from the XML file in your program, rather than trying to keep them in sync and having to verify that they are in sync.

Christoffer Hammarström
  • 27,242
  • 4
  • 49
  • 58
  • No I do not need to keep them in sync they are two different checks. –  Apr 12 '12 at 15:15
  • OK, i see now. But surely you see what i mean. If there is another more authoritative source for the values, that the tests check against, make the program read from that source instead. – Christoffer Hammarström Apr 12 '12 at 15:23
0

This sort of thing would normally be handled by a unit test with the build broken if the tests failed.

henry
  • 5,923
  • 29
  • 46
0

You could use TeamCity and pre-tested commits. This will run the unit tests before generating the build artefacts on the build server.

Jeff Foster
  • 43,770
  • 11
  • 86
  • 103