Skip to content

Commit efad8dc

Browse files
committed
Replace shell script by antrun maven plugin call
1 parent ff7d33f commit efad8dc

6 files changed

Lines changed: 109 additions & 42 deletions

File tree

.circleci/config.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ jobs:
2020

2121
# get dependencies
2222
- run:
23-
name: Get dependencies
24-
command: |
25-
curl -L https://get.web3j.io | bash
26-
source $HOME/.web3j/source.sh
27-
./get_dependencies.sh
23+
name: Get web3j
24+
command: curl -L https://get.web3j.io | bash
2825
# run tests!
2926
- run:
3027
name: Build and run tests
31-
command: mvn install
28+
command: |
29+
source $HOME/.web3j/source.sh
30+
mvn install
3231
- run:
3332
name: Upload coverage
3433
command: bash <(curl -s https://codecov.io/bash)

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010

1111
## How to build
1212

13-
Install dependencies for the first time:
13+
Install web3j for the first time:
1414
```
1515
curl -L https://get.web3j.io | bash
1616
source $HOME/.web3j/source.sh
17-
./get_dependencies.sh
1817
```
1918

2019
Build and test:

get_dependencies.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1212
<maven.compiler.source>1.8</maven.compiler.source>
1313
<maven.compiler.target>1.8</maven.compiler.target>
14+
<platform-contracts.version>0.3.4</platform-contracts.version>
15+
<snet-daemon.version>2.0.2</snet-daemon.version>
1416
<protobuf.version>3.5.1</protobuf.version>
1517
<grpc.version>1.20.0</grpc.version>
1618
</properties>
@@ -184,6 +186,11 @@
184186
<artifactId>exec-maven-plugin</artifactId>
185187
<version>1.4.0</version>
186188
</plugin>
189+
<plugin>
190+
<groupId>org.apache.maven.plugins</groupId>
191+
<artifactId>maven-antrun-plugin</artifactId>
192+
<version>1.6</version>
193+
</plugin>
187194
<!-- generated by maven -->
188195
<plugin>
189196
<artifactId>maven-clean-plugin</artifactId>

sdk/get-dependencies.xml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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>

sdk/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@
105105
</resources>
106106

107107
<plugins>
108+
109+
<plugin>
110+
<groupId>org.apache.maven.plugins</groupId>
111+
<artifactId>maven-antrun-plugin</artifactId>
112+
<executions>
113+
<execution>
114+
<id>get-dependencies</id>
115+
<phase>generate-sources</phase>
116+
<configuration>
117+
<target>
118+
<ant antfile="${project.basedir}/get-dependencies.xml"/>
119+
</target>
120+
</configuration>
121+
<goals>
122+
<goal>run</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
127+
108128
<plugin>
109129
<groupId>org.xolstice.maven.plugins</groupId>
110130
<artifactId>protobuf-maven-plugin</artifactId>

0 commit comments

Comments
 (0)