-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
111 lines (85 loc) · 3.01 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias libs.plugins.android.application apply false
alias libs.plugins.android.library apply false
}
def jsr = "$System.env.J2OBJC_HOME/lib/jsr305-3.0.0.jar"
task translateLeBlueJava(type:Exec) {
FileTree tree = fileTree(dir: 'LeBLue-java/src/main/java')
tree.include '**/*.java'
executable System.getenv()['J2OBJC_HOME'] + '/j2objc'
args '--prefixes', file('objc/prefixes.properties').path
args '--no-package-directories'
args '-d', file('objc/generated/').path
args '-sourcepath', tree.dir ,''
args '--swift-friendly'
args '-x', 'objective-c++'
args '-cp', "$jsr"
args tree
}
task translateLeBlueJavaTest(type:Exec) {
FileTree mainTree = fileTree(dir: 'LeBLue-java/src/main/java')
mainTree.include '**/*.java'
FileTree tree = fileTree(dir: 'LeBLue-java/src/test/java')
tree.include '**/*.java'
executable System.getenv()['J2OBJC_HOME'] + '/j2objc'
args '--prefixes', file('objc/prefixes.properties').path
args '--no-package-directories'
args '-d', file('objc/generated/').path
args '--swift-friendly'
args '-x', 'objective-c++'
args '-cp', "$jsr"
String dir1 = tree.dir
String dir2 = mainTree.dir
args '-sourcepath',dir1 + ":" + dir2
args '-classpath', System.getenv()['J2OBJC_HOME'] + '/lib/j2objc_junit.jar'
args tree
}
task compileTranslatedLeBlueJavaTest(type:Exec) {
executable System.getenv()['J2OBJC_HOME'] + '/j2objcc'
args "-I${file("objc/generated/").path}"
args "-ObjC", "-ljunit", "-ljre_emul"
args "-o", "testrunner"
args "-Wno-nullability-completeness"
args "-Wno-objc-property-no-attribute"
args "-Wno-error"
FileTree tree = fileTree(dir: "objc/generated/", include: '**/*.mm')
args tree
}
task testTranslatedLeBlueJava(type:Exec) {
executable file("testrunner")
args 'org.junit.runner.JUnitCore'
FileTree tree = fileTree(dir: "objc/generated/", include: '**/*Test.mm')
tree.exclude '**/MockerTest.mm'
tree.each { File file ->
println file
args file.name.replace(".mm", "")
}
}
task deleteGenerated() {
doLast {
delete "objc/generated/"
}
}
task createDirs(dependsOn:deleteGenerated ) {
doLast {
file("objc/generated/").mkdirs()
}
}
task removeHeader {
doLast{
FileTree tree = fileTree(dir: 'objc/generated/')
tree.include '**/*.m'
tree.include '**/*.mm'
tree.include '**/*.h'
tree.each { File file ->
String contents = new File(file.path).getText('UTF-8')
//remove generated comments
contents = contents.substring(contents.indexOf('\n') + 1)
contents = contents.substring(contents.indexOf('\n') + 1)
contents = contents.substring(contents.indexOf('\n') + 1)
contents = contents.substring(contents.indexOf('\n') + 1)
new File(file.path).write(contents, 'UTF-8')
}
}
}