Web3j Gradle Plugin – Web3j Gradle插件区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Web3j Gradle Plugin – Web3j Gradle插件区块链毕设代写 是一篇很好的国外资料

Web3j Gradle Plugin

Gradle plugin that generates Web3j Java wrappers from Solidity smart contracts. It smoothly integrates with your project’s build lifecycle by adding specific tasks that can be also run independently.

Plugin configuration

To configure the Web3j Gradle Plugin using the plugins DSL or the legacy plugin application, check the plugin page. The minimum Gradle version to run the plugin is 5.+.

Then run your project containing Solidity contracts:

./gradlew build 

After applying the plugin, the base directory for generated code (by default $buildDir/generated/sources/web3j) will contain a directory for each source set (by default main and test) containing the smart contract wrappers Java classes.

Code generation

The web3j DSL allows to configure the generated code, e.g.:

web3j {     generatedPackageName = 'com.mycompany.{0}'     generatedFilesBaseDir = "$buildDir/custom/destination"     excludedContracts = ['Ownable']     useNativeJavaTypes = false }

The properties accepted by the DSL are listed in the following table:

Name Type Default value Description
generatedPackageName String ${group}.web3j or org.web3j.{0} Generated contract wrappers package.
generatedFilesBaseDir String $buildDir/generated/sources/web3j Generated Java code output directory.
excludedContracts String[] [] Excluded contract names from wrapper generation.
includedContracts String[] [] Included contract names from wrapper generation. Has preference over excludedContracts.
useNativeJavaTypes Boolean true Generate smart contract wrappers using native Java types.
addressBitLength int 160 Supported address length in bits, by default Ethereum addresses.

The generatedPackageName is evaluated as a message format string accepting a single parameter between curly brackets ({0}), allowing to format the generated value using the contract name. For convenience, when applied to a Java package name it will be converted to lower case.

For instance, a generatedPackageName set to ${group}.{0} in a project with group com.mycompany, a Solidity contract named MyToken.sol will be generated in the package com.mycompany.mytoken.

Also, the default value contains the ${group} property, which corresponds to your project artifact group (e.g. com.mycompany). If the project does not define a group property, the generated package name will be org.web3j.{0}.

Note that message format parameters are not Gradle properties and should not be preceded by $.

Source sets

By default, all .sol files in $projectDir/src/main/solidity will be processed by the plugin. To specify and add different source sets, use the sourceSets DSL:

sourceSets {     main {         solidity {             srcDir {                  "my/custom/path/to/solidity"               }         }     } }

Check the Solidity Plugin documentation to configure the smart contracts source code directories.

Output directories for generated smart contract wrappers Java code will be added to your build automatically.

Plugin tasks

The Java Plugin adds tasks to your project build using a naming convention on a per source set basis (i.e. compileJava, compileTestJava).

Similarly, the Solidity plugin will add the generateContractWrappers task for the project main source set, and a generate[SourceSet]ContractWrappers for each remaining source set (e.g. test).

To obtain a list and description of all added tasks, run the command:

./gradlew tasks --all 

We use cookies and similar technologies (“cookies”) to provide and secure our websites, as well as to analyze the usage of our websites, in order to offer you a great user experience. To learn more about our use of cookies see our Privacy Statement.

Select Accept all to consent to this use, Reject all to decline this use, or More info to control your cookie preferences. You can always update your selection by clicking Cookie Preferences at the bottom of the page.


Web3j Gradle Plugin

从Solidity智能合约生成web3jjava包装的Gradle插件。它通过添加也可以独立运行的特定任务与项目的构建生命周期顺利集成。

Plugin configuration

要使用插件DSL或旧插件应用程序配置Web3j Gradle插件,请查看插件页面。运行插件的最低版本是5。

然后运行包含Solidity契约的项目:

./gradlew build 

应用插件后,生成代码的基本目录(默认为$buildDir/generated/sources/web3j)将包含包含智能合约包装器Java类的每个源集(默认为main和test)的目录。

Code generation

web3j DSL允许配置生成的代码,例如:

web3j {     generatedPackageName = 'com.mycompany.{0}'     generatedFilesBaseDir = "$buildDir/custom/destination"     excludedContracts = ['Ownable']     useNativeJavaTypes = false }

DSL接受的属性列在下表中:

Name Type Default value Description
生成的合同包装程序包。 generatedFilesBaseDir String $buildDir/generated/sources/web3j
生成的Java代码输出目录。 排除合同 String[] []
从包装器生成中排除合同名称。 includedContracts String[] []
包装生成中包含的合同名称。优先于排除合同。 使用本机Java类型生成智能合约包装器。 地址位长度 int
160 支持的地址长度(位),默认为以太坊eth地址。 true Generate smart contract wrappers using native Java types.
addressBitLength int 160 Supported address length in bits, by default Ethereum addresses.

generatedPackageName被评估为一个消息格式字符串,接受大括号({0})之间的单个参数,允许使用协定名称格式化生成的值。为了方便起见,当应用于Java包名称时,它将被转换为小写。

例如,在有组的项目中,generatedPackageName设置为${group}.{0}com.mycompany公司一份名为我的令牌.sol将在包中生成com.mycompany.mytoken.

另外,默认值包含${group}属性,它对应于您的项目工件组(例如。com.mycompany公司). 如果项目未定义组属性,则生成的包名称将为网址:org.web3j{0}。

请注意,消息格式参数不是渐变属性,不应以$开头。

Source sets

默认情况下,$projectDir/src/main/solidity中的所有.sol文件都将由插件处理。要指定和添加不同的源代码集,请使用sourceSets DSL:

sourceSets {     main {         solidity {             srcDir {                  "my/custom/path/to/solidity"               }         }     } }

查看Solidity插件文档以配置智能合约源代码目录。

生成的智能合约包装器的输出目录Java代码将自动添加到您的构建中。

Plugin tasks

Java插件使用基于每个源集的命名约定(即compileJava、compileTestJava)将任务添加到项目构建中。

类似地,Solidity插件将为项目主源集添加generateContractWrappers任务,并为每个剩余的源集(例如test)添加generate[SourceSet]ContractWrappers。

要获取所有添加任务的列表和说明,请运行以下命令:

./gradlew tasks --all 

我们使用cookies和类似技术(“cookies”)来提供和保护我们的网站,以及分析我们网站的使用情况,以便为您提供出色的用户体验。要了解更多有关cookies使用的信息,请参阅我们的隐私声明。

选择“全部接受”以同意此使用,选择“全部拒绝”以拒绝此使用,或选择“更多信息”以控制cookie首选项。您可以随时通过单击页面底部的Cookie首选项来更新您的选择。

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/17811.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 !
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Web3j Gradle Plugin – Web3j Gradle插件区块链毕设代写

提供最优质的资源集合

立即查看 了解详情