Getting error calling ShowViewModel - mvvmcross

Writing a sample app where I have a list of items, and then when the user clicks on a item - it uses ShowViewModel to display a detail page about the item. However, when call the method that calls ShowViewModel it crashes with the following error:
"Could not resolve type with token 01000037
(from typeref, class/assembly MvvmCross.Core.ViewModels.MvxRequestedBy..."
The code for the sample app is here:
https://github.com/gregmercer/FruitsAndVeggies
The full error message is here:
https://github.com/gregmercer/FruitsAndVeggies/blob/master/error.txt
And the line that cause the error (when uncommented) is found here:
https://github.com/gregmercer/FruitsAndVeggies/blob/master/FruitsAndVeggies.Core/ViewModels/FruitsViewModel.cs#L58

The problem is that you are mixing MvvmCross versions.
So if you look at your packages.config for your core:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MvvmCross" version="4.4.0" targetFramework="portable45-net45+win8+wpa81" />
<package id="MvvmCross.Binding" version="4.4.0" targetFramework="portable45-net45+win8+wpa81" />
<package id="MvvmCross.Core" version="4.4.0" targetFramework="portable45-net45+win8+wpa81" />
<package id="MvvmCross.Platform" version="4.4.0" targetFramework="portable45-net45+win8+wpa81" />
</packages>
These are version 4.4.0
Then if we look at the Droid project:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MvvmCross" version="5.0.2" targetFramework="monoandroid70" />
<package id="MvvmCross.Binding" version="5.0.2" targetFramework="monoandroid70" />
<package id="MvvmCross.Core" version="5.0.2" targetFramework="monoandroid70" />
<package id="MvvmCross.Droid.Shared" version="5.0.2" targetFramework="monoandroid70" />
<package id="MvvmCross.Droid.Support.Core.UI" version="5.0.2" targetFramework="monoandroid70" />
<package id="MvvmCross.Droid.Support.Fragment" version="5.0.2" targetFramework="monoandroid70" />
<package id="MvvmCross.Droid.Support.V7.AppCompat" version="5.0.2" targetFramework="monoandroid70" />
<package id="MvvmCross.Droid.Support.V7.RecyclerView" version="5.0.2" targetFramework="monoandroid70" />
<package id="MvvmCross.Platform" version="5.0.2" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Annotations" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Compat" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Core.UI" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Core.Utils" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Design" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Fragment" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Media.Compat" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Transition" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="25.3.1" targetFramework="monoandroid70" />
<package id="Xamarin.Build.Download" version="0.4.3" targetFramework="monoandroid70" />
</packages>
These are version 5.0.2, which is newer than 4.4.0.
Consolidate your packages and use same versions across all your projects.

To pass parameters you either need to inherit from a generic MvxViewModel< Parameters> or update to MvvmCross 5.0 which has improved support for passing objects without trouble.
Look at this sample as a reference: https://github.com/MvvmCross/MvvmCross/tree/develop/TestProjects/Navigation

Related

Linker preventing MvvmCross MvxApplication Initialize being called

I have updated my Target Android Api to Android 12 (API 31) so our app can be accepted in the PlayStore. This meant that the Android X packages had to be updated as well.
However, our MvxApplication Intialize override is no longer called, meaning we can not call RegisterCustomAppStart, so the app gets stuck on the splash screen.
This only happens when Linker (Link SDK assemblies only) is enabled. When it is disabled, everything works fine.
I find it impossible to determine what is happening under the hood with MvvmCross startup process, and therefore determine what may be linked out. I have included as many classes and methods as I can think of in our "LinkerPleaseInclude" file, but that is really stabbing in the dark.
ADB will output the missing method at runtime. It is indeed stabbing in the dark. It's more of a Xamarin issue than an MvvmCross issue.
The Custom Linker Configuration is a superior alternative to LinkerPleaseInclude.cs. I use this XML to prevent linking out key MvvmCross bits with an Android MvvmCross 8.x app:
<assembly fullname="MvvmCross">
<type fullname="MvvmCross.IoC.MvxPropertyInjector" />
<type fullname="MvvmCross.Core.MvxSettings" />
<type fullname="MvvmCross.Core.MvxStringToTypeParser" />
<type fullname="MvvmCross.ViewModels.MvxViewModelLoader" />
<type fullname="MvvmCross.Platforms.Android.Views.MvxSavedStateConverter" />
<type fullname="MvvmCross.ViewModels.MvxAppStart`1" />
</assembly>
Here is a full example from an Android app built with MvvmCross 8.0.2. The idea is to keep only what is needed. For example, remove the NumberPicker parts if you don't use that widget in your app.
<?xml version="1.0" encoding="utf-8" ?>
<!--
This file prevents the Xamarin.Android Linker from removing code from the final executable.
C# Properties are implemented as two methods: get_PropertyName + put_PropertyName
C# Events are implemented as two methods: add_EventName + remove_EventName
C# Constructors are implemented as such:
default: .ctor
string parameter: System.Void .ctor(System.String)
See https://docs.microsoft.com/en-us/xamarin/cross-platform/deploy-test/linker for more information.
-->
<linker>
<!-- Mono.Android -->
<assembly fullname="Mono.Android">
<type fullname="Android.Views.View">
<method name="get_Text" />
<method name="put_Text" />
<method name="get_ContentDescription" />
<method name="put_ContentDescription" />
<method name="add_Click" />
<method name="remove_Click" />
<method name="add_LongClick" />
<method name="remove_LongClick" />
<method name="Invalidate" />
</type>
<type fullname="Android.Views.View.LongClickEventArgs">
<method name="System.Void .ctor(System.Boolean)" />
<method name="get_Handled" />
<method name="put_Handled" />
</type>
<type fullname="Android.Widget.TextView">
<method name="add_AfterTextChanged" />
<method name="remove_AfterTextChanged" />
</type>
<type fullname="Android.Widget.NumberPicker">
<method name="get_Value" />
<method name="put_Value" />
<method name="add_ValueChanged" />
<method name="remove_ValueChanged" />
</type>
<type fullname="Android.Widget.NumberPicker.ValueChangeEventArgs">
<method name="get_Picker" />
<method name="put_Picker" />
<method name="get_OldVal" />
<method name="put_OldVal" />
<method name="get_NewVal" />
<method name="put_NewVal" />
</type>
</assembly>
<!-- netstandard -->
<assembly fullname="netstandard">
<type fullname="System.TimeSpan" >
<method name="get_Hours" />
<method name="get_Minutes" />
<method name="get_Seconds" />
</type>
</assembly>
<!-- Google Material Design Components -->
<assembly fullname="Xamarin.Google.Android.Material">
<type fullname="Google.Android.Material.TextField.TextInputLayout">
<method name="get_Hint" />
<method name="set_Hint" />
<method name="get_Error" />
<method name="set_Error" />
</type>
<type fullname="Google.Android.Material.TextField.TextInputEditText">
<method name="get_Text" />
<method name="set_Text" />
</type>
</assembly>
<!-- MvvmCross -->
<assembly fullname="MvvmCross">
<type fullname="MvvmCross.IoC.MvxPropertyInjector" />
<type fullname="MvvmCross.Core.MvxSettings" />
<type fullname="MvvmCross.Core.MvxStringToTypeParser" />
<type fullname="MvvmCross.ViewModels.MvxViewModelLoader" />
<type fullname="MvvmCross.Platforms.Android.Views.MvxSavedStateConverter" />
<type fullname="MvvmCross.ViewModels.MvxAppStart`1" />
</assembly>
<!-- Xamarin.AndroidX.Core -->
<assembly fullname="Xamarin.AndroidX.Core">
<type fullname="AndroidX.Core.App.CoreComponentFactory" />
</assembly>
</linker>

Adding supported file type in windows phone 8.1

I have added four file type association in my package.appmanifest file
in which .pdf is one of them. Due to this when i am clicking on any
external pdf file, My app is also coming in the list along with Adobe
reader. What could be the reason.
Following is the code of my app.manifest file
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="195c0ec0-b933-4837-99c7-30250bbd0f9b" Publisher="CN=etu10" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="195c0ec0-b933-4837-99c7-30250bbd0f9b" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>eBasta</DisplayName>
<PublisherDisplayName>etu10</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="eBasta.App">
<m3:VisualElements DisplayName="eBasta" Square150x150Logo="Assets\Logo.png" Square44x44Logo="Assets\SmallLogo.png" Description="eBasta" ForegroundText="light" BackgroundColor="transparent">
<m3:DefaultTile Wide310x150Logo="Assets\WideLogo.png" Square71x71Logo="Assets\Square71x71Logo.png">
</m3:DefaultTile>
<m3:SplashScreen Image="Assets\SplashScreen.png" />
<m3:InitialRotationPreference>
<m3:Rotation Preference="portrait" />
<m3:Rotation Preference="landscape" />
<m3:Rotation Preference="landscapeFlipped" />
</m3:InitialRotationPreference>
</m3:VisualElements>
<Extensions>
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name="text">
<DisplayName>text</DisplayName>
<SupportedFileTypes>
<FileType ContentType="text/xml">.xml</FileType>
<FileType ContentType="application/pdf">.pdf</FileType>
<FileType ContentType="application/zip">.zip</FileType>
<FileType ContentType="application/zip">.ebs</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
<Extension Category="windows.fileTypeAssociation">
<FileTypeAssociation Name=".pdf">
<DisplayName>pdf</DisplayName>
<SupportedFileTypes>
<FileType ContentType="application/pdf">.pdf</FileType>
</SupportedFileTypes>
</FileTypeAssociation>
</Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
<Capability Name="removableStorage" />
<Capability Name="picturesLibrary" />
<Capability Name="musicLibrary" />
<Capability Name="enterpriseAuthentication" />
<m3:Capability Name="contacts" />
<m3:Capability Name="appointments" />
<Capability Name="sharedUserCertificates" />
<Capability Name="videosLibrary" />
<DeviceCapability Name="location" />
<DeviceCapability Name="proximity" />
<DeviceCapability Name="webcam" />
</Capabilities>
</Package>
Well it's normal that your app is listed there as you supported that file extension. If you expected that your app opens the file alone, that's not possible in Windows phone as defining default file opener is not supported

ServiceStack View 403 (Forbidden)

I have setup Service Stack web project with a couple of views. I can access the /Default.cshtml view without any problems but when I try to access anything in the /Views/ folder I get the below error:
Forbidden
Request.HttpMethod: GET
Request.PathInfo: /Views/MyView.cshtml
Request.QueryString:
Request.RawUrl: /Views/MyView.cshtml
I have looked at the answers here and here as well as many others but I can't seem to figure this out.
Here is my view:
#{
ViewBag.Title = "Fake View";
}
<div>
<div>Hello!</div>
</div>
And my Web.Config:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<sectionGroup name="jsEngineSwitcher">
<section name="core" type="JavaScriptEngineSwitcher.Core.Configuration.CoreConfiguration, JavaScriptEngineSwitcher.Core" />
<section name="msie" type="JavaScriptEngineSwitcher.Msie.Configuration.MsieConfiguration, JavaScriptEngineSwitcher.Msie" />
<section name="v8" type="JavaScriptEngineSwitcher.V8.Configuration.V8Configuration, JavaScriptEngineSwitcher.V8" />
</sectionGroup>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<compilation targetFramework="4.5" debug="true">
<buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders>
</compilation>
<httpRuntime targetFramework="4.5" />
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
<security>
<requestFiltering>
<hiddenSegments>
<add segment="ClearScript.V8" />
</hiddenSegments>
</requestFiltering>
</security>
</system.webServer>
<jsEngineSwitcher xmlns="http://tempuri.org/JavaScriptEngineSwitcher.Configuration.xsd">
<core>
<engines>
<add name="MsieJsEngine" type="JavaScriptEngineSwitcher.Msie.MsieJsEngine, JavaScriptEngineSwitcher.Msie" />
<add name="V8JsEngine" type="JavaScriptEngineSwitcher.V8.V8JsEngine, JavaScriptEngineSwitcher.V8" />
</engines>
</core>
</jsEngineSwitcher>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
<add key="webPages:Enabled" value="false" />
</appSettings>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="System" />
<add namespace="ServiceStack" />
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="ConnectDevelop.Configuration.Web" />
</namespaces>
</pages>
</system.web.webPages.razor>
</configuration>
I've also added ?debug=requestinfo to the end of the request but I can't see any obvious errors in the output.
Any help would be appreciated.
See the difference between Views vs Content Pages, i.e. the /Views folder is a special folder for view pages that are only executed with the result of a Service (i.e. similar to ASP.NET MVC Controllers + Views).
Essentially Razor pages in /Views can't be called directly, where as razor pages outside of /Views can only be called directly.

