blob: c9128cad1c5044f02c3ae86a15c5dc1ac546ac49 (
plain)
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
|
package frege.gradle
import org.gradle.api.DefaultTask
import org.gradle.api.internal.file.FileResolver
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import org.gradle.process.internal.DefaultJavaExecAction
import org.gradle.process.internal.JavaExecAction
class NativeGenTask extends DefaultTask {
/*
* Example from https://github.com/Frege/frege-native-gen:
* java -cp /path/to/guava-15.0.jar:lib/frege-YY.jar:frege-native-gen-XX.jar frege.nativegen.Main com.google.common.collect.ImmutableCollection
*/
// help not currently supported by native gen tool
Boolean help = false
@Optional
@InputFile
File typesFile = new File(project.projectDir, "types.properties")
@Input
String className = null
@Optional
@OutputFile
File outputFile = new File(project.buildDir, "generated/frege/NativeGenOutput.fr")
@TaskAction
void gen() {
FileResolver fileResolver = getServices().get(FileResolver.class)
JavaExecAction action = new DefaultJavaExecAction(fileResolver)
action.setMain("frege.nativegen.Main")
action.workingDir = project.projectDir
action.standardInput = System.in
action.standardOutput = outputFile.newOutputStream()
action.errorOutput = System.err
action.setClasspath(project.files(project.configurations.compile) + project.files("$project.buildDir/classes/main"))
def args = []
if (help) {
args << "-h"
} else {
args << className
args << typesFile.absolutePath
}
logger.info("Calling Frege NativeGen with args: '$args'")
action.args args
action.execute()
}
}
|