{"id":19901901,"url":"https://github.com/hyperledger-web3j/web3j-maven-plugin","last_synced_at":"2025-03-12T23:07:32.911Z","repository":{"id":38083786,"uuid":"91747262","full_name":"hyperledger-web3j/web3j-maven-plugin","owner":"hyperledger-web3j","description":"web3j Maven plugin","archived":false,"fork":false,"pushed_at":"2025-02-14T07:58:25.000Z","size":317,"stargazers_count":122,"open_issues_count":33,"forks_count":84,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-03-01T19:07:09.480Z","etag":null,"topics":["blockchain","ethereum","java","maven-plugin","solidity","solidity-contracts","web3j"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperledger-web3j.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-18T23:49:21.000Z","updated_at":"2025-02-19T02:04:14.000Z","dependencies_parsed_at":"2024-02-20T20:25:57.982Z","dependency_job_id":"c2bff73e-085b-425f-abbe-7c379e214ac5","html_url":"https://github.com/hyperledger-web3j/web3j-maven-plugin","commit_stats":null,"previous_names":["hyperledger/web3j-maven-plugin","hyperledger-web3j/web3j-maven-plugin"],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-web3j%2Fweb3j-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-web3j%2Fweb3j-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-web3j%2Fweb3j-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger-web3j%2Fweb3j-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperledger-web3j","download_url":"https://codeload.github.com/hyperledger-web3j/web3j-maven-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243307489,"owners_count":20270262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","ethereum","java","maven-plugin","solidity","solidity-contracts","web3j"],"created_at":"2024-11-12T20:16:33.594Z","updated_at":"2025-03-12T23:07:32.886Z","avatar_url":"https://github.com/hyperledger-web3j.png","language":"Java","readme":"# web3j-maven-plugin\n[![build status](https://github.com/web3j/web3j-maven-plugin/actions/workflows/maven.yml/badge.svg)](https://github.com/web3j/web3j-maven-plugin/actions/workflows/maven.yml)\n[![codecov](https://codecov.io/gh/web3j/web3j-maven-plugin/branch/master/graph/badge.svg?token=Ar7tgwmUEz)](https://codecov.io/gh/web3j/web3j-maven-plugin)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nweb3j maven plugin is used to create java classes based on the solidity contract files.\n\n## Usage\nThe base configuration for the plugin will take the solidity files from `src/main/resources` and generates \nthe java classes into the folder `src/main/java`.\n\n```xml\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003eorg.web3j\u003c/groupId\u003e\n            \u003cartifactId\u003eweb3j-maven-plugin\u003c/artifactId\u003e\n            \u003cversion\u003e4.13.0\u003c/version\u003e\n            \u003cconfiguration\u003e\n                \u003csoliditySourceFiles/\u003e\n            \u003c/configuration\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\nto run the plugin execute the goal `generate-sources`\n```bash\nmvn web3j:generate-sources\n```\n\n\n## Configuration\nThe are several variable to select the solidity source files, define a source destination path or change the package name.\n\n| Name                   | Format                                                                                 | Default value                   |\n| -----------------------|----------------------------------------------------------------------------------------| --------------------------------|\n| `\u003cpackageName/\u003e`       | valid java package name                                                                | `org.web3j.model`               |\n| `\u003coutputDirectory\u003e\u003cjava/\u003e\u003c/outputDirectory\u003e` | relative or absolute path of the generated for 'Java files       | value in `\u003csourceDestination/\u003e` |\n| `\u003coutputDirectory\u003e\u003cbin/\u003e\u003c/outputDirectory\u003e`  | relative or absolute path of the generated for 'Bin' files       | value in `\u003csourceDestination/\u003e` |\n| `\u003coutputDirectory\u003e\u003cabi/\u003e\u003c/outputDirectory\u003e`  | relative or absolute path of the generated for 'ABI' files       | value in `\u003csourceDestination/\u003e` |\n| `\u003csourceDestination/\u003e` | relative or absolute path of the generated files (java, bin, abi)                      | `src/main/java`                 |\n| `\u003coutputFormat/\u003e`      | generate Java Classes(`java`), ABI(`abi`) and/or BIN (`bin`) Files (comma separated)   | `java`                          |\n| `\u003cnativeJavaType/\u003e`    | Creates Java Native Types (instead of Solidity Types)                                  | `true`                          |\n| `\u003coutputJavaParentContractClassName/\u003e` | Sets custom(? extends org.web3j.tx.Contract) class as a parent for java generated code | `org.web3j.tx.Contract` |\n| `\u003csoliditySourceFiles\u003e`| Standard maven [fileset](https://maven.apache.org/shared/file-management/fileset.html) | `\u003csoliditySourceFiles\u003e`\u003cbr\u003e`  \u003cdirectory\u003esrc/main/resources\u003c/directory\u003e`\u003cbr\u003e`  \u003cincludes\u003e`\u003cbr\u003e`    \u003cinclude\u003e**/*.sol\u003c/include\u003e`\u003cbr\u003e`  \u003c/includes\u003e`\u003cbr\u003e`\u003c/soliditySourceFiles\u003e`  |\n| `\u003cabiSourceFiles\u003e`     | Standard maven [fileset](https://maven.apache.org/shared/file-management/fileset.html) | `\u003cabiSourceFiles\u003e`\u003cbr\u003e`  \u003cdirectory\u003esrc/main/resources\u003c/directory\u003e`\u003cbr\u003e`  \u003cincludes\u003e`\u003cbr\u003e`    \u003cinclude\u003e**/*.json\u003c/include\u003e`\u003cbr\u003e`  \u003c/includes\u003e`\u003cbr\u003e`\u003c/abiSourceFiles\u003e`           |\n| `\u003ccontract\u003e`           | Filter (`\u003cinclude\u003e` or `\u003cexclude\u003e`) contracts based on the name.                       | `\u003ccontract\u003e`\u003cbr\u003e`  \u003cincludes\u003e`\u003cbr\u003e`    \u003cinclude\u003egreeter\u003c/include\u003e`\u003cbr\u003e`  \u003c/includes\u003e`\u003cbr\u003e`  \u003cexcludes\u003e`\u003cbr\u003e`    \u003cexclude\u003emortal\u003c/exclude\u003e`\u003cbr\u003e`  \u003cexcludes\u003e`\u003cbr\u003e`\u003c/contracts\u003e`  |\n| `\u003cpathPrefixes\u003e`       | A list (`\u003cpathPrefixe\u003e`) of replacements of dependency replacements inside Solidity contract.  |  |\n\nConfiguration of `outputDirectory` has priority over `sourceDestination`\n\n\n## Getting Started\n\nCreate a standard java maven project. Add following `\u003cplugin\u003e` - configuration into the `pom.xml` file:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003eorg.web3j\u003c/groupId\u003e\n    \u003cartifactId\u003eweb3j-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e4.13.0\u003c/version\u003e\n    \u003cconfiguration\u003e\n        \u003cpackageName\u003ecom.zuehlke.blockchain.model\u003c/packageName\u003e\n        \u003csourceDestination\u003esrc/main/java/generated\u003c/sourceDestination\u003e\n        \u003cnativeJavaType\u003etrue\u003c/nativeJavaType\u003e\n        \u003coutputFormat\u003ejava,bin\u003c/outputFormat\u003e\n        \u003csoliditySourceFiles\u003e\n            \u003cdirectory\u003esrc/main/resources\u003c/directory\u003e\n            \u003cincludes\u003e\n                \u003cinclude\u003e**/*.sol\u003c/include\u003e\n            \u003c/includes\u003e\n        \u003c/soliditySourceFiles\u003e\n        \u003cabiSourceFiles\u003e\n            \u003cdirectory\u003esrc/main/resources\u003c/directory\u003e\n            \u003cincludes\u003e\n                \u003cinclude\u003e**/*.json\u003c/include\u003e\n            \u003c/includes\u003e\n        \u003c/abiSourceFiles\u003e\n        \u003coutputDirectory\u003e\n            \u003cjava\u003esrc/java/generated\u003c/java\u003e\n            \u003cbin\u003esrc/bin/generated\u003c/bin\u003e\n            \u003cabi\u003esrc/abi/generated\u003c/abi\u003e\n        \u003c/outputDirectory\u003e\n        \u003ccontract\u003e\n            \u003cincludes\u003e\n                \u003cinclude\u003egreeter\u003c/include\u003e\n            \u003c/includes\u003e\n            \u003cexcludes\u003e\n                \u003cexclude\u003emortal\u003c/exclude\u003e\n            \u003c/excludes\u003e\n        \u003c/contract\u003e\n        \u003cpathPrefixes\u003e\n            \u003cpathPrefix\u003edep=../dependencies\u003c/pathPrefix\u003e\n        \u003c/pathPrefixes\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\nAdd your solidity contract files into the folder `src/main/resources`. Make sure that the solidity files \nends with `.sol`.\n\n\nStart the generating process:\n\n\n```\n\u003e mvn web3j:generate-sources\n\n[INFO] --- web3j-maven-plugin:4.3.0:generate-sources (default-cli) @ hotel-showcase ---\n[INFO] process 'HotelShowCaseProxy.sol'\n[INFO] \tBuilt Class for contract 'HotelShowCaseProxy'\n[INFO] \tBuilt Class for contract 'HotelShowCaseV2'\n[INFO] \tBuilt Class for contract 'Owned'\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD SUCCESS\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 4.681 s\n[INFO] Finished at: 2017-06-13T07:07:04+02:00\n[INFO] Final Memory: 14M/187M\n[INFO] ------------------------------------------------------------------------\n\nProcess finished with exit code 0\n```\n\nYou find the generated java classes inside the directory `src/main/java/generated/`.\n\nNext step is to interact with the smart contract. See for that \n[deploying and interacting with smart contracts](https://web3j.readthedocs.io/en/latest/smart_contracts.html#deploying-and-interacting-with-smart-contracts) \nin the official web3j documentation.\n\nFor a multi module project configuration see following [post](https://github.com/web3j/web3j-maven-plugin/issues/14) \nfrom [@fcorneli](https://github.com/fcorneli). In short:  For pick up the generated java source \nfiles, you need the build-helper-maven-plugin configuration. Also, `${basedir}` prefix is required \nwithin a multi-module project.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger-web3j%2Fweb3j-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperledger-web3j%2Fweb3j-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger-web3j%2Fweb3j-maven-plugin/lists"}