views:

217

answers:

3

I'm having trouble getting my cruisecontrol script to do something. I want to call grep on the files in my project to search for a few preprocessor defines, and place them into a list, which I can use later. This snippet works fine when I toss it into an ant buildfile, but returns an error when used in cruisecontrol...

<target name="generate_list">
  <echo>calling grep</echo>
  <exec dir="${basedir}/src/" executable="grep" failonerror="true">
    <arg line="-R --include=*.{cpp,h} -l -P &quot;ARG1|ARG2|ARG3&quot; . &gt; touchlist" />
  </exec>
  <echo>contents of touchlist is</echo>
  <exec dir="${basedir}/src/" executable="cat" failonerror="true">
    <arg line="touchlist" />
  </exec>
</target>

the error returned is

<stacktrace>
  /opt/cruisecontrol-2.8.1/build-foo.xml:195: exec returned: 1
    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:636)
    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:662)
    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:487)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.Target.performTasks(Target.java:385)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    at org.apache.tools.ant.Main.runBuild(Main.java:698)
    at org.apache.tools.ant.Main.startAnt(Main.java:199)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
</stacktrace>

I'm at a total loss here. I don't even know how I can debug this one, aside from changing things incrementally and seeing what happens.

+1  A: 

I would suggest you extracting the command line to a separate shell script, so that you would call the script only and let the script call grep instead.

Grzegorz Oledzki
A: 

Another idea (after googling) would be to avoid using <arg line.... Replace it with multiple <arg value... definitions.

Grzegorz Oledzki
A: 

Maybe it´s different basedirs.

Place a <echoproperties/>in the first line of your target and compare the output for basedir form the ant-run and the cruisecontrol run.

CodeSeavers