Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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?

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

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

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

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.

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?

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.

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?

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

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.

Indeed. It would be hard to imagine how this could work without sources. Line numbers only? Rather impractical...

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?

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.

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?

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
TAGS
Community showcase
Published in Jira

Jira Cloud Performance Improvements

Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...

146 views 1 8
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