Package.appxmanifest not showing all 7 Tabs

I re-targeted my project from wp8 to wp8.1. At first my package.appxmanifest file's build action was not set to Appxmanifest. Also it is only showing 4 tabs
-Application
-capabilities
-Declarations
-Packaging
Tabs that are missing are
-Visual Assets
-content URI's
-Declarations
What should i do.
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="37576f76-9ac9-4f78-b2d9-cb51446fb500" Publisher="CN=R" Version="1.0.0.0" />
<mp:PhoneIdentity PhoneProductId="e4312153-3f4c-49dd-904d-5fbe8f1d6000" PhonePublisherId="3f72d71c-dd80-408e-affb-aa06372f300a" />
<Properties>
<DisplayName>app</DisplayName>
<PublisherDisplayName>app</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="xe4312153y3f4cy49ddy904dy5fbe8f1d6073x" Executable="AGHost.exe" EntryPoint="MainPage.xaml">
<m3:VisualElements DisplayName="app" Square150x150Logo="Assets\SquareTile150x150.png" Square44x44Logo="Assets\Logo.png" Description="app" ForegroundText="light" BackgroundColor="#464646" ToastCapable="true">
<m3:DefaultTile Square71x71Logo="Assets\SquareTile71x71.png">
</m3:DefaultTile>
<m3:SplashScreen Image="SplashScreenImage.jpg" />
<m3:ApplicationView MinWidth="width320" />
<!--Used in XAML Designer. DO NOT REMOVE-->
</m3:VisualElements>
</Application>
</Applications>
<Extensions>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>AgHostSvcs.dll</Path>
<ActivatableClass ActivatableClassId="AgHost.BackgroundTask" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
<Capabilities>
<Capability Name="internetClientServer" />
<DeviceCapability Name="location" />
</Capabilities>
</Package>
Silverlight-based apps don't have those extra tabs; they are only applicable to non-Silverlight (WinRT) apps. You set things like your Tile icons via the WMAppManifest.xml file.

