Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ant-javacard for building the applet. #3

Merged
merged 1 commit into from
May 2, 2015
Merged

Use ant-javacard for building the applet. #3

merged 1 commit into from
May 2, 2015

Conversation

martinpaljak
Copy link
Contributor

This works on all platforms and all JavaCard SDK versions
and is more pleasing to eye.

@philipWendland
Copy link
Owner

Thank you, I did actually test this on a local branch but got distracted.
From the readme of jcpro, the build.xml you provided should work out of the box when JC_HOME is set. However, I get:

[philip@philip-pc IsoApplet]$ echo $JC_HOME
/opt/java/lib/java-card-development-kit
[philip@philip-pc IsoApplet]$ ant
Buildfile: /home/philip/projects/github/IsoApplet/build.xml

dist:

BUILD FAILED
/home/philip/projects/github/IsoApplet/build.xml:8: Must specify JavaCard SDK path

Total time: 0 seconds
[philip@philip-pc IsoApplet]$

Am I wrong? Do you need more debug information?

I know from earlier tests that it does work when specifying the java card SDK manually by:

<javacard jckit="/path/to/jckit_dir1">
  <cap jckit="/path/to/jckit_dir2" (...)

@martinpaljak
Copy link
Contributor Author

JC_HOME was documented on README but not released as a downloadable JAR. This was fixed before making this pull request, that includes https://github.com/martinpaljak/ant-javacard/releases/tag/v0.8

The warning is correct with both versions:

/Users/martin/projects/IsoApplet/build.xml:8: Must specify JavaCard SDK path or set JC_HOME

@philipWendland
Copy link
Owner

Nevermind. I had ant-javacard in $ANT_HOME/lib from earlier and ant favored to use the older version located there..

You might have seen this as well:

[compile] /home/philip/projects/github/IsoApplet/src/net/pwendland/javacard/pki/isoapplet/ElementaryFileCyclicFixed.java:68: error: annotations are not supported in -source 1.3
  [compile]     @Override
  [compile]      ^
  [compile]   (use -source 5 or higher to enable annotations)

As far as I remember, the IsoApplet uses features introduced in JC 2.2.2 (getIncomingLength, getOffsetCData etc.) which builds upon Java SDK 1.5 [1]. As there is no possibility to go below JC 2.2.2, compiling the sources with -source 1.5 might make sense.

In the source code of ant-javacard I found:

312         // TODO: detect
313         // 2.2.1 max 1.2
314         // 2.2.2 max 1.3
315         // 3.0.3 max 1.6. Overrides come in 1.5

Where did you get that information from? See the link below, JC 2.2.2 should be JDK 1.5. I am currently using -source 1.5 as well.
It's not that having the annotiation is a must for me, I just wanted to note this.

[1] http:https://www.oracle.com/technetwork/java/javacard/documentation/releasenotes-jcspecspw-2-2-2-142671.html - "Java Card platform language aligned with JDK^TM version 1.5 technology and tools"

@martinpaljak
Copy link
Contributor Author

Interesting. I really don't remember but it should have come from some empirical tests that are apparently wrong. I'll need to look into this. Thanks for noticing.

@philipWendland
Copy link
Owner

I'd rather not have the ant-javacard.jar binary in the version control. There are two ways to get around this; either have the user/contributor download ant-javacard.jar himself or

including the ant-javacard source code as git submodule (cd ext && git submodule add https://github.com/martinpaljak/ant-javacard.git) and have ant (recursively) call its build.xml to generate the jar, see below. What do you think of this idea?

Either way, could you please rebase your commit to not include the ant-javacard.jar binary?

diff --git a/build.xml b/build.xml
index 8440e92..051c4d4 100644
--- a/build.xml
+++ b/build.xml
@@ -1,10 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project name="JavaCard PKI isoApplet" default="dist" basedir=".">
+<project name="JavaCard PKI IsoApplet" default="dist" basedir=".">
   <description>Builds the project. </description>
-  <target name="dist" description="generate the distribution">
+
+  <target name="init-ant-javacard" description="build ant-javacard">
+    <tstamp/>
+    <ant antfile="build.xml" dir="ext/ant-javacard" />
+    <taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="ext/ant-javacard/ant-javacard.jar"/>
+  </target>
+
+  <target name="dist" depends="init-ant-javacard" description="generate the distribution">
     <tstamp/>
     <!-- Create the distribution directory -->
-    <taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="ext/ant-javacard.jar"/>
     <javacard>
       <cap aid="f2:76:a2:88:bc:fb:a6:9d:34:f3:10" output="IsoApplet.cap" sources="src" version="1.0">
         <applet class="net.pwendland.javacard.pki.isoapplet.IsoApplet" aid="f2:76:a2:88:bc:fb:a6:9d:34:f3:10:01"/>

This works on all platforms and all JavaCard SDK versions
and is more pleasing to eye.
@martinpaljak
Copy link
Contributor Author

What about this ?

@philipWendland philipWendland merged commit 7fcbf0c into philipWendland:master May 2, 2015
@philipWendland
Copy link
Owner

Perfect, thank you! Applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants