• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * This file was generated by the Gradle 'init' task.
3 *
4 * This generated file contains a sample Java Library project to get you started.
5 * For more details take a look at the Java Libraries chapter in the Gradle
6 * User Manual available at https://docs.gradle.org/6.3/userguide/java_library_plugin.html
7 */
8
9buildscript {
10    repositories {
11        maven {
12            url "https://plugins.gradle.org/m2/"
13        }
14    }
15    dependencies {
16        classpath "gradle.plugin.io.netifi:gradle-flatbuffers-plugin:1.0.7"
17    }
18}
19
20
21plugins {
22    // Apply the java-library plugin to add support for Java Library
23    id 'java-library'
24}
25
26apply plugin: "io.netifi.flatbuffers"
27
28repositories {
29    // Use jcenter for resolving dependencies.
30    // You can declare any Maven/Ivy/file repository here.
31    jcenter()
32    maven {
33        url "https://maven.springframework.org/release"
34    }
35    maven {
36        url "https://maven.restlet.com"
37    }
38    maven {
39        url "https://plugins.gradle.org/m2/"
40    }
41}
42
43dependencies {
44    // Use JUnit test framework
45    testImplementation 'junit:junit:4.12'
46
47    // https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
48    compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.14.9'
49    testCompile group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '3.14.9'
50
51    // https://mvnrepository.com/artifact/com.google.flatbuffers/flatbuffers-java
52    compile group: 'com.google.flatbuffers', name: 'flatbuffers-java', version: '2.0.0'
53
54    compile(group: 'org.bouncycastle',name: 'bcprov-jdk15on', version: '1.68')
55    implementation project(':common')
56    implementation project(':linux_x86')
57
58}
59
60def getFlatVersion(path) {
61    def version = new ByteArrayOutputStream()
62    def cmd = path + ' --version'
63    exec {
64        ExecSpec execSpec ->
65            executable 'bash'
66            args '-c', cmd
67            standardOutput = version
68    }
69    return version.toString().split()[2]
70}
71
72import io.netifi.flatbuffers.plugin.tasks.FlatBuffers
73
74flatbuffers {
75    String msLib = System.getenv("MSLIBS_CACHE_PATH").toString()
76    FileTree msLibTree = fileTree(dir: msLib, include: ["flatbuffers_*/bin/flatc"])
77    String msLibPath = ''
78    String libPath = ''
79    msLibTree.find {File file ->
80        libPath = file.toString()
81        String version = getFlatVersion(libPath)
82        if ('2.0.0' == version) {
83            msLibPath = libPath
84            return true
85        }
86    }
87    if (file('../../../build/_deps/flatbuffers-src/_build/flatc').exists()) {
88        String version = getFlatVersion('../../../build/_deps/flatbuffers-src/_build/flatc')
89        println('version: ' + version)
90        if ('2.0.0' == version) {
91            flatcPath = '../../../build/_deps/flatbuffers-src/_build/flatc'
92        } else {
93            println('the version of build flatc is not valid, will find the other flatc')
94        }
95    } else if (msLibPath != '' && file(msLibPath).exists()){
96        flatcPath = msLibPath
97    } else {
98        println("the needed flatc of version 2.0.0 is not exist, please check")
99    }
100    println("the used flatc path: " + flatcPath)
101}
102
103task createFlatBuffers(type: FlatBuffers) {
104    inputDir = file("../../../../schema")
105    outputDir = file("src/main/java/")
106    language = 'java'
107}
108
109
110task clearJar(type: Delete) {
111    delete 'build/libs/jarAAR/mindspore-lite-java-flclient.jar'
112    delete 'build/libs/jarX86/mindspore-lite-java-flclient.jar'
113}
114
115archivesBaseName ='mindspore-lite-java-flclient'
116
117task flReleaseJarAAR(type: Jar){
118    manifest {
119        attributes "Main-Class": "com.mindspore.flclient.SyncFLJob"
120    }
121    from('build/classes/java/main')
122    destinationDirectory = file('build/libs/jarAAR')
123}
124
125task packFLJarX86(type: Jar){
126    manifest {
127        attributes "Main-Class": "com.mindspore.flclient.SyncFLJob"
128    }
129    from ('build/classes/java/main')
130    from ('../common/build/classes/java/main')
131    from ('../linux_x86/build/classes/java/main')
132    from {
133        configurations.compile.collect {
134            it.isDirectory() ? it : zipTree(it) }
135    }
136    destinationDirectory = file('build/libs/jarX86')
137}
138
139task flReleaseJarX86 (type:Exec, dependsOn: ['packFLJarX86']){
140    commandLine "zip", "-d", "./build/libs/jarX86/mindspore-lite-java-flclient.jar",'META-INF/.SF',  'META-INF/.RSA',  'META-INF/*SF'
141}
142