github-af / SmartPGP

SmartPGP is a JavaCard implementation of the OpenPGP card specifications
GNU General Public License v2.0
227 stars 47 forks source link

Use bertrandmartel/gradle-javacard instead of fidesmo/gradle-javacard #14

Closed dschuermann closed 3 years ago

dschuermann commented 5 years ago

bertrandmartel/gradle-javacard is a wrapper around the ant plugin, thus the output of ant and gradle is more consistent

af-anssi commented 5 years ago

Any gradle command fails with the message "Invalid JavaCard SDK path : use JC_HOME or jckit" while I set correctly the JC_HOME variable. The ant command is working correctly. I don't find any useful information in the gradle stack trace...

dschuermann commented 5 years ago

Hmm, weird. I used https://github.com/martinpaljak/oracle_javacard_sdks as follows:

schuerm@apep:~/Cotech/dev/smartcard-dev/SmartPGP$ gradle buildJavaCard

FAILURE: Build failed with an exception.

* What went wrong:                                                                                                                                                                                                          
A problem occurred configuring root project 'SmartPGP'.                                                                                                                                                                     
> Invalid JavaCard SDK path : use JC_HOME or jckit                                                                                                                                                                          

* Try:                                                                                                                                                                                                                       
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.                                                                                                               

BUILD FAILED

Total time: 0.72 secs
schuerm@apep:~/Cotech/dev/smartcard-dev/SmartPGP$ export JC_HOME="/home/schuerm/Cotech/dev/smartcard-dev/oracle_javacard_sdks/jc304_kit/"
schuerm@apep:~/Cotech/dev/smartcard-dev/SmartPGP$ gradle buildJavaCard
:buildJavaCard
[ant:cap] INFO: using JavaCard v3.0.4 SDK in /home/schuerm/Cotech/dev/smartcard-dev/oracle_javacard_sdks/jc304_kit
[ant:cap] Building CAP with 1 applet from package fr.anssi.smartpgp
[ant:cap] fr.anssi.smartpgp.SmartPGPApplet D276000124010303AFAF000000000000
[ant:compile] Compiling 13 source files to /tmp/jccpro7055289149264793766
[ant:convert] [ INFO: ] Converter [v3.0.4]
[ant:convert] [ INFO: ]     Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
[ant:convert]     
[ant:convert]     
[ant:convert] [ INFO: ] conversion completed with 0 errors and 0 warnings.
[ant:cap] CAP saved to /home/schuerm/Cotech/dev/smartcard-dev/SmartPGP/build/javacard/SmartPGPApplet.cap
[ant:exp] EXP saved to /home/schuerm/Cotech/dev/smartcard-dev/SmartPGP/build/javacard/SmartPGPApplet.exp/fr/anssi/smartpgp/javacard/smartpgp.exp
[ant:jca] JCA saved to /home/schuerm/Cotech/dev/smartcard-dev/SmartPGP/build/javacard/SmartPGPApplet.jca
[ant:verify] Nov 06, 2018 3:47:49 PM  
[ant:verify] INFO: Verifier [v3.0.4]
[ant:verify] Nov 06, 2018 3:47:49 PM  
[ant:verify] INFO:     Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
[ant:verify]     
[ant:verify]     
[ant:verify] Nov 06, 2018 3:47:49 PM  
[ant:verify] INFO: Verifying CAP file /home/schuerm/Cotech/dev/smartcard-dev/SmartPGP/build/javacard/SmartPGPApplet.cap
[ant:verify] Nov 06, 2018 3:47:49 PM  
[ant:verify] INFO: Verification completed with 0 warnings and 0 errors.

BUILD SUCCESSFUL

Total time: 2.87 secs
dschuermann commented 5 years ago

I am using gradle 3.2.1 in Debian stable.

af-anssi commented 5 years ago

I just checked with @martinpaljak SDKs and I get the same error, with any of the methods described here to set the path. I use gradle 4.4.1, so I think it is the cause of the problem. Maybe @bertrandmartel could help solve this issue ?

dschuermann commented 5 years ago

That sounds like the issue, they downgraded their gradle wrapper here: https://github.com/bertrandmartel/javacard-gradle-plugin/commit/fc356dc776c3fcabad3930f45d03d651c8dddf68 but without explanations.

bertrandmartel commented 5 years ago

The issue seems to be JavaCard SDK path. The easiest way is to add a submodule to https://github.com/martinpaljak/oracle_javacard_sdks and include a gradle wrapper file (generated with gradle wrapper) this way everyone has the same configuration (and much easier to build on a CI service). I don't think there is an issue with the gradle version I have v4.6 on my side

I've forked your project (your fork of SmartPGP) and included the modif above here:

git clone git@github.com:bertrandmartel/SmartPGP.git
cd SmartPGP
git submodule update --init
./gradlew buildJavaCard
bertrandmartel commented 5 years ago

also the reason for why I downgraded gradle from 4.1 to 3.3 was that gradle plugin API had some changes between thoses 2 version and I had difficulties to work on new gradle 4.1 version (at that time) to work with both Android Studio (for SIM development) & IntellIJ (both IDE have different behaviour dealing with gradle plugin)

You can find below 3 projects using the javacard-gradle-plugin :

https://github.com/bertrandmartel/aram-applet https://github.com/bertrandmartel/javacard-tutorial https://github.com/bertrandmartel/sim-password-wallet (Android)

af-anssi commented 5 years ago

Setting the jckit in the build.gradle with a full path to locally installed JCDK is actually working; the JC_HOME environment variable is not. I would prefer to have the JC_HOME environment variable solution because it does not require to modify a file tracked by git and it does not require an additional submodule.

bertrandmartel commented 5 years ago

@af-anssi I've just removed the jckit in the build.gradle and uses :

export JC_HOME="$PWD/oracle_javacard_sdks/jc304_kit"
./gradlew buildJavaCard

and it's working for me. How are you setting the JC_HOME variable? Note that the JC_HOME path needs to be absolute

af-anssi commented 5 years ago

With the jckit in the build.gradle it works with gradle 4.4.1, but not with the environment variable set as depicted above.

af-anssi commented 3 years ago

Gradle build is not supported anymore.