forked from luben/zstd-jni
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
80 lines (70 loc) · 1.85 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
apply plugin: 'com.android.library'
version = rootProject.file('version').text.trim()
def generatedSrcDir = new File(buildDir, "generated/main/java/");
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName version
externalNativeBuild {
cmake {
cppFlags ""
}
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
task generateZstdVersion {
doLast {
ZstdVersionGenerator.generate(generatedSrcDir, version)
}
}
preBuild.dependsOn generateZstdVersion
sourceSets {
main.java.srcDirs += generatedSrcDir
}
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
}
public class ZstdVersionGenerator {
public static void generate(File outputDir, String version) throws Exception {
String packageName = "com.github.luben.zstd.util";
File packageDir = new File(outputDir, packageName.replace(".", "/"));
packageDir.mkdirs();
OutputStream outputStream = new FileOutputStream(new File(packageDir, "ZstdVersion.java"));
try {
def output = "package " + packageName + ";\n\npublic class ZstdVersion\n{\n\tpublic static final String VERSION = \"" + version + "\";\n}\n";
outputStream.write(output.getBytes("UTF-8"));
}
finally {
outputStream.close();
}
}
}