How to run a .jar file instrumented in windows using clover-ant in linux ?

Hi All,

I have instrumented a sample java program in windows, using clover-ant and was able to get the coverage info when running the .jar file using commandline.

Query : How to run an instrumented build in Linux.

Plan A : I tried using the same build which we instrumented in windows and tried runnning the same in linux environment by using the same clover.jar and same coverage.db file. (This didnt work out because the clover.jar path in windows cant be matched to any similar path in linux, similarly the same issue with initstring)

Plan B : Installed ant in the linux environment, copied the same java project in to linux machine, modified the build.xml to the expected paths of clover.jar present in the linux machine. When trying to run the .jar file I am seeing the below error :

/home/sv186037/Desktop/code_coverage/CloverInstrumentBuild/build/jar/CIB.jar: line 1: $'PK\003\004': command not found
/home/sv186037/Desktop/code_coverage/CloverInstrumentBuild/build/jar/CIB.jar: line 2: $'\bS#\261J': command not found
/home/sv186037/Desktop/code_coverage/CloverInstrumentBuild/build/jar/CIB.jar: line 3: syntax error near unexpected token `)'
/home/sv186037/Desktop/code_coverage/CloverInstrumentBuild/build/jar/CIB.jar: line 3:R#�J�C8�s�META-INF/MANIFEST.MFM�1�0
�H��Gb%����fb��X���T����� �����)�ٛhM%Ɂ���v�κ<�&�p���?��D��oW��pU`(���G0
�l�Ƶ˛bZ)\f0`�PK'

2 comments

General rule of thumb should be

  1.  Instrument code with Clover
  2. Compile instrumented code with making sure code clover.jar is in the classpath
  3. Move instrumented JAR along with Clover database to a second machine (it doesn't matter if you're moving it from Windows to Linux box or the opposite) 
  4. Execute tests on the target machine, make sure clover.jar is in the classpath and it's the same major.minor version as the one used for instrumentation
  5. Move coverage recording files back to the instrumentation machine
  6. Generate Clover report


NOTE: You can generate report on a different machine than you instrumented the sources, but Clover for rendering HTML report needs access to the source code. Java files shall be in the same location like when Clover was performing the instrumentation, however you can override the root location of the project by using sourcepath tag

I actually though of moving the same insturmented jar from windows to linux, but the paths mentioned in the build.xml will not be matchng the linux environment.

So I have instrumented a new one using new paths for clover.jar and coverage.db in linux machine.

To build a new instumented build in linux only clover.jar is enough or I need the total folder of clover-ant-4.1.2 ?

I tried with the complete folder of clover-ant-4.1.2 and build was successful, only thing is the coverege.db file is not getting created, even the .clover folder is also not getting created.

but the paths mentioned in the build.xml will not be matchng the linux environment.

You need to write proper path handling in the ANT project. You may use: 

  • relative paths instead of absolute ones
  • ANT's if-else conditions
  • or system properties to point ANT to the proper locations.

To build a new instumented build in linux only clover.jar is enough or I need the total folder of clover-ant-4.1.2 ?

Clover.jar will be sufficient. Clover-ant cotains API documentation, 3rd party libraries licenses and tutorial. The main part is clover.jar 

I tried with the complete folder of clover-ant-4.1.2 and build was successful, only thing is the coverege.db file is not getting created, even the .clover folder is also not getting created.

Without build logs and build file I can't really tell what's wrong. Also please note, there's no such thing like coverage.db. There's a Clover database which is generated during instrumentation phase, it contains infromation about your project structure and there're coverage recordings files which contains data about actual coverage. Those are created when instrumented code is executed and has access to Clover database. 

Hi Grzegorz,

Was able to instrument the same java code in linux by istalling ant, and modifying the paths of clover.jar and clover registry file in build.xml.

Even the coverage recording files are getting created as well.

Thanks,

Sagar.

I want to generate a clover report but that's possible only if I test my jars. How do I test my .jar files which have been instrumented by clover? 

I don't know how your tests configuration looks like.  But replace 'normal production' JAR with instrumented JAR on a classpath.

Comment

Log in or Sign up to comment
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted yesterday in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

51 views 2 2
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you