{"id":13428436,"url":"https://github.com/ph4r05/javacard-gradle-template","last_synced_at":"2025-10-23T11:30:29.858Z","repository":{"id":27406425,"uuid":"113781603","full_name":"ph4r05/javacard-gradle-template","owner":"ph4r05","description":"JavaCard project template for building CAP and running JCardSim with gradle + coverage","archived":false,"fork":false,"pushed_at":"2023-10-09T13:19:18.000Z","size":892,"stargazers_count":53,"open_issues_count":5,"forks_count":23,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-30T17:38:40.778Z","etag":null,"topics":["ant-javacard","cap","coverage","gradle","intellij-idea","javacard","javacard-applet","javacard-project","javacard-simulator","jcardsim","project","project-template","simulator","template","testing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ph4r05.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-10T20:36:30.000Z","updated_at":"2024-12-20T07:39:47.000Z","dependencies_parsed_at":"2023-01-14T06:40:36.307Z","dependency_job_id":null,"html_url":"https://github.com/ph4r05/javacard-gradle-template","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph4r05%2Fjavacard-gradle-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph4r05%2Fjavacard-gradle-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph4r05%2Fjavacard-gradle-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ph4r05%2Fjavacard-gradle-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ph4r05","download_url":"https://codeload.github.com/ph4r05/javacard-gradle-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237811515,"owners_count":19370144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ant-javacard","cap","coverage","gradle","intellij-idea","javacard","javacard-applet","javacard-project","javacard-simulator","jcardsim","project","project-template","simulator","template","testing"],"created_at":"2024-07-31T01:00:57.216Z","updated_at":"2025-10-23T11:30:24.521Z","avatar_url":"https://github.com/ph4r05.png","language":"Java","funding_links":[],"categories":["Tools","企业软件开发"],"sub_categories":["文件同步"],"readme":"# JavaCard Template project with Gradle\n\n[![Build Status](https://travis-ci.org/ph4r05/javacard-gradle-template.svg?branch=master)](https://travis-ci.org/ph4r05/javacard-gradle-template)\n\nThis is simple JavaCard project template using Gradle build system.\n\nYou can develop your JavaCard applets and build cap files with the Gradle!\nMoreover the project template enables you to test the applet with [JCardSim] or on the physical cards.\n\nGradle project contains one module:\n\n- `applet`: contains the javacard applet. Can be used both for testing and building CAP\n\nFeatures:\n - Gradle build (CLI / IntelliJ Idea)\n - Build CAP for applets\n - Test applet code in [JCardSim] / physical cards\n - IntelliJ Idea: Coverage\n - Travis support \n\n### Template\n\nThe template contains simple Hello World applet generating random bytes on any APDU message received.\nThere is also implemented very simple test that sends static APDU command to this applet - in JCardSim.\n\nThe Gradle project can be opened and run in the IntelliJ Idea.\n\nRunning in IntelliJ Idea gives you a nice benefit: *Coverage*!\n\n## How to use\n\n- Clone this template repository:\n\n```bash\ngit clone --recursive https://github.com/ph4r05/javacard-gradle-template.git\n```\n\n- Implement your applet in the `applet` module.\n\n- Run Gradle wrapper `./gradlew` on Unix-like system or `./gradlew.bat` on Windows\nto build the project for the first time (Gradle will be downloaded if not installed).\n\n## Building cap\n\n- Setup your Applet ID (`AID`) in the `./applet/build.gradle`.\n\n- Run the `buildJavaCard` task:\n\n```bash\n./gradlew buildJavaCard  --info --rerun-tasks\n```\n\nGenerates a new cap file `./applet/out/cap/applet.cap`\n\nNote: `--rerun-tasks` is to force re-run the task even though the cached input/output seems to be up to date.\n\nTypical output:\n\n```\n[ant:cap] [ INFO: ] Converter [v3.0.5]\n[ant:cap] [ INFO: ]     Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.\n[ant:cap]     \n[ant:cap]     \n[ant:cap] [ INFO: ] conversion completed with 0 errors and 0 warnings.\n[ant:verify] XII 10, 2017 10:45:05 ODP.  \n[ant:verify] INFO: Verifier [v3.0.5]\n[ant:verify] XII 10, 2017 10:45:05 ODP.  \n[ant:verify] INFO:     Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.\n[ant:verify]     \n[ant:verify]     \n[ant:verify] XII 10, 2017 10:45:05 ODP.  \n[ant:verify] INFO: Verifying CAP file /Users/dusanklinec/workspace/jcard/applet/out/cap/applet.cap\n[ant:verify] javacard/framework/Applet\n[ant:verify] XII 10, 2017 10:45:05 ODP.  \n[ant:verify] INFO: Verification completed with 0 warnings and 0 errors.\n```\n\n## Installation on a (physical) card\n\n```bash\n./gradlew installJavaCard\n```\n\nOr inspect already installed applets:\n\n```bash\n./gradlew listJavaCard\n```\n\n## Running on simulator (jCardSim)\n\nAs simple as:\n\n```bash\n./gradlew run\n```\n\nBy default the run task will run the main Java application implemented at: `main/java/main/Run.java`, using the `HelloWorldApplet` applet.\n\n## Running tests\n\n```\n./gradlew test --info --rerun-tasks\n```\n\nOutput:\n\n```\nRunning test: Test method hello(AppletTest)\n\nGradle suite \u003e Gradle test \u003e AppletTest.hello STANDARD_OUT\n    Connecting to card... Done.\n    --\u003e [00C00000080000000000000000] 13\n    \u003c-- 51373E8B6FDEC284DB569204CA13D2CAA23BD1D85DCAB02A0E3D50461E73F1BB 9000 (32)\n    ResponseAPDU: 34 bytes, SW=9000\n```\n\n## Dependencies\n\nThis project uses mainly:\n\n- https://github.com/bertrandmartel/javacard-gradle-plugin\n- https://github.com/martinpaljak/ant-javacard\n- https://github.com/martinpaljak/oracle_javacard_sdks\n- https://github.com/licel/jcardsim\n- Petr Svenda scripts \n\nKudos for a great work!\n\n### JavaCard support\n\nThanks to Martin Paljak's [ant-javacard] and [oracle_javacard_sdks] we support:\n\n- JavaCard 2.1.2\n- JavaCard 2.2.1\n- JavaCard 2.2.2\n- JavaCard 3.0.3\n- JavaCard 3.0.4\n- JavaCard 3.0.5u1\n- JavaCard 3.1.0b43\n\n## Supported Java versions\n\nJava 8-u271 is the minimal version supported. \n\nMake sure you have up to date java version (`-u` version) as older java 8 versions\nhave problems with recognizing some certificates as valid.\n\nOnly some Java versions are supported by the JavaCard SDKs.\nCheck the following compatibility table for more info: \nhttps://github.com/martinpaljak/ant-javacard/wiki/Version-compatibility\n\n## Coverage\n\nThis is a nice benefit of the IntelliJ Idea - gives you coverage \nresults out of the box. \n\nYou can see the test coverage on your applet code.\n\n- Go to Gradle plugin in IntelliJ Idea\n- Tasks -\u003e verification -\u003e test\n- Right click - run with coverage.\n\nCoverage summary:\n![coverage summary](https://raw.githubusercontent.com/ph4r05/javacard-gradle-template/master/.github/image/coverage_summary.png)\n\nCoverage code:\n![coverage code](https://raw.githubusercontent.com/ph4r05/javacard-gradle-template/master/.github/image/coverage_class.png)\n\n## Troubleshooting\n\nIf you experience the following error: \n\n```\njava.lang.VerifyError: Expecting a stackmap frame at branch target 19\n    Exception Details:\n      Location:\n        javacard/framework/APDU.\u003cinit\u003e(Z)V @11: ifeq\n      Reason:\n        Expected stackmap frame at this location.\n```\n\nThen try running JVM with `-noverify` option.\n\nIn the IntelliJ Idea this can be configured in the top tool bar\nwith run configurations combo box -\u003e click -\u003e Edit Configurations -\u003e VM Options.\n\nHowever, the `com.klinec:jcardsim:3.0.5.11` should not need the `-noverify`.\n\n### Invalid APDU loaded\n\nYou may experience error like this: `Invalid APDU loaded. You may have JC API in your classpath before JCardSim. Classpath:`\n\nThis error is thrown by JCardSim which tries to load APDU class augmented with another methods. The augmented APDU version is contained in the JCardSim JAR.\nHowever, if `api_class.jar` from the JavaCard SDK is on the classpath before the JCardSim, this problem occurs. The classpath ordering causes non-augmented version is loaded which prevents JCardSim from correct function.\n\ngradle-javacard-plugin v1.7.4 should fix this error.\n\nIf you still experience this in IntelliJ Idea try: open project structure settings -\u003e modules -\u003e applet_test and move JCardSim to the top so it appears first on the classpath.\nThis has to be done with each project reload from the Gradle. \n\n## Roadmap\n\nTODOs for this project:\n\n- Polish Gradle build scripts\n- Add basic libraries as maven dependency.\n\n## Contributions\n\nCommunity feedback is highly appreciated - pull requests are welcome!\n\n\n\n[JCardSim]: https://jcardsim.org/\n[ant-javacard]: https://github.com/martinpaljak/ant-javacard\n[oracle_javacard_sdks]: https://github.com/martinpaljak/oracle_javacard_sdks\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fph4r05%2Fjavacard-gradle-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fph4r05%2Fjavacard-gradle-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fph4r05%2Fjavacard-gradle-template/lists"}