In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to use the Gradle plug-in in java, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Plug-in configuration
Before you begin, you need to install the Solidity compiler if it is not already installed on your computer.
Use the buildscript convention
To install the web3j plug-in using the old Gradle buildscript convention, add the following to the first line of the build file (currently only Gradle supports distributions, not SNAPSHOT):
Buildscript {repositories {mavenCentral ()} dependencies {classpath 'org.web3j:web3j-gradle-plugin:0.1.6'}} apply plugin:' web3j' uses the plug-in DSL
Or, if you are using the more modern plug-in DSL, add the following line to your build file:
Plugins {id 'org.web3j' version' 0.1.6'}
Then run the project that contains the Solidity smart contract:
. / gradlew build
After the plug-in is applied, the base directory where the code is generated (default is $buildDir/generated/source/web3j) will contain the directory for each source set (default is main and test), which contains the Java class of the smart contract wrapper.
Code generation
Web3j DSL allows you to configure the generated code, for example:
Web3j {generatedPackageName = 'com.mycompany. {0}' generatedFilesBaseDir = "$buildDir/custom/destination" excludedContracts = ['Ownable'] useNativeJavaTypes = false}
The properties accepted by DSL are shown in the following table:
GeneratedPackageName is evaluated as a message format string that accepts a single parameter between curly braces ({0}), allowing the resulting value to be formatted with the contract name. For convenience, when applied to a Java package name, it is converted to lowercase.
For example, if generatedPackageName is set to ${group}. {0} in a project with a group com.mycompany, the Solidity smart contract named MyToken.sol will be generated in the com.mycompany.mytoken package.
In addition, the default value contains the ${group} attribute, which corresponds to a group in the project (for example, com.mycompany). If the project does not define group properties, the generated package name will be org.web3j. {0}.
Note that the message format parameter is not a Gradle property and should not start with $.
Source Settin
By default, all .sol files in $projectDir/src/main/solidity are processed by the plug-in. To specify and add different sources, use sourceSets DSL:
SourceSets {main {solidity {srcDir {"my/custom/path/to/solidity"}
Check the Solidity Plugin documentation to configure the smart contract source code directory.
The output directory of the generated smart contract wrapper Java code will be automatically added to your build.
Plug-in task
The Java plug-in uses a naming convention based on each source (that is, compileJava,compileTestJava) to add tasks to the project build.
Similarly, the Solidity plug-in will add generateContractWrappers tasks to the main source of the project and generate [SourceSet] ContractWrappers for each remaining source, such as test.
To get a list and description of all added tasks, run the following command:
. / gradlew tasks-all on how to use the Gradle plug-in in java to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.