views:

155

answers:

2

Hi all, basic reason to put the comparison question between these 2 is I am able to generate the reports in site directory(for cobertura) after putting the following plug in information in build section of my pom. But same would not happening with emma. I checked documentation in codehause mojo its almost same for both. My configuration is :

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>emma-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>emma</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

but it dont generate reports as expected in site directory but I can see coverage.em generated and classes instrumented every time. am I missing any configuration ?

+1  A: 

I can't reproduce your problem. I copied and pasted your configuration snippet into a random pom.xml and running any phase posterior to process-classes triggers emma:emma and the coverage report is generated as expected:

$ mvn clean process-classes
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Project
[INFO]    task-segment: [clean, process-classes]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory /home/pascal/tmp/test-project/target
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to /home/pascal/tmp/test-project/target/classes
[INFO] Preparing emma:emma

...

EMMA: runtime coverage data merged into [/home/pascal/tmp/test-project/coverage.ec] {in 93 ms}
[INFO] [emma:emma {execution: default}]
processing input files ...
2 file(s) read and merged in 3 ms
writing [xml] report to [/home/pascal/tmp/test-project/target/site/emma/coverage.xml] ...
writing [html] report to [/home/pascal/tmp/test-project/target/site/emma/index.html] ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

Do you have unit tests in your project? Is the coverage.em file non empty? What happens if you run emma:emma on the command line? Does running mvn with the -X option give you any hint? Can you post some traces that would be helpful?

As a side note, I wouldn't run emma:emma as part of the regular build personally. I would either run the emma:emma goal from the command line or configure the plugin and the reporting section as suggested in the Usage page. But that's another story and doesn't answer the question.

Pascal Thivent
hey Pascal thanks much for your interest. yes I do have unit tests and coverage.em is not empty. See below what I was missing.
RN
but still looking at your trace its strange behavior. The things I noticed are, one is output directory but you are saying you just copy pasted my code and another is I am running 'clean install'. Don't no whats the matter.
RN
@RN Yes, I used the snippet "as is". I just tested with `mvn clean install` and I get the same result. Does your pom inherit from another one (mine doesn't).
Pascal Thivent
@Pascal, it inherits from parent project.
RN
A: 

this is really strange: corrected plugin entry is : see the output directory

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>emma-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <inherited>true</inherited>
            <executions>
                <execution>
                    <id>emma</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>emma</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <outputDirectory>${basedir}/target</outputDirectory>
            </configuration>
        </plugin>

emma even does not accept ${basedir}/target/emma.

conclusion : emma not generated reports when you add any sub-directory to ${project.build.directory} e.g. ${project.build.directory}/emma-reports.

RN
${basedir} is deprecated, use ${project.basedir} and ${basedir}/target was always bad, use ${project.build.directory} (and ${project.build.outputDirectory} for target/classes)
seanizer
thanks seanizer
RN