github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/core/chaincode/shim/java/build.gradle (about)

     1  /*
     2  Copyright DTCC, IBM 2016, 2017 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8           http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  buildscript {
    18      repositories {
    19          mavenLocal()
    20          mavenCentral()
    21          jcenter()
    22      }
    23      dependencies {
    24          classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.0'
    25      }
    26  }
    27  
    28  plugins {
    29      id "java"
    30      id "com.google.protobuf" version "0.8.0"
    31      id "eclipse"
    32      id "maven-publish"
    33  
    34  }
    35  archivesBaseName = 'shim-client'
    36  version = '1.0'
    37  
    38  
    39  sourceSets {
    40      main {
    41          java {
    42              srcDir 'src/main/java'
    43          }
    44          proto {
    45              srcDir 'src/main/proto'
    46          }
    47      }
    48  }
    49  
    50  repositories {
    51      mavenLocal()
    52      mavenCentral()
    53  }
    54  
    55  apply plugin: "com.google.osdetector"
    56  
    57  def tcnative_classifier = osdetector.classifier;
    58  
    59  protobuf {
    60      generatedFilesBaseDir = "$projectDir/src"
    61      protoc {
    62          artifact = 'com.google.protobuf:protoc:3.0.0'
    63      }
    64      plugins {
    65          grpc {
    66              artifact = 'io.grpc:protoc-gen-grpc-java:0.13.2'
    67          }
    68      }
    69      generateProtoTasks {
    70          all().each { task ->
    71              task.builtins {
    72                  java {
    73                      outputSubDir = 'java'
    74                  }
    75              }
    76              task.plugins {
    77                  grpc {
    78                  outputSubDir = 'java'
    79                  }
    80              }
    81          }
    82      }
    83  }
    84  
    85  task copyToLib(type: Copy) {
    86      into "$buildDir/libs"
    87      from configurations.runtime
    88  }
    89  
    90  
    91  task copyProtos(type:Copy){
    92      into "peer", {
    93          from ("${rootDir}/protos/peer"){
    94              include 'chaincode_event.proto'
    95              include 'chaincode.proto'
    96              include 'chaincode_shim.proto'
    97              include 'proposal.proto'
    98              include 'proposal_response.proto'
    99          }
   100      }
   101      into "common", {
   102          from ("${rootDir}/protos/common"){
   103              include 'common.proto'
   104          }
   105      }
   106      into "${projectDir}/src/main/proto"
   107  }
   108  
   109  task copyProtosFromDevEnv(type:Copy){
   110      into "peer", {
   111          from ("../../../../protos/peer"){
   112              include 'chaincode_event.proto'
   113              include 'chaincode.proto'
   114              include 'chaincode_shim.proto'
   115              include 'proposal.proto'
   116              include 'proposal_response.proto'
   117          }
   118      }
   119      into "common", {
   120          from ("../../../../protos/common"){
   121              include 'common.proto'
   122          }
   123      }
   124      into "${projectDir}/protos"
   125  }
   126  
   127  tasks['build'].mustRunAfter tasks['copyProtos']
   128  build.dependsOn(copyProtos)
   129  build.finalizedBy(copyToLib)
   130  build.finalizedBy(publishToMavenLocal)
   131  
   132  dependencies {
   133      compile 'com.google.protobuf:protobuf-java:3.0.0'
   134      compile 'com.google.protobuf:protobuf-java-util:3.0.0'
   135      compile 'io.grpc:grpc-all:0.13.2'
   136      compile 'commons-cli:commons-cli:1.3.1'
   137      compile 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork21:' + tcnative_classifier
   138  }
   139  
   140  publishing {
   141     publications {
   142         mavenJava(MavenPublication) {
   143             groupId 'org.hyperledger'
   144             artifactId 'shim-client'
   145             version '1.0'
   146             from components.java
   147         }
   148     }
   149  }