Hi Ankit,

have a look in the error message:

> Caused by: java.io.IOException: Can't create directory 
> C:\Hybris\CX1905PL13\hybris\bin\platform\site\jacoco \jacoco-resources.

Do you notice the suspicious blank in the path? Probably that’s why the folder 
cannot be created.

Now look at your code:

> <property name="result.report.dir" location="${result.dir}/site/jacoco        
> "/>


Maybe remove that extra blanks in the location attribute?

Please understand that we cannot provide general development support here. You 
better find someone in your organisation who can help you with Ant build basics.

Thanks for your understanding,
-marc



> On 3. Feb 2022, at 17:23, ankit daruka <ankit.dar...@gmail.com> wrote:
> 
> Hi Marc,
> 
> I analyzed the documentation and corrected my build.xml. But, I am still 
> getting the below error. Can you please check and let me know what am I doing 
> wrong here.
> 
> Build.xml file snippet:
> 
> <project name="jacoco_rpt_pim" xmlns:jacoco="antlib:org.jacoco.ant">
>         <property name="platformhome" location="."/>
>         <property name="src.dir" location="./../custom/bestprice"/>
> <property name="result.dir" location="."/>
> <property name="result.classes.dir" location="${result.dir}/classes"/>
> <property name="result.report.dir" location="${result.dir}/site/jacoco        
> "/>
> <property name="result.exec.file" location="${result.dir}/jacoco.exec"/>
>     <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
> <classpath path="${platformhome}/lib/jacocoant.jar"/>
> </taskdef>
>         <target name="jacocoalltests" description="run jacoco">    
>                 <ant dir="${platformhome}" target="unittests" 
> inheritrefs="false">
>                         <property name="testclasses.suppress.junit.tenant" 
> value="true"/>
>                         <property name="standalone.javaoptions" 
> value="-javaagent:${platformhome}/lib/jacocoagent.jar=destfile=jacoco.exec,append=false,excludes=com.google.*:com.sun.*:de.hybris.platform.*"
>  />                </ant>
>         </target>
>     
> <target name="report" depends="jacocoalltests">
> <!--  Step 3: Create coverage report  -->
> <jacoco:report>
> <!--  This task needs the collected execution data and ...  -->
> <executiondata>
> <file file="${result.exec.file}"/>
> </executiondata>
> <!--  the class files and optional source files ...  -->
> <structure name="JaCoCo Ant Example">
> <classfiles>
> <fileset dir="${result.classes.dir}"/>
> </classfiles>
> <sourcefiles encoding="UTF-8">
> <fileset dir="${src.dir}"/>
> </sourcefiles>
> </structure>
> <!--  to produce reports in different formats.  -->
> <html destdir="${result.report.dir}"/>
> <csv destfile="${result.report.dir}/report.csv"/>
> <xml destfile="${result.report.dir}/report.xml"/>
> </jacoco:report>
> </target>
> <target name="rebuild" depends="clean,compile,test,report"/>
> </project>
> 
> Command: ant  -buildfile build.xml report 
> -Dtestclasses.extensions=${unitTetsExtensions}
> 
> Error msg:
>      [echo] Report generated to 
> C:\Hybris\CX1905PL13\hybris\log/junit/index.html
>      [echo] JUNITTESTS FAILED. See 
> C:\Hybris\CX1905PL13\hybris\log/junit/index.html!
>       [ant] Exiting C:\Hybris\CX1905PL13\hybris\bin\platform\build.xml.
> 
> report:
> [antlib:org.jacoco.ant] Could not load definitions from resource 
> org/jacoco/ant/antlib.xml. It could not be found.
> [jacoco:report] Loading execution data file 
> C:\Hybris\CX1905PL13\hybris\bin\platform\jacoco.exec
> 
> BUILD FAILED
> C:\Hybris\CX1905PL13\hybris\bin\platform\jacoco.xml:40: Error while creating 
> report
>         at org.jacoco.ant.ReportTask.execute(ReportTask.java:502)
>         at 
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
>         at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown 
> Source)
>         at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>         at 
> org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
>         at org.apache.tools.ant.Task.perform(Task.java:350)
>         at org.apache.tools.ant.Target.execute(Target.java:449)
>         at org.apache.tools.ant.Target.performTasks(Target.java:470)
>         at 
> org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
>         at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
>         at 
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>         at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
>         at org.apache.tools.ant.Main.runBuild(Main.java:834)
>         at org.apache.tools.ant.Main.startAnt(Main.java:223)
>         at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
>         at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
> Caused by: java.io.IOException: Can't create directory 
> C:\Hybris\CX1905PL13\hybris\bin\platform\site\jacoco \jacoco-resources.
>         at 
> org.jacoco.report.FileMultiReportOutput.createFile(FileMultiReportOutput.java:46)
>         at 
> org.jacoco.report.internal.ReportOutputFolder.createFile(ReportOutputFolder.java:92)
>         at 
> org.jacoco.report.internal.html.resources.Resources.copyResource(Resources.java:127)
>         at 
> org.jacoco.report.internal.html.resources.Resources.copyResources(Resources.java:103)
>         at 
> org.jacoco.report.html.HTMLFormatter.createVisitor(HTMLFormatter.java:192)
>         at 
> org.jacoco.ant.ReportTask$HTMLFormatterElement.createVisitor(ReportTask.java:254)
>         at org.jacoco.ant.ReportTask.createVisitor(ReportTask.java:533)
>         at org.jacoco.ant.ReportTask.execute(ReportTask.java:493)
>         ... 16 more
> 
> Thanks,
> Ankit
> On Thursday, 3 February 2022 at 18:19:35 UTC+5:30 Marc R. Hoffmann wrote:
> Hi Ankit,
> 
> this is not the way how it works. The agent always creates exec files, even 
> if you name them “xml”.
> 
> To create a xml report you need to run the report task. Please read the 
> documentation <https://www.jacoco.org/jacoco/trunk/doc/ant.html>.
> 
> Regards,
> -marc
> 
> 
>> On 3. Feb 2022, at 13:44, ankit daruka <ankit....@gmail.com 
>> <applewebdata://EB894C4D-4C6D-40DB-8005-F7B76F7EEAE9>> wrote:
>> 
> 
>> Hi Marc,
>> 
>> Below is my build.xml file which I was using successfully for exec file 
>> format. I have only changed the file format from exec to xml in destfile 
>> attribute of below file.
>> 
>> <project name="jacoco_rpt_pim" xmlns:jacoco="antlib:org.jacoco.ant">
>>         <property name="platformhome" location="."/>
>>     
>>         <target name="jacocoalltests" description="run jacoco">    
>>                 <ant dir="${platformhome}" target="unittests" 
>> inheritrefs="false">
>>                         <property name="testclasses.suppress.junit.tenant" 
>> value="true"/>
>>                         <property name="standalone.javaoptions" 
>> value="-javaagent:${platformhome}/lib/jacocoagent.jar=destfile=${HYBRIS_BIN_DIR}/platform/reports.xml,append=false,excludes=com.google
>>  <http://com.google/>.*:com.sun.*:de.hybris.platform.*" />                
>> </ant>
>>         </target>
>> </project>
>> 
>> I am using the below command for running the jacocoalltests target
>> Command: ant -buildfile build.xml jacocoalltests 
>> -Dtestclasses.extensions=${unitTestExtensions}
>> 
>> Can you suggest what other changes are required to get the correct xml file.
>> 
>> Thanks
>> 
>> On Thursday, 3 February 2022 at 18:08:04 UTC+5:30 Marc R. Hoffmann wrote:
>> Hi Ankit,
>> 
>> what you’re showing in the screen shot is definitely not a XML file. It more 
>> looks like a binary exec file.
>> 
>> Please see the examples in our documentation 
>> <https://www.jacoco.org/jacoco/trunk/doc/> how to create an XML report with 
>> Ant: https://www.jacoco.org/jacoco/trunk/doc/examples/build/build.xml 
>> <https://www.jacoco.org/jacoco/trunk/doc/examples/build/build.xml>
>> 
>> Best regards,
>> -marc
>> 
>> 
>>> On 3. Feb 2022, at 12:21, ankit daruka <ankit....@gmail.com <>> wrote:
>>> 
>> 
>>> Hi Team,
>>> 
>>> I am using Jacoco integration with Ant in my Hybris project. It was working 
>>> fine until the report was generating in exec format. But, after the sonar 
>>> upgrade, exec format is deprecated and we have to move to xml report format.
>>>  
>>> I have made the below property changes for getting the report in xml 
>>> format. The report is generated at the desired location in xml format, but 
>>> the content seems to be in encoded format. Can you help me with the steps 
>>> needed to migrate from exec to xml format.
>>> 
>>> Property used : 
>>> sonar.coverage.jacoco.xmlReportPaths=hybris/log/junit/jacocoReports.xml
>>> 
>>> Please find the screenshot of the xml getting generated. Please suggest any 
>>> changes required to fix the issue.
>>> 
>>> Thanks,
>> 
>>> Ankit Daruka
>>> <JacocoReports_SS.PNG>
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "JaCoCo and EclEmma Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to jacoco+un...@googlegroups.com <>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jacoco/aa3efb49-d166-4a42-ab42-60dbbe537f4cn%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jacoco/aa3efb49-d166-4a42-ab42-60dbbe537f4cn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>> <JacocoReports_SS.PNG>
>> 
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "JaCoCo and EclEmma Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to jacoco+un...@googlegroups.com 
>> <applewebdata://EB894C4D-4C6D-40DB-8005-F7B76F7EEAE9>.
> 
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/176c168f-7a25-4654-ba74-075e53cd8411n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/176c168f-7a25-4654-ba74-075e53cd8411n%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to jacoco+unsubscr...@googlegroups.com 
> <mailto:jacoco+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/a8d48329-37a0-4c92-823a-59ac865a7081n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jacoco/a8d48329-37a0-4c92-823a-59ac865a7081n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jacoco+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/E5CF4602-2CDA-4DC4-82F6-79FAC699EC99%40mountainminds.com.

Reply via email to