-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
107 lines (86 loc) · 3.44 KB
/
build.gradle
File metadata and controls
107 lines (86 loc) · 3.44 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
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
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.13'
id 'io.spring.dependency-management' version '1.1.7'
// id 'com.github.ben-manes.versions' version '0.39.0'
// id 'com.github.johnrengelman.shadow' version '7.1.2'
}
group = 'skillter'
version = '0.1.0-SNAPSHOT'
sourceCompatibility = 17
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
compileOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
// compileOnly 'org.springframework:springloaded:1.2.8.RELEASE'
// implementation 'org.springframework:spring-webmvc'
// implementation 'javax.servlet:servlet-api:3.0-alpha-1'
implementation 'com.h2database:h2'
implementation 'org.postgresql:postgresql'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
springBoot {
mainClass = 'skillter.aboutme.AboutMeApplication'
}
tasks.register('watchForChanges') {
doLast {
var refreshRateMS = 100;
var lastTrigger = null;
while (true) {
def configDir = fileTree("F:\\.Java Workspace\\aboutme\\src\\main\\resources")
def changes = configDir.files.findAll { it.lastModified() > new Date().time - refreshRateMS * 1.6 }
if (!changes.isEmpty()) {
if (!(lastTrigger == null || new Date().time - lastTrigger >= 500)) continue; // Anti false double trigger and problematic spam prevention
changes.each { file -> println("Change detected in file: " + file.path)}
// here implement triggering processResources task
// welp, there's simply no way to do that, you could use finalizedBy(), but then the current task is finished and there's no way to run it again automatically, spent few hours on this but it has to be abandoned
// oh you can run the gradle task through the console command, I tried it but did it wrong at first time and wasted 2 hours
// oh my god it actually works, i hate my job it was so f annoying i'm never touching it again
var command = "\"" + System.getProperty("user.dir") + "\\gradlew.bat\" processResources"
command.execute()
lastTrigger = new Date().time
}
sleep(refreshRateMS)
}
}
}
tasks.named('test') {
useJUnitPlatform()
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
}
tasks.register('grypeScan') {
group = 'verification'
description = 'Scan dependencies for vulnerabilities using Grype'
dependsOn 'bootJar'
doLast {
def grypeCommand = System.getProperty('os.name').toLowerCase().contains('windows') ? 'grype.exe' : 'grype'
def hasGrype = false
try {
def result = exec {
commandLine grypeCommand, '--version'
ignoreExitValue = true
standardOutput = new ByteArrayOutputStream()
errorOutput = new ByteArrayOutputStream()
}
hasGrype = result.exitValue == 0
} catch (Exception e) {
hasGrype = false
}
if (!hasGrype) {
throw new GradleException("""Grype is not installed. Install it first:
Windows (Scoop): scoop install anchore/grype
Windows (Winget): winget install Anchore.Grype
macOS: brew install anchore/grype/grype
Linux: curl -sSfL https://get.anchore.io/grype | sh -s -- -b /usr/local/bin
See: https://github.com/anchore/grype""")
}
exec {
commandLine grypeCommand, "dir:${projectDir}/build/libs", '--fail-on', 'high', '-o', 'table'
}
}
}