ant-javacard
                                
                                 ant-javacard copied to clipboard
                                
                                    ant-javacard copied to clipboard
                            
                            
                            
                        Easy to use Ant task for building JavaCard applets (2.1.1 to 3.2.0)
Building JavaCard applet CAP files with Ant
Easy to use Ant task for building JavaCard CAP files in a declarative way.
Features
- Do What I Mean. You will love it!
- No dependencies, no extra or unrelated downloads. Just a 46KB jar.
- Supports all available JavaCard SDK versions: 2.1.2, 2.2.1, 2.2.2, 3.0.3, 3.0.4, 3.0.5 and 3.1
- Get one from oracle.com or use the handy Github repository
 
- Works on all platforms with Java 1.8+: Windows, OSX, Linux.
- Usable SDK-s depend on JDK version; 1.8 recommended!
 
- Almost everything integrates or works with Ant.
- Trigger it from Maven or via Gradle wrapper
 
- Can be easily integrated into continuous integration workflows.
- Generates CAP files from sources or pre-compiled class files.
- Import external libraries: natural use of .jarlibraries and/or.expfiles.
- No restrictions on project folder layout (but src/main/javacardworks).
- Loading JavaCard applets is equally pleasing with GlobalPlatformPro
Download & Use
- Download ant-javacard.jar- Java version usable with all SDK-s is 1.8! Use SDK 3.0.5u3 and targetsdkto compile with Java 10 for older versions.
 
- Java version usable with all SDK-s is 1.8! Use SDK 3.0.5u3 and 
- Or use the download task:
<get src="https://github.com/martinpaljak/ant-javacard/releases/latest/download/ant-javacard.jar" dest="." skipexisting="true"/>
- Then add the following to your build.xmlfile:
<taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="ant-javacard.jar"/>
- Now you can create applets within your Ant targets like this:
<javacard>
  <cap jckit="/path/to/jckit_dir" aid="0102030405">
    <applet class="myapplet.MyApplet" aid="0102030405060708"/>
  </cap>
</javacard>
(which results in output similar to this)
target:
      [cap] INFO: using JavaCard 3.0.4 SDK in sdks/jc304_kit
      [cap] INFO: targeting JavaCard 2.2.2 SDK in sdks/jc222_kit
      [cap] Setting package name to testapplets.empty
      [cap] INFO: generated applet AID: A000000617008E5CDAAE01 for testapplets.empty.Empty
      [cap] Building CAP with 1 applet from package testapplets.empty (AID: A000000617008E5CDAAE)
      [cap] testapplets.empty.Empty A000000617008E5CDAAE01
  [compile] Compiling files from /Users/martin/projects/ant-javacard/src/testapplets/empty
  [compile] Compiling 1 source file to /var/folders/gf/_m9mq9td3lz32qv1hd4r12yw0000gn/T/jccpro841338375581620546
  [convert] [ INFO: ] Converter [v3.0.4]
  [convert] [ INFO: ]     Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
  [convert]
  [convert]
  [convert] [ INFO: ] conversion completed with 0 errors and 0 warnings.
 [javacard] NB! Please use JavaCard SDK 3.0.5u3 or later for verifying!
      [cap] CAP saved to /Users/martin/projects/ant-javacard/Empty_A000000617008E5CDAAE_50da91a4_2.2.2.cap
Syntax
Sample:
<javacard jckit="/path/to/jckit_dir1">
  <cap targetsdk="/path/to/jckit_dir2" aid="0102030405" package="package.name" version="0.1" output="MyApplet.cap" sources="src/myapplet" classes="path/to/classes" export="mylib">
    <applet class="myapplet.MyApplet" aid="0102030405060708"/>
    <import exps="path/to/exps" jar="/path/to/lib.jar"/>
  </cap>
</javacard>
Details:
- javacardtag - generic task- jckitattribute - path to the JavaCard SDK that is used if individual- capdoes not specify one. Optional if- capdefines one, required otherwise.
 
- captag - construct a CAP file- jckitattribute - path to the JavaCard SDK to be used. Optional if- javacarddefines one, required otherwise.
- targetsdkattribute - path to the target JavaCard SDK to be used for this CAP. Optional, value of- jckitused by default. Allows to use a more recent converter to target older JavaCard platforms.
- sourcesattribute - path to Java source code, to be compiled against the JavaCard SDK. Either- sourcesor- classesis required, unless- src/main/javacardexists.
- sources2attribute - additional sources to build per-platform applets. Optional.
- classesattribute - path to pre-compiled class files to be assembled into a CAP file. If both- classesand- sourcesare specified, compiled class files will be put to- classesfolder, which is created if missing.
- includesattribute - comma or space separated list of patterns of files that must be included.
- excludesattribute - comma or space separated list of patterns of files that must be excluded.
- packageattribute - name of the package of the CAP file. Optional for applets - set to the parent package of the applet class if left unspecified, required for libraries
- versionattribute - version of the package. Optional - defaults to 0.1 if left unspecified.
- fidesmoappidattribute - Fidesmo appId, to create the package AID and applet AID-s automatically. Optional.
- aidattribute - AID (hex) of the package. Recommended - or set to the 5 first bytes of the applet AID if left unspecified.
- outputattribute - path where to save the generated CAP file. Optional, see below for variables.
- exportattribtue - path (folder) where to place the JAR and generated EXP file. Optional.
- jarattribute - path where to save the generated archive JAR file. Optional.
- jcaattribute - path where to save the generated JavaCard Assembly (JCA) file. Optional.
- verifyattribute - if set to false, disables verification of the resulting CAP file with offcardeverifier. Optional.
- debugattribute - if set to true, generates debug CAP components. Optional.
- stripattribute - if set to true, removes class files from CAP. Optional.
- intsattribute - if set to true, enables support for 32 bit- inttype. Optional.
 
- applettag - for creating an applet inside the CAP- classattribute - class of the Applet where install() method is defined. Required.
- aidattribute - AID (hex) of the applet. Recommended - or set to package- aid+- iwhere- iis index of the applet definition in the build.xml instruction
 
- importtag - for linking against external components/libraries, like- GPSystemor- OPSystem- expsattribute - path to the folder keeping- .expfiles. Optional. Required if file in- jardoes not include .exp files.
- jarattribute - path to the JAR file for compilation. Required if using- sourcesmode and not necessary with- classesmode if java code is already compiled
 
Notes:
- jc.homeproperty has the highest precedence, followed by- jckitpath of- cap, followed by path in- javacard, followed by- JC_HOMEenvironment variable. SDK must be valid to be considered for use.
Output file name variables
- %h- 8 character prefix of the SHA-256 Load File Data Block hash of the CAP file
- %H- SHA-256 Load File Data Block hash of the CAP file
- %n- common name of the entity, either applet class or package
- %p- package name
- %a- package AID
- %j- targeted JavaCard version
Maven dependency
Releases are published to https://javacard.pro/maven/. To use it, add this to your pom.xml:
<repositories>
    <repository>
        <id>javacard-pro</id>
        <url>https://javacard.pro/maven/</url>
    </repository>
</repositories>
Pushes to Maven Central happen manually and only for selected final versions.
License
- MIT
Happy users
A random list of users, with a public link:
- Applets:
- IsoApplet by @philipWendland
- NdefApplet by @promovicz
- GidsApplet by @vletoux
- LedgerWalletApplet by @LedgerHQ
- KeePassNFC by @nfd
- PivApplet (PIV) by @arekinath
- OpenFIP201 (PIV) by @makinako
- Cryptonit (PIV) by @mbrossard
- HTOP NDEF by @petrs
- Yubikey OTP by @arekinath
- SmartPGP by @ANSSI-FR
- SatochipApplet (Bitcoin Hardware Wallet) by @Toporin
- Plus loads of academic projects, classes and papers.
 
- Integration projects:
- Other:
- You! Don't torture yourself with complexity, KISS!
 
Contact
- See javacard.pro
Similar projects
- standard JavaCard SDK Ant tasks
- :( as cumbersome to use as the command line utilities
- :( not declarative/DWIM enough
- :) very explicit interface with all details exposed
 
- JavaCard Gradle plugin (MIT) - https://github.com/bertrandmartel/javacard-gradle-plugin
- :) Wraps ant-javacard for use with Gradle
 
- gradle-javacard (Apache 2.0) - https://github.com/fidesmo/gradle-javacard
- :) nice declarative interface
- :( requires gradle (40M download)
- :( JavaCard 2.2.2 only
 
- EclipseJCDE (Eclipse 1.0) - http://eclipse-jcde.sourceforge.net/
- :( JavaCard 2.2.2 only
- :( not possible to integrate in CI - depends on eclipse
- :( essentially an Eclipse GUI wrapper for JC SDK
 
- JCOP Tools
- :( not open source
 
- NetBeans IDE JC support
- :( not possible to integrate into CI
- :( JavaCard 3.0 only
- :( Netbeans, not cross platform
 
- Maven2 task from FedICT (LGPL3) - https://code.google.com/p/eid-quick-key-toolset
- :( Maven downloads half the internet before even simple tasks
- :( JavaCard 2.2.2 only
 
- Ant script files with templates
- :( XML is a very bad and verbose programming environment