Skip to content

Commit 8c933d8

Browse files
committed
Allow building for tests without JC SDK
1 parent 392f4b6 commit 8c933d8

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

build.gradle

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ buildscript {
55
}
66
}
77

8+
89
plugins {
910
id("java")
10-
id("com.klinec.gradle.javacard") version "1.8.0"
11+
id("com.klinec.gradle.javacard") version "1.8.0" apply false
12+
}
13+
14+
var jcHomeSet = System.getenv("JC_HOME") != null
15+
if (!jcHomeSet) {
16+
project.logger.warn("JC_HOME environment variable not set - doing a testing/fake build with jCardSim!")
17+
project.logger.warn("YOU WILL NOT BE ABLE TO BUILD A JAVACARD APPLET THIS WAY")
1118
}
1219

1320
group = "us.q3q"
@@ -18,9 +25,14 @@ repositories {
1825
}
1926

2027
dependencies {
21-
testImplementation(group: 'com.klinec', name: 'jcardsim', version: '3.0.5.11') {
22-
// Javacard will be provided by the user at runtime through the JC_HOME env var
23-
exclude(group: 'oracle.javacard', module: 'api_classic')
28+
if (jcHomeSet) {
29+
testImplementation(group: 'com.klinec', name: 'jcardsim', version: '3.0.5.11') {
30+
// Javacard will be provided by the user at runtime through the JC_HOME env var
31+
exclude(group: 'oracle.javacard', module: 'api_classic')
32+
}
33+
} else {
34+
// Perform a full-test build, since there's no javacard SDK
35+
implementation(group: 'com.klinec', name: 'jcardsim', version: '3.0.5.11')
2436
}
2537
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.1'
2638

@@ -44,16 +56,19 @@ tasks.register('testJar', Jar) {
4456
}
4557
}
4658

47-
javacard {
48-
config {
49-
cap {
50-
packageName 'us.q3q.fido2'
51-
version '0.1'
52-
aid 'A0:00:00:06:47'
53-
output 'FIDO2.cap'
54-
applet {
55-
className 'us.q3q.fido2.FIDO2Applet'
56-
aid 'A0:00:00:06:47:2F:00:01'
59+
if (jcHomeSet) {
60+
apply plugin: "com.klinec.gradle.javacard"
61+
javacard {
62+
config {
63+
cap {
64+
packageName 'us.q3q.fido2'
65+
version '0.1'
66+
aid 'A0:00:00:06:47'
67+
output 'FIDO2.cap'
68+
applet {
69+
className 'us.q3q.fido2.FIDO2Applet'
70+
aid 'A0:00:00:06:47:2F:00:01'
71+
}
5772
}
5873
}
5974
}

0 commit comments

Comments
 (0)