daparic
daparic

Reputation: 4474

Does Gradle / javacard plugin support the build of two applets dependency in a multi-project gradle build?

Does gradle mechanism or specifically its javacard plugin has a way to express the dependency wherein the build of one *.cap depends on another project's .exp.

I googled and found this PR where it seems the feature I am looking for is not yet supported by the plugin.

Currently, the way I build is by: ./gradlew proj01:convertJavacard proj02:convertJavacard. Wherein, I have to specify first the proj01:convertJavacard because it produced the .exp file needed by proj02. Currently, this works.

I asked here because I want to instead do the elegant-looking: ./gradlew convertJavacard.

In proj02/build.gradle I tried the below relevant section to express the dependency to proj01:

javacard {
    cap {
        dependencies {
            javacardExport files(rootDir.absolutePath + '/build/javacard/')
            compile files(rootDir.absolutePath + '/build/classes/java/main/')
            compile project(':proj01')
        }
    }
}

It did not produce the proj01 .exp file so the build dependency failed. The compile project(':proj01') dependency line seems it tried to do an equivalent of something like: ./gradlew proj01:assemble because it produced similar output with no .exp file. Hence, proj02 failed to build.

Any tips on how can I do the build by: ./gradlew convertJavacard ?

Upvotes: 1

Views: 164

Answers (1)

daparic
daparic

Reputation: 4474

I think I found a solution that works in a gradle way. And although, the gradle plugin is unable to resolve properly the dependency between the two javacard projects, the override mechanism of a gradle task allowed me to insert an additional dependency relation.

Here is the relevant portion of proj02/build.gradle that did the trick:

convertJavacard {
    dependsOn ":proj01:convertJavacard"
}

javacard {
    cap {
        dependencies {
            javacardExport files(rootDir.absolutePath + '/build/javacard/')
            compile files(rootDir.absolutePath + '/build/classes/java/main/')
            compile project(':proj01')
        }
    }
}

So in conclusion, the javacard plugin alone is unable to link 2 javacard projects. And the gradle task override mechanism came to the rescue.

Upvotes: 1

Related Questions