Generate TODO list from java source code


Is it possible to generate and display list of TODO (or similiar tags) from source code in the TC ?


Comment actions Permalink

This can be easily done by IDE (for example, IntelliJ IDEA can show you such list). Why do you need this feature in TeamCity?

Comment actions Permalink

well, it is always good to have some information to be centrally available.

Also, the same functionality could also be used to display @Ignored junit test cases.


Comment actions Permalink

I am also looking for similar functionality. I love how ReSharper will produce the TODO list for me. But I would like it to be part of our integration build server. I'd like it to be part of the final report that gets put with my artifiacts. Similar to the Code Coverage stuff. I'd like to be able to know easily without opening up Visual Studio how many TODO's are part of the project.

I'm looking for it to work with a .NET project instead of java source. But I'm curious if this was ever implemented since the thread seems to have died.

Comment actions Permalink

You'll need to generate such report by external tools - grep or more sophisticated engine.
Thenit can be displayed right on a build page.


Comment actions Permalink

I've just undergone the journey to make this happen, so here are my notes:

(Before I go any further, JetBrains, I would love to see this incorporated by default. Very useful metric.)

You need a process that will pull out the TODO's and generate two things. You need to record a statistic with the total count. That can easily be done by creating a teamcity-info.xml file (docs) as part of your build. Then I wanted a listing of each TODO, which is done via a custom report tab (doc).

So, first step is to write a small app/script to parse your code and spit out the two files. For your coding pleasure, I have done this for you in the StarLight Common project on SourceForge. The class you really need is and you are free to pull and use that class (the project is BSD licensed, so do what you will). This app takes 3+ args:

  1. regex pattern (eg: "\btodo\b.*" )
  2. output dir
  3. search dirs (1+)

Note: the output is a bit rough as of this writing (8/17/11), but I'll try to make it prettier Very Soon Now (TM).

I then call then via an ant script. Mine looks like this:

     <target name="todo_report">
     <java classname=""
          args="\btodo\b.* ${basedir} ${src} ${test}">
                         <classpath refid="project.class.path"/>

Obviously, make sure the StarLight Common jar (or wherever your TCFileRegexCounter binary is) is in your classpath, but that's all you need.

This will spit out two files: "teamcity-info.xml" and "todo_list.html". I put those both in the base dir for  the build.

Now, TC will process the "teamcity-info.xml" file automatically, but you need to tell it to pick up the "todo_list.html" file. So, just add that to your project artifacts.

To include the list, you just need to add a custom report tab (docs).
  1. Go to: Administration > Server Configuration > Report Tabs
  2. Click "Create new report tab"
  3. Enter (without quotes): Tab Title: "TODO's"  Base Path: "/"  Start Page: "todo_list.html"

Finally, you need to tell TC to make a custom chart (doc) using the statistic added via the "teamcity-info.xml" file. I did this using the "main-config.xml" file so I wouldn't have to deal with individual projects. To do that, find your data directory and edit "config/main-config.xml". I added this to mine:

<?xml version="1.0" encoding="UTF-8"?>
<server rootURL="">
  <!-- Exisiting stuff -->

  <!-- Custom chart for TODO's -->
  <graph title="TODO's" seriesTitle="Count" hideFilters="series">
    <valueType key="todoCount" title="Count"/>

When that's done, run a build and you should have a "TODO's" tab for the build and a chart labeled with the same name in the Statistics.

Comment actions Permalink

Hi Robert

Thank you for detailed description!

I have questions to better understand the use case, and a business need behind it. ReSharper allows to export the list into a file. Why do you need to generate it continuously in every build? Do you use a bug tracker in your project, what's the role of TODOs then? You said it's a metric - do you count a number of items? What kind of decisions could be made if, for example, a number is increasing over time?


Please sign in to leave a comment.