It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is source code location hardcode in clover registry file?

Kai Hu Jan 14, 2014

I'm now facing some problem with maven clover plugin, I have 2 separate maven projects: one from DEV and one from QA, and they are executed on different hosts, details:

host1: a Windows host where I instrument DEV's source code and build project(DEV's maven project)

<plugin>
	<groupId>com.atlassian.maven.plugins</groupId>
	<artifactId>maven-clover2-plugin</artifactId>
	<version>${clover.version}</version>
	<configuration>
		<license>xxx</license>
		<singleCloverDatabase>true</singleCloverDatabase>
		<cloverDatabase>${project.home.dir}/clover.db</cloverDatabase>
		<includesTestSourceRoots>false</includesTestSourceRoots>
		<excludes>xxx</excludes>
	</configuration>
</plugin>

host2: a Linux host where I run integration tests and generate report(QA's maven project)

<plugin>
	<groupId>com.atlassian.maven.plugins</groupId>
	<artifactId>maven-clover2-plugin</artifactId>
	<version>${clover.version}</version>
	<configuration>
		<license>xxx</license>
		<contextFilters>logger, iflogger, log, iflog</contextFilters>
		<generateXml>true</generateXml>
		<generateHtml>true</generateHtml>
		<cloverDatabase>../DEV/clover.db</cloverDatabase>
		<outputDirectory>target/surefire-reports/clover</outputDirectory>
	</configuration>
	<executions>
		<execution>
			<id>site</id>
			<phase>pre-site</phase>
			<goals>
				<goal>clover</goal>
				<goal>save-history</goal>
			</goals>
		</execution>
	</executions>
</plugin>

The problem is:

After I copy the build file with instrumented classes and clover database from host1 to host2, then I execute test and generate clover report on host2 by executing command: mvn test clover2:clover, following error return, D:/perforce/depot/..../example.java is the location on host1 where source code place.

[ERROR] Failed to render syntax highlights for /app/QA/D:/perforce/depot/..../example.java: D:/perforce/depot/..../example.java (No such file or directory)
java.io.FileNotFoundException: D:/perforce/depot/..../example.java (No such file or directory)java.io.FileNotFoundException: D:/perforce/depot/Solutions/EAS/eas/Main/core/eas-service/src/main/java/com/emc/documentum/eas/service/order/EnumerateOrdersService.java (No such file or directory)

I'm wondering is there any solution can resolve my problem?

4 answers

1 vote
Kai Hu Jan 19, 2014

Anyone who meet the same problem, please go https://jira.atlassian.com/browse/CLOV-1415for the solution.

0 votes
Kai Hu Jan 14, 2014

I'm using Clover 3.1.10, the problem I'm facing now is exactly match what described in CLOV-1112, instrument on Windows and generate report on linux, db file record each source file's absolute path, which resulting win-linux paths like:

[ERROR] Failed to render syntax highlights for /app/QA/D:/perforce/depot/..../example.java

As you mentioned CLOV-1112 is mark as resloved in 3.1.7, but now seems it's still reproducible in 3.1.10.

BTW, I'm using clover maven plugin, details please check my post:

https://answers.atlassian.com/questions/251117/is-source-code-location-hardcode-in-clover-registry-file,

Thanks,

Kai

0 votes
Marek Parfianowicz Atlassian Team Jan 19, 2014

A problem is indeed similar to CLOV-1112, but it's not caused by a bug in later Clover versions, but by a fact that the Maven clover2:clover goal does not pass the "sourcepath" property to the report task. Unfortunately, there's no "sourcepath" configuration option for the clover2:clover goal.

Issue report:

An improvement for it is reported here: https://jira.atlassian.com/browse/CLOV-1415.

Workaround:

Use a custom report configuration:

1. Define the clover2:clover reportDescriptor tag in pom.xml, pointing to a file with a custom report configuration.

2. Define a custom report configuration as per Creating+custom+reports guideline. You can use any of the options available for <clover-report> task in it.

3. In this custom report configuration define the <sourcepath> element for the <clover-report> tasks defined in "current" and "historical" targets.

0 votes
Bhuvi Sundararaman Apr 27, 2014

Hello,

Im trying to use command line tool to generate report as below:

java -Dclover.license.path=../resources/clover.license -classpath ../lib/clover-3.2.1.jar com.atlassian.clover.reporters.html.HtmlReporter -p ../lib -i clover-proj.db -o clover_html

But am getting these errors:

ERROR: Failed to render syntax highlights for <myserver/path/to/myclass.java>: <myserver/path/to/myclass.java>: (No such file or directory)

Looks like the path for java files is hardcoded ...I tried using "-p" option to point to location where the source code jars are present, but that doesn't work. We cannot generate report on server (where src code is present) ..is there a way to get the syntax highlighting working in this case?

Marek Parfianowicz Atlassian Team Apr 28, 2014

I tried using "-p" option to point to location where the source code jars are present

Please do not use JARs. Clover does not read sources from archives.

Instead of this, please point to a directory containing source files.

Bhuvi Sundararaman Apr 28, 2014

The team generating the report, have access only to

1. clover.db

2. coverage files

3. clover-3.2.1.jar and

4. clover.license.

They do not have source code in their environment.. what do we do now?

Marek Parfianowicz Atlassian Team Apr 28, 2014

Use HtmlReporter with the '--hidesrc' option - it will not render source pages.

Bhuvi Sundararaman Apr 29, 2014

I was looking for source highlighting (which lines were hit and which did not), but I guess there is no way to do without access to source files. Anyways, thanks for the help.

Marek Parfianowicz Atlassian Team Apr 29, 2014
Indeed. It would be hard to imagine how this could work without sources. Line numbers only? Rather impractical...
Bhuvi Sundararaman Jun 09, 2014

We tried giving the path to the .java source files using "-p" option . But report generation still looks for the files in the build path. For example:

While intrumenting if the files were at a/b/file.java. Generate report with '-p x/y/file.java'. But it fails saying cannot find '/a/b/file.java/' ..How do we overrite this?

Marek Parfianowicz Atlassian Team Jun 09, 2014

Generate report with '-p x/y/file.java'

You should not point to a source file, but to a root directory (or directories). For example, if during instrumentation sources were present in directories:

/build/projectA/src/main/java

/build/projectA/src/test/java

(e.g. /build/projectA/src/main/java/com/acme/A.java)

and during report generation these sources are in:

/reporting/projectA/src/main/java

/reporting/projectA/src/test/java

then you shall use:

HtmlReporter -p "/reporting/projectA/src/main/java:/reporting/projectA/src/test/java" ...

Note: use ":" for Linux and ";" for Windows.

Bhuvi Sundararaman Jun 09, 2014

I checked again and found that I used only paths and not exact file names.

Why is it still looking for sources in build path?

Marek Parfianowicz Atlassian Team Jun 10, 2014

If Clover uses the original build path, then it means that it doesn't see sources under a path(s) provided by you. Are you sure that you're using correct source roots?

You can run Clover with debug logging (ant -d / mvn -X / HtmlReporter -d) and look for messages like:

"looking for /com/acme/MyClass.java (FOUND|not found)"

"/com/acme/MyClass.java not found on path"

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Opsgenie

Handling Opsgenie Alerts

Hi everyone, welcome to the kb articles for Opsgenie FAQs. I'm one of the Technical Support Engineers for Opsgenie who will be providing weekly posts on FAQs from customers.   All alerts are ...

72 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you