bertrandmartel / javacard-gradle-plugin

:key: Gradle plugin for JavaCard development
MIT License
32 stars 14 forks source link

Depend on another module #1

Closed biafra23 closed 7 years ago

biafra23 commented 7 years ago

How can I build an applet that depends on sources in a different module?

dependencies {
    compile project(':common')
} 

This works fine when running the applet in the simulator but cannot find symbols (in common) when building a cap file.

Alternatively: How do build a java card library with export files as a module in gradle?

bertrandmartel commented 7 years ago

Thanks for your feedback, in 1.5.3, I've added dependency with other modules

For instance with the following config :

applet module

apply plugin: 'javacard'

def packageAid = 'A0:00:00:01:51:41:43:4C'
def appletAid = 'A0:00:00:01:51:41:43:4C:00'

javacard {

    config {
        jckit '../oracle_javacard_sdks/jc221_kit'
        cap {
            packageName 'fr.bmartel.aram'
            version '0.1'
            aid packageAid
            output 'applet.cap'
            applet {
                className 'fr.bmartel.aram.AccessRuleMaster'
                aid appletAid
            }
            dependencies {
                remote 'fr.bmartel:gplatform:2.1.1'
            }
        }
    }
dependencies {
    compile project(':common')
}

common module

apply plugin: 'javacard'

def packageAid = '01:02:03:04:05:01'

javacard {

    config {
        jckit '../oracle_javacard_sdks/jc221_kit'
        cap {
            packageName 'fr.bmartel.common'
            version '0.1'
            aid packageAid
            output 'common.cap'
            verify false
        }
    }
}

dependencies {
    compile project(':common2')
}

common2 module

apply plugin: 'javacard'

def packageAid = '01:02:03:04:05:02'

javacard {

    config {
        jckit '../oracle_javacard_sdks/jc221_kit'
        cap {
            packageName 'fr.bmartel.aram'
            version '0.1'
            aid packageAid
            output 'common2.cap'
            verify false
        }
    }
}

Also note that if you have already exp/jar files, you can use dependencies under cap closure to include local or remote dependencies :

cap {
    packageName 'fr.bmartel.javacard'
    version '0.1'
    aid '01:02:03:04:05:06:07:08:0A'
    output 'applet2.cap'
    applet {
        className 'fr.bmartel.javacard.SomeOtherClass'
        aid '01:02:03:04:05:06:07:08:09:01:04'
    }
    dependencies {
        local {
            jar '/path/to/dependency.jar'
            exps '/path/to/expfolder'
        }
        remote 'fr.bmartel:gplatform:2.1.1'
    }
}