|
| 1 | +<project default="get-dependencies"> |
| 2 | + |
| 3 | + <target name="get-dependencies" depends="generate-contract-stubs,get-daemon-proto"/> |
| 4 | + |
| 5 | + <target name="check-contract-stubs"> |
| 6 | + <condition property="contract-stubs-present"> |
| 7 | + <and> |
| 8 | + <available file="${project.build.directory}/generated-sources/sol/java/io/singularitynet/sdk/contracts/MultiPartyEscrow.java"/> |
| 9 | + <available file="${project.build.directory}/generated-sources/sol/java/io/singularitynet/sdk/contracts/Registry.java"/> |
| 10 | + </and> |
| 11 | + </condition> |
| 12 | + <echo message="Check contracts presence: ${contract-stubs-present}"/> |
| 13 | + </target> |
| 14 | + |
| 15 | + <target name="generate-contract-stubs" depends="check-contract-stubs" unless="contract-stubs-present"> |
| 16 | + <echo message="Downloading SingularityNet contracts"/> |
| 17 | + <get src="https://registry.npmjs.org/singularitynet-platform-contracts/-/singularitynet-platform-contracts-${platform-contracts.version}.tgz" |
| 18 | + dest="${project.build.directory}/singularitynet-platform-contracts.tgz"/> |
| 19 | + <untar src="${project.build.directory}/singularitynet-platform-contracts.tgz" |
| 20 | + dest="${project.build.directory}" compression="gzip"/> |
| 21 | + <move file="${project.build.directory}/package" |
| 22 | + tofile="${project.build.directory}/singularitynet-platform-contracts"/> |
| 23 | + <mkdir dir="${project.build.directory}/resources"/> |
| 24 | + <move file="${project.build.directory}/singularitynet-platform-contracts/networks" |
| 25 | + todir="${project.build.directory}/resources"/> |
| 26 | + |
| 27 | + <!-- TODO: replace by direct call to the web3j java class used |
| 28 | + in web3j cli interface. Plugin would be better but it |
| 29 | + doesn't support generation from ABI json --> |
| 30 | + <echo message="Generating Java stubs for contracts"/> |
| 31 | + <exec executable="web3j"> |
| 32 | + <arg value="solidity"/> |
| 33 | + <arg value="generate"/> |
| 34 | + <arg value="-a"/> |
| 35 | + <arg value="${project.build.directory}/singularitynet-platform-contracts/abi/Registry.json"/> |
| 36 | + <arg value="--outputDir"/> |
| 37 | + <arg value="${project.build.directory}/generated-sources/sol/java"/> |
| 38 | + <arg value="--package"/> |
| 39 | + <arg value="io.singularitynet.sdk.contracts"/> |
| 40 | + </exec> |
| 41 | + <exec executable="web3j"> |
| 42 | + <arg value="solidity"/> |
| 43 | + <arg value="generate"/> |
| 44 | + <arg value="-a"/> |
| 45 | + <arg value="${project.build.directory}/singularitynet-platform-contracts/abi/MultiPartyEscrow.json"/> |
| 46 | + <arg value="--outputDir"/> |
| 47 | + <arg value="${project.build.directory}/generated-sources/sol/java"/> |
| 48 | + <arg value="--package"/> |
| 49 | + <arg value="io.singularitynet.sdk.contracts"/> |
| 50 | + </exec> |
| 51 | + </target> |
| 52 | + |
| 53 | + <target name="check-daemon-proto"> |
| 54 | + <condition property="daemon-proto-present"> |
| 55 | + <available file="${project.build.directory}/proto/state_service.proto"/> |
| 56 | + </condition> |
| 57 | + <echo message="Check deamon proto presence: ${daemon-proto-present}"/> |
| 58 | + </target> |
| 59 | + |
| 60 | + <target name="get-daemon-proto" depends="check-daemon-proto" unless="daemon-proto-present"> |
| 61 | + <echo message="Downloading snet-daemon API" /> |
| 62 | + <get src="https://github.com/singnet/snet-daemon/releases/download/v${snet-daemon.version}/snet-daemon-v${snet-daemon.version}-linux-amd64.tar.gz" |
| 63 | + dest="${project.build.directory}/snet-daemon.tar.gz"/> |
| 64 | + <untar src="${project.build.directory}/snet-daemon.tar.gz" |
| 65 | + dest="${project.build.directory}" compression="gzip"/> |
| 66 | + <move file="${project.build.directory}/snet-daemon-v${snet-daemon.version}-linux-amd64" |
| 67 | + tofile="${project.build.directory}/snet-daemon"/> |
| 68 | + <mkdir dir="${project.build.directory}/proto"/> |
| 69 | + <move file="${project.build.directory}/snet-daemon/proto/state_service.proto" |
| 70 | + todir="${project.build.directory}/proto" /> |
| 71 | + <!-- Next step should be removed when daemon v2.0.3 is released --> |
| 72 | + <echo message='option java_package = "io.singularitynet.daemon.escrow";' |
| 73 | + file="${project.build.directory}/proto/state_service.proto" append="true"/> |
| 74 | + </target> |
| 75 | + |
| 76 | +</project> |
0 commit comments