martinpaljak/ant-javacard

Unable to get excludes attribute to work

Closed this issue · 9 comments

Hello,

I have a modified version of PivApplet that I am trying to add JUnit tests to. I have some test code that's not intended to be part of the .cap, and I'm trying to exclude it using the excludes attribute.

    <javacard>
      <cap aid="a0:00:00:03:08:00:00:10" output="bin/PivApplet.cap" sources="src-gen" excludes="**Test**" classes="bin" version="1.0">
        <applet class="net.cooperi.pivapplet.PivApplet" aid="a0:00:00:03:08:00:00:10:00:01:00"/>
      </cap>
    </javacard>

I've tried every variation I can come up with in order to exclude "src-gen/org/openphysical/pivapplet/PivAppletTest.java". I've tried **Test**, **/*Test.java, etc. I've even tried excluding ".class", ".java", etc. just to see if it would exclude other files.

Does the excludes attribute work? It's entirely possible I'm using it wrong.

It should, of course. Let me have a look just to verify.

Indeed it does not, the file is removed from the "list of files to compile" but actually still gets compiled...

Ahh. Makes sense.

I'm not particularly familiar with ant, so I figured it was probably something on my end.

Fixed, will be released ASAP (trying to make a testcase as well..)

Will v21.12.16 be made available on the maven repository?

It is now.

The exclude attribute works as expected, and I'm now able to get the unit testing working as expected.

I was getting some errors initially, "java.lang.NoClassDefFoundError: pro/javacard/VerifierError" using just the classpath for ant-javacard on the taskdef entry.

I was able to resolve the error by adding the capfile library to the class path.

  <target name="dist" depends="preprocess,resolve" description="generate the distribution">
    <tstamp/>
    <!-- Create the distribution directory -->
    <taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="lib/ant-javacard-21.12.31.jar;lib/capfile-20.02.19.jar"/>
    <javacard>
      <cap aid="a0:00:00:03:08:00:00:10" output="bin/PivApplet-222.cap" sources="src-gen" excludes="test/*" classes="bin" jckit="ext/oracle_javacard_sdks/jc222_kit/" version="1.0">
        <applet class="net.cooperi.pivapplet.PivApplet" aid="a0:00:00:03:08:00:00:10:00:01:00"/>
      </cap>
      <cap aid="a0:00:00:03:08:00:00:10" output="bin/PivApplet-304.cap" sources="src-gen" excludes="test/*" classes="bin" jckit="ext/oracle_javacard_sdks/jc304_kit/" version="1.0">
        <applet class="net.cooperi.pivapplet.PivApplet" aid="a0:00:00:03:08:00:00:10:00:01:00"/>
      </cap>
    </javacard>
  </target>

Thank you so much for the help.

ant-javacard.jar is distributed as a combined JAR containing all necessary bits and pieces. If you fetch it somehow via Maven, you obviouosly have to add necessary things to classpath.

Makes sense. Thank you.