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

Support JCSDK env var to choose which SDK to use #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ language: java
jdk:
- oraclejdk8

# uncomment the applicable lines if wanting to test all applet-supported SDKs
# env:
# the first one is to test the usage of a default SDK
# -
# - JCSDK=jc212
# - JCSDK=jc221
# - JCSDK=jc222
# - JCSDK=jc303
# - JCSDK=jc304
# - JCSDK=jc305u1

script:
- ./gradlew check --info
- ./gradlew buildJavaCard --info
Expand Down
33 changes: 23 additions & 10 deletions applet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,34 @@ test {
}

// JavaCard SDKs and libraries
final def JC212 = libsSdk + '/jc212_kit'
final def JC221 = libsSdk + '/jc221_kit'
final def JC222 = libsSdk + '/jc222_kit'
final def JC303 = libsSdk + '/jc303_kit'
final def JC304 = libsSdk + '/jc304_kit'
final def JC305 = libsSdk + '/jc305u1_kit'
final def JC212 = 'jc212'
final def JC221 = 'jc221'
final def JC222 = 'jc222'
final def JC303 = 'jc303'
final def JC304 = 'jc304'
final def JC305 = 'jc305u1'

// Which JavaCard SDK to use - select
final def JC_SELECTED = JC304
// Which JavaCard SDK can be used
final def JC_ENABLED = [
JC222, JC303, JC304, JC305
]

// Which JavaCard SDK to use by default
def JC_SELECTED = JC222

// Check if user wants to compile with a specific enabled JavaCard SDK
final def JCSDK = System.getenv('JCSDK')
if (JCSDK in JC_ENABLED) {
JC_SELECTED = JCSDK
} else if (JCSDK) {
throw new InvalidUserDataException("JCSDK environment variable is set to an SDK not available for this project")
}

javacard {

//noinspection GroovyAssignabilityCheck
config {
jckit JC_SELECTED
jckit "${libsSdk}/${JC_SELECTED}_kit"

// JCardSim automatically added by the javacard-gradle plugin
addSurrogateJcardSimRepo true
Expand All @@ -69,7 +82,7 @@ javacard {
packageName 'applet'
version '0.1'
aid '01:02:03:04:05:06:07:08:09'
output 'applet.cap'
output "${JC_SELECTED}_applet.cap"

//noinspection GroovyAssignabilityCheck
applet {
Expand Down