Skip to content

Commit 6c8abf4

Browse files
committed
[FAB-9416]: Add gradle task to update protos
This commit adds new gradle task to download update proto files required by project (currently handled manually). Hence allowing to run following command to get updates: gradle :fabric-chaincode-protos:downloadProtoFiles which will download all depencies *.proto into project sub folder to get them compiled. Change-Id: Iac03e08214667b0af42b13741e959f70b8a50a2b Signed-off-by: Artem Barger <bartem@il.ibm.com>
1 parent e3be99e commit 6c8abf4

File tree

8 files changed

+28
-2
lines changed

8 files changed

+28
-2
lines changed

fabric-chaincode-protos/build.gradle

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,35 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
76
apply plugin: 'com.google.protobuf'
7+
apply plugin: 'de.undercouch.download'
88

99
repositories {
1010
maven { url "https://plugins.gradle.org/m2/" }
11+
jcenter()
1112
}
1213

14+
// Fabric branch to download proto files from
15+
def fabricBranch = 'release-1.1'
16+
// Fabric Github repository link
17+
def fabricRepo = 'https://raw.githubusercontent.com/hyperledger/fabric'
18+
def protosDir = 'src/main/protos'
19+
// List of files to download
20+
def protoFiles = ['protos/common/common.proto' : "$protosDir/common/common.proto",
21+
'protos/ledger/queryresult/kv_query_result.proto': "$protosDir/ledger/queryresult/kv_query_result.proto",
22+
'protos/peer/chaincode.proto' : "$protosDir/peer/chaincode.proto",
23+
'protos/peer/chaincode_event.proto' : "$protosDir/peer/chaincode_event.proto",
24+
'protos/peer/chaincode_shim.proto' : "$protosDir/peer/chaincode_shim.proto",
25+
'protos/peer/proposal.proto' : "$protosDir/peer/proposal.proto",
26+
'protos/peer/proposal_response.proto' : "$protosDir/peer/proposal_response.proto"]
27+
1328
buildscript {
1429
repositories {
1530
maven { url "https://plugins.gradle.org/m2/" }
1631
}
1732
dependencies {
1833
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5'
34+
classpath 'de.undercouch:gradle-download-task:3.4.2'
1935
}
2036
}
2137

@@ -54,7 +70,17 @@ sourceSets {
5470
srcDirs = ['src/main/java', 'src/main/grpc']
5571
}
5672
proto {
57-
srcDirs 'src/main/proto'
73+
srcDirs 'src/main/protos'
74+
}
75+
}
76+
}
77+
78+
task downloadProtoFiles << {
79+
protoFiles.each { k, v ->
80+
download {
81+
src "$fabricRepo/$fabricBranch/$k"
82+
dest v
83+
onlyIfModified true
5884
}
5985
}
6086
}

fabric-chaincode-protos/src/main/proto/common/common.proto renamed to fabric-chaincode-protos/src/main/protos/common/common.proto

File renamed without changes.

fabric-chaincode-protos/src/main/proto/ledger/queryresult/kv_query_result.proto renamed to fabric-chaincode-protos/src/main/protos/ledger/queryresult/kv_query_result.proto

File renamed without changes.

fabric-chaincode-protos/src/main/proto/peer/chaincode.proto renamed to fabric-chaincode-protos/src/main/protos/peer/chaincode.proto

File renamed without changes.

fabric-chaincode-protos/src/main/proto/peer/chaincode_event.proto renamed to fabric-chaincode-protos/src/main/protos/peer/chaincode_event.proto

File renamed without changes.

fabric-chaincode-protos/src/main/proto/peer/chaincode_shim.proto renamed to fabric-chaincode-protos/src/main/protos/peer/chaincode_shim.proto

File renamed without changes.

fabric-chaincode-protos/src/main/proto/peer/proposal.proto renamed to fabric-chaincode-protos/src/main/protos/peer/proposal.proto

File renamed without changes.

fabric-chaincode-protos/src/main/proto/peer/proposal_response.proto renamed to fabric-chaincode-protos/src/main/protos/peer/proposal_response.proto

File renamed without changes.

0 commit comments

Comments
 (0)