In Cobertura Report all the percentages are 0 and message is coming have you mentioned the correct path

Here is my build.xml. Here all the paths are mentioned.
In report all the percentages are 0(ZERO).
And It is also prompting me that "Have you mentioned the specified source directory"
Please suggest where is the mistake.
Either I have to change the build.xml or have to perform some steps.
First I ran all the junit test cases, then stoped the server and then run the build.xml as ant-build.
<project name="RFM2" default="cobertura_REPORT">
<property name="BASEDIR" value="D:/SIT/busnessservice" />
<property name="cobertura.dir" value="D:/SIT/JUNIT_jars/cobertura-1.9.1" />
<property name="src.dir" value="${BASEDIR}/src" />
<property name="build.dir" value="${BASEDIR}/build" />
<property name="dist.dir" value="${BASEDIR}/dist" />
<property name="lib.dir" value="D:/SIT/JUNIT_jars/jars" />
<property name="report.dir" value="${BASEDIR}/reports" />
<property name="cobertura.ser.file" value="${cobertura.dir}/cobertura.ser" />
<property name="server.ser.file" value="D:/Program Files/cobertura.ser" />
<property name="instrumentedDir" value="${cobertura.dir}/instrument" />
<property name="junit.data.dir" value="${report.dir}/junit/data" />
<property name="junit.report.dir" value="${report.dir}/junit/html" />
<property name="junit.dir" value="D:/SIT/JUNIT_jars/jars" />
<property name="test.dir" value="D:/SIT/JUNITTESTFILES" />
<!--class path for cobertula -->
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}">
<include name="cobertura-1.9.4.1.jar" />
<include name="*.jar" />
</fileset>
</path>
<!--class path for JUNIT -->
<path id="junit.classpath">
<fileset dir="${junit.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${junit.dir}/junit-4.1.jar" />
<pathelement location="${BASEDIR}/bin" />
<path refid="cobertura.classpath" />
</path>
<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
<!-- PATH FOR LIB -->
<path id="lib.classpath">
<fileset dir="${lib.dir}" includes="*.jar" />
</path>
<path id="runtime.classpath">
<pathelement location="${build.dir}" />
<path refid="lib.classpath" />
</path>
<!--Initialization -->
<target name="init">
<mkdir dir="${dist.dir}" />
</target>
<!-- Clean files-->
<target name="clean" description="Remove all generated files.">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
</target>
<!-- Compile the java file -->
<!--Instrument the files -->
<target name="cobertura_instrument">
<cobertura-instrument todir="${instrumentedDir}" datafile="${server.ser.file}">
<fileset dir="${lib.dir}">
<include name="businessServices.jar" />
</fileset>
</cobertura-instrument>
<!-- Copy cobertula.ser file in server-->
</target>
<!--copy the instrumented file in class file-->
I have removed this block as I think it is not getting used .
But still my report is getting generated with zero percentage.
<!--Make EAR-->
<target name="making ear">
<echo>come in making ear</echo>
<ear destfile="${build.dir}/myapp.ear" appxml="${src.dir}/metadata/application.xml">
<fileset dir="${build.dir}" includes="*.jar,*.war" />
</ear>
</target>
<!--Run the JUNIT Test Case-->
<target name="runJunitTest">
<junit fork="yes" dir="${test.dir}" failureProperty="test.failed">
<!--
Specify the name of the coverage data file to use.
The value specified below is the default.
-->
<sysproperty key="net.sourceforge.cobertura.datafile" file="${server.ser.file}" />
<classpath location="${instrumentedDir}" />
<classpath refid="junit.classpath" />
<classpath refid="cobertura.dir" />
<formatter type="plain" usefile="false" />
<formatter type="xml"/>
<test name="${test.dir}/ColorConfigurationTest" />
<batchtest todir="${report.dir}" unless="testcase">
<fileset dir="${test.dir}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
</target>
<!--rEPORTING-->
<target name="cobertura_REPORT">
<delete dir="${report.dir}" />
<mkdir dir="${report.dir}" />
<cobertura-report srcdir="${src.dir}" format="html" destdir="${report.dir}" datafile="${server.ser.file}">
</cobertura-report>
</target>
</project>
<!--Make EAR-->
<target name="making ear">
<echo>come in making ear</echo>
<ear destfile="${build.dir}/myapp.ear" appxml="${src.dir}/metadata/application.xml">
<fileset dir="${build.dir}" includes="*.jar,*.war" />
</ear>
</target>
<!--Run the JUNIT Test Case-->
<target name="runJunitTest">
<junit fork="yes" dir="${test.dir}" failureProperty="test.failed">
<!--
Specify the name of the coverage data file to use.
The value specified below is the default.
-->
<sysproperty key="net.sourceforge.cobertura.datafile" file="${server.ser.file}" />
<classpath location="${instrumentedDir}" />
<classpath refid="junit.classpath" />
<classpath refid="cobertura.dir" />
<formatter type="plain" usefile="false" />
<formatter type="xml"/>
<test name="${test.dir}/ColorConfigurationTest" />
<batchtest todir="${report.dir}" unless="testcase">
<fileset dir="${test.dir}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
</target>
I noticed one thing that should be easy to correct - that doesn't match the Cobertura doc or my working copy. Hopefully this will fix your problem.
Your JUnit task references <classpath refid="cobertura.dir" /> but the cobertura.dir is not a path id, it is the name of a property pointing to your cobertura directory. (IntelliJ IDEA flagged it in red, which caught my eye!)
In my script, I have:
Then my JUnit task references the cobertura.classpath like so:
<classpath refid="cobertura.classpath" />
Hope this helps!