-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathbuild.gradle
64 lines (46 loc) · 1.78 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
import org.gradle.work.Incremental
import org.gradle.work.InputChanges
import org.gradle.api.DefaultTask
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
abstract class IncrementalConvertTask extends DefaultTask {
@Incremental
//@PathSensitive(PathSensitivity.NAME_ONLY)
@InputFiles
abstract ConfigurableFileCollection getSourceFiles();
@TaskAction
void execute(InputChanges inputChanges) {
println(inputChanges.incremental
? 'Executing incrementally'
: 'Executing non-incrementally'
)
sourceFiles.each { f ->
println "jake sourceFiles ${f.getPath()}"
}
inputChanges.getFileChanges(sourceFiles).each { change ->
if (change.fileType == FileType.DIRECTORY) return
def srcPath = change.normalizedPath
println "${change.changeType}: ${srcPath}"
def dstPath = srcPath.substring(0, srcPath.length()-3)+'_ui.py'
if (change.changeType == ChangeType.REMOVED) {
def targetFile = file(srcPath.substring(0, srcPath.length()-3)+'_ui.py').get().asFile
targetFile.delete()
} else {
def cmdLine = "pyside6-uic $change.file.path -o $dstPath"
println("cmdLine " +cmdLine)
def proc = cmdLine.execute()
proc.waitForProcessOutput(System.out, System.err)
}
}
}
}
task convertUI(type: IncrementalConvertTask) {
def uiFiles = fileTree('view')
uiFiles.include('**/*.ui')
sourceFiles.setFrom(uiFiles)
def oFiles = uiFiles.collect {f ->
file(f.getPath().replaceFirst(/\.ui$/, "_ui.py"))
}
outputs.files(oFiles)
}