Corda RPC客户端外部依赖

huangapple go评论72阅读模式
英文:

Corda RPC client external dependencies

问题

假设我有一个用于 Corda 的小型 RPC 客户端应用程序,应该上传到节点并被调用以在节点上执行一些实用工作。
在我的实用 RPC 客户端的 build.gradle 文件中,我只有以下依赖项 cordaCompile "$corda_release_group:corda-rpc:$corda_release_version",而我的 JAR 任务如下所示:

jar {
    version = ''''
    baseName = ''rpc_utility''
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    manifest {
        attributes ''Main-Class': ''com.example.rpcclient.MainKt''
    }
    zip64 = true

    from { (configurations.compile).collect { it.isDirectory() ? it : zipTree(it) } }
}

但是,当我创建我的 JAR 文件时,它会生成一个大小为 58 MB 的 JAR 文件,其中包含 Corda 的所有依赖项,这些依赖项已经存在于节点内,打包在 corda.jar 文件中。 Cordapps 可以在不将这些库包含在其JAR文件中的情况下使用它们。

现在的问题是,我应该如何配置我的 JAR 任务,以及应该包含什么内容,以告诉Java它所需的所有依赖项都在同一文件夹中的 corda.jar 文件中。

P.S. 我还尝试过创建一个类似于现在的 fat JAR,然后使用 Proguard 进行缩减,但即使在长长的 Proguard 规则列表之后,我仍然会遇到错误,因为 Proguard 似乎会删除 Corda 需要的许多文件,所以这似乎不是一个好的解决方案,即使成功了,我也会得到一个大约 20 MB 的文件,其中只有几行真正的代码...

英文:

Suppose I have a small RPC client application for corda, which should be uploaded into node, and be called to do some utility work on node.
In build.gradle file of my utility RPC client I have just the following dependency cordaCompile "$corda_release_group:corda-rpc:$corda_release_version" and my JAR task looks like this

jar {
    version = ''
    baseName = 'rpc_utility'
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    manifest {
        attributes 'Main-Class': 'com.example.rpcclient.MainKt'
    }
    zip64=true

    from { (configurations.compile).collect { it.isDirectory() ? it : zipTree(it) } } 
}

but when I create my jar, it results in 58 MB Jar file, with all the dependencies of Corda in it, which are already there inside the node, packed in the corda.jar file. And cordapps can use these libraries without having them inside their JAR files.

Now the question is, how should I configure my jar task and what should I include inside it to tell Java that all the dependencies it needs are right there, in the same folder inside corda.jar file.

P.S. I also tried to create a fat jar like I do now, and then minify it with Proguard, but even after a long proguard-rules list I still have errors, as Proguard seems to remove a lot of files that Corda needs, so this seems to be not a good solution, and even if I succeed, I will get a ~20 MB file, just for a few lines of code that I have in real...

答案1

得分: 1

客户端的JAR包大小适中。它不仅包含了Corda的依赖,还包括了您实际的CorDapp JAR包(合约和工作流)。原因是:

  1. RPC客户端需要与Corda节点通信,因此需要Corda的依赖。
  2. 它还需要理解您的CorDapp,因为您的控制器将直接调用流程。
英文:

The client jar is about the right size. It not only includes the dependencies for Corda but also includes your actual CorDapp jars as well (Contract & workflows). The reason is that the:

  1. RPC client needs to talk to the Corda node, so it needs the Corda dependencies.
  2. It also needs to understand your CorDapps as your controller will invoke the flow directly.

huangapple
  • 本文由 发表于 2020年7月27日 02:45:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/63104264.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定