Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sol2java指定包名无效 #488

Open
beyondiary opened this issue Oct 8, 2021 · 2 comments
Open

sol2java指定包名无效 #488

beyondiary opened this issue Oct 8, 2021 · 2 comments
Assignees
Labels

Comments

@beyondiary
Copy link

beyondiary commented Oct 8, 2021

console2.8.0

执行以下命令,指定包名无效,生成的的java类所在包名固定为com

编译合约,后面指定一个Java的包名参数,可以根据实际项目路径指定包名

./sol2java.sh org.fisco.bcos.asset.contract

|-- java
| | com
| | |-- Asset.java
| | |-- Crypto.java
| | |-- HelloWorld.java
| | |-- KVTableTest.java
| | |-- ShaTest.java
| | |-- Table.java
| | `-- TableTest.java

@cyjseagull cyjseagull self-assigned this Oct 8, 2021
@cyjseagull cyjseagull added faq good first issue Good for newcomers labels Oct 8, 2021
@cyjseagull
Copy link
Contributor

最新的sol2java.sh改变了用法,具体可参考:

$ bash sol2java.sh -h
usage: Compile Solidity Tool:
 -h,--help
 -l,--libraries <arg>   [Optional] Set library address information built
                        into the solidity contract
                        eg:
                        --libraries lib1:lib1_address lib2:lib2_address
 -o,--output <arg>      [Optional] The file path of the generated java
                        code, default is contracts/sdk/java/
 -p,--package <arg>     [Optional] The package name of the generated java
                        code, default is com
 -s,--sol <arg>         [Optional] The solidity file path or the solidity
                        directory path, default is contracts/solidity/

指定路径和包名可以使用如下命令:

$ bash sol2java.sh -o tests -p org.fisco.bcos.asset.contract
*** Compile solidity TableTest.sol***
INFO: Compile for solidity TableTest.sol success.
*** Convert solidity to java  for TableTest.sol success ***

*** Compile solidity Crypto.sol***
INFO: Compile for solidity Crypto.sol success.
*** Convert solidity to java  for Crypto.sol success ***

*** Compile solidity KVTableTest.sol***
INFO: Compile for solidity KVTableTest.sol success.
*** Convert solidity to java  for KVTableTest.sol success ***

*** Compile solidity HelloWorld.sol***
INFO: Compile for solidity HelloWorld.sol success.
*** Convert solidity to java  for HelloWorld.sol success ***

*** Compile solidity Table.sol***
INFO: Compile for solidity Table.sol success.
*** Convert solidity to java  for Table.sol success ***

*** Compile solidity ShaTest.sol***
INFO: Compile for solidity ShaTest.sol success.
*** Convert solidity to java  for ShaTest.sol success ***

执行上面命令后,会在tests目录下生成java文件,对应的import的路径是package org.fisco.bcos.asset.contract;

$ find . -name "*.java"
./tests/org/fisco/bcos/asset/contract/Table.java
./tests/org/fisco/bcos/asset/contract/TableTest.java
./tests/org/fisco/bcos/asset/contract/ShaTest.java
./tests/org/fisco/bcos/asset/contract/HelloWorld.java
./tests/org/fisco/bcos/asset/contract/Crypto.java
./tests/org/fisco/bcos/asset/contract/KVTableTest.java

文档还没更新,稍后我们会同步更新文档。

1 similar comment
@cyjseagull
Copy link
Contributor

最新的sol2java.sh改变了用法,具体可参考:

$ bash sol2java.sh -h
usage: Compile Solidity Tool:
 -h,--help
 -l,--libraries <arg>   [Optional] Set library address information built
                        into the solidity contract
                        eg:
                        --libraries lib1:lib1_address lib2:lib2_address
 -o,--output <arg>      [Optional] The file path of the generated java
                        code, default is contracts/sdk/java/
 -p,--package <arg>     [Optional] The package name of the generated java
                        code, default is com
 -s,--sol <arg>         [Optional] The solidity file path or the solidity
                        directory path, default is contracts/solidity/

指定路径和包名可以使用如下命令:

$ bash sol2java.sh -o tests -p org.fisco.bcos.asset.contract
*** Compile solidity TableTest.sol***
INFO: Compile for solidity TableTest.sol success.
*** Convert solidity to java  for TableTest.sol success ***

*** Compile solidity Crypto.sol***
INFO: Compile for solidity Crypto.sol success.
*** Convert solidity to java  for Crypto.sol success ***

*** Compile solidity KVTableTest.sol***
INFO: Compile for solidity KVTableTest.sol success.
*** Convert solidity to java  for KVTableTest.sol success ***

*** Compile solidity HelloWorld.sol***
INFO: Compile for solidity HelloWorld.sol success.
*** Convert solidity to java  for HelloWorld.sol success ***

*** Compile solidity Table.sol***
INFO: Compile for solidity Table.sol success.
*** Convert solidity to java  for Table.sol success ***

*** Compile solidity ShaTest.sol***
INFO: Compile for solidity ShaTest.sol success.
*** Convert solidity to java  for ShaTest.sol success ***

执行上面命令后,会在tests目录下生成java文件,对应的import的路径是package org.fisco.bcos.asset.contract;

$ find . -name "*.java"
./tests/org/fisco/bcos/asset/contract/Table.java
./tests/org/fisco/bcos/asset/contract/TableTest.java
./tests/org/fisco/bcos/asset/contract/ShaTest.java
./tests/org/fisco/bcos/asset/contract/HelloWorld.java
./tests/org/fisco/bcos/asset/contract/Crypto.java
./tests/org/fisco/bcos/asset/contract/KVTableTest.java

文档还没更新,稍后我们会同步更新文档。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants