Menu

[Ant] Changing *.ec destination

Ryan Lowe
2004-10-12
2013-05-09
  • Ryan Lowe

    Ryan Lowe - 2004-10-12

    I'm having some problems changing where my *.ec files are written to.  It's likely unique to the way I'm using Ant.

    I am using:
    Java: j2sdk1.4.2_04
    Eclipse 3.0.0
    Ant 1.6.1

    Unfortunately this is a proprietary app and I cannot post the Ant build.xml file.  Depending on what's needed to solve this problem, I could post additional snippets of it.

    I am building a single release out of several sub-projects which have depencies between them.  All of these sub-projects are built the same way (compile, instrument, test, test-report, coverage-report, jar) so I made a single central build script to do these simple tasks.

    Then each sub-project's build.xml file sets up a few properties and calls the central build file to do the work.  Incidentally, they also manage their dependencies by building other sub-projects with <ant> first and then using the JARs produced from those builds.  All of my EMMA targets are in this central build file.

    The build results are timestamped and placed in a directory with the following structure:

    builds\    20041012.1124\       [product name]
             [sub-project A]
                src-classes\             src-instrumented-classes\             test-classes\             test-results\             test-junit-results\             test-emma-results\             (etc...)
             [sub-project B]
                (etc...)

    The *.ec files are showing up in each project's working directory in Eclipse (default behaviour, since that is where the first Ant build file is, which is also Java's user.dir).

    [eclipse workspace dir]
       [sub-project A]
          src\       tests\       build.xml
          coverage.ec   <-- don't want this here

    But I want them to go into the proper test-emma-results\ directory in the builds\ results hierarchy above, since they are *results*.  :)

    I looked in the manual for how to change this, and none of the options seem to suit my needs, since the destination directory is specified at Ant runtime (and is dependent on the timestamp of the build), except the <property> option.  But I can't seem to get the <property> option to change the destination of *.ec files.

    I've added the property

    <property name="coverage.out.file" value="${tests.emma.dir}/coverage.ec"/>

    nested inside the <instr> tag, as well as the <emma> tag that surrounds <instr>.  Neither change the destination of the *.ec file outputted during the test run.  I've also added the property to the top of the build file inside no target, and that didn't work either.  Every time the *.ec file shows up in the project's workspace directory.

    I assumed that since the *.ec file is generated during the test run that instrumentation is the only place to specify this property.  I could very well be making an error here -- I have to admit I'm still getting used to EMMA.

    Thanks in advance for any suggestions you have,

    Ryan Lowe

     
    • Ryan Lowe

      Ryan Lowe - 2004-10-12

      It's unfortunate that this forum strips spaces -- my directory hierarchies in the previous post don't make much sense without them.  I'll try it again with tabs.  Apologies if this doesn't work.

      builds\     20041012.1124\         [product name]
                  [sub-project A]
                      src-classes\                 src-instrumented-classes\                 test-classes\                 test-results\                 test-junit-results\                 test-emma-results\                 (etc...)
                  [sub-project B]
                      (etc...)

       
    • Ryan Lowe

      Ryan Lowe - 2004-10-12

      Here's the long hand way.  They really aught to have preview on this forum.  Sorry about the extra messages.

      builds\ builds\20041012.1124\ builds\20041012.1124\[product name]
      builds\20041012.1124\[product name]\[sub-project A]
      builds\20041012.1124\[product name]\[sub-project A]\src-classes\ builds\20041012.1124\[product name]\[sub-project A]\src-instrumented-classes\ builds\20041012.1124\[product name]\[sub-project A]\test-classes\ builds\20041012.1124\[product name]\[sub-project A]\test-results\ builds\20041012.1124\[product name]\[sub-project A]\test-junit-results\ builds\20041012.1124\[product name]\[sub-project A]\test-emma-results\ builds\20041012.1124\[product name]\[sub-project A]\(etc...)
      builds\20041012.1124\[product name]\[sub-project B]
      builds\20041012.1124\[product name]\[sub-project B](etc...)

       
    • Vlad Roubtsov

      Vlad Roubtsov - 2004-10-12

      I will respond in more detail later today if necessary, but for now I wanted to give you a couple of quick hints:

      (a) the coverage is collected at *runtime*. The decision on where the *.ec file will be located is also made at *runtime*. Attempting to set coverage.out.file property for <instr> will have no effect (<instr> outputs *.em files only). The property summary section in the reference (http://emma.sourceforge.net/reference/ch03s02.html) details which properties have effect on which tools.

      (b) the default location for *.ec file is the value of your JVM's user.dir property (http://emma.sourceforge.net/faq.html#faq-N10414). I don't know how Eclipse sets it when it runs ANT itself.

      One easy way to override this location is to add a -Demma.coverage.out.file JVM property. I assume there is a way to do this from Eclipse.

      [A a side comment, I really recommend not running ANT builds from IDEs. The best build is a reproducible build and the best way to accomplish this is to run ANT from command line.]

       
    • Ryan Lowe

      Ryan Lowe - 2004-10-12

      Hi Vlad, thanks for the quick response.

      I've got the solution now, with your help.

      To get coverage data I'm running a test suite: <junit> Ant task.  This task has a <jvmarg> nested tag to pass arguments to the JVM that runs the tests.  Mine now looks like:

      <junit fork="yes" printsummary="false">
      <jvmarg value="-Demma.coverage.out.file=${coverage.out.file}"/>
      ...
      </junit>

      where ${coverage.out.file} is in the timestamped build directory and is different for each sub-project.

      Thanks again,

      Ryan Lowe

       

Log in to post a comment.