-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
66 lines (54 loc) · 1.46 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
plugins {
id 'java'
id 'com.diffplug.spotless' version '6.22.0'
}
group = 'com.werockstar'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
spotless {
java {
removeUnusedImports()
indentWithTabs()
}
}
static def isLinuxOrMacOs() {
def osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
return osName.contains('linux') || osName.contains('mac os') || osName.contains('macos')
}
task copyGitHooks(type: Copy) {
description 'Copies the git hooks from /git-hooks to the .git folder.'
from("${rootDir}/git-hooks/") {
include '**/*.sh'
rename '(.*).sh', '$1' // Removes .sh extension, adjust if necessary
}
into "${rootDir}/.git/hooks"
}
task installGitHooks(type: Exec) {
description 'Installs the pre-commit git hooks from /git-hooks.'
group 'git hooks'
doFirst {
if (isLinuxOrMacOs()) {
// Unix-like OS
commandLine 'chmod', '-R', '+x', "${rootDir}/.git/hooks"
} else {
// Windows - Adjust if you have a specific command to run
// Generally, no action is needed to change permissions on Windows
commandLine 'cmd', '/c', 'echo', 'No permission change needed on Windows'
}
}
doLast {
logger.info('Git hook installed successfully.')
}
dependsOn copyGitHooks
}
dependencies {
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core:5.6.0'
implementation "io.reactivex.rxjava3:rxjava:3.1.8"
}
test {
useJUnitPlatform()
}