-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle
More file actions
58 lines (44 loc) · 1.62 KB
/
build.gradle
File metadata and controls
58 lines (44 loc) · 1.62 KB
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
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply plugin: 'maven' // jitpack.io
buildscript {
repositories{
jcenter()
}
}
group='com.github.quarkworks' // jitpack.io
def source_GIT_COMMIT = new File(buildDir, 'generated/source/GIT_COMMIT/main/java')
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation project(':annotations')
implementation "io.realm:realm-annotations:$realm_version"
kapt "com.google.auto.service:auto-service:1.0-rc4"
compileOnly "com.google.auto.service:auto-service:1.0-rc4"
implementation 'com.squareup:kotlinpoet:1.0.0-RC1'
}
repositories {
mavenCentral()
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
main.java.srcDirs += source_GIT_COMMIT
}
//Embed jitpack GIT_COMMIT env variable value.
//Add a build signature to jitpack builds
import com.squareup.javapoet.FieldSpec
import com.squareup.javapoet.JavaFile
import com.squareup.javapoet.TypeName
import com.squareup.javapoet.TypeSpec
import javax.lang.model.element.Modifier
task compileKotlin.doFirst {
ext.GIT_COMMIT = System.getenv()['GIT_COMMIT'] ?: "Not Set"
if (ext.GIT_COMMIT != null) {
def fs = FieldSpec.builder(TypeName.get(String.class), "val", Modifier.STATIC)
.initializer('$S', ext.GIT_COMMIT).build()
def ts = TypeSpec.classBuilder("GIT_COMMIT").addField(fs).build()
JavaFile.builder("com.quarkworks.android.realmtypesafequery.annotationprocessor", ts)
.build().writeTo(source_GIT_COMMIT)
}
}