-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle
More file actions
125 lines (110 loc) · 3.77 KB
/
Copy pathbuild.gradle
File metadata and controls
125 lines (110 loc) · 3.77 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
group = 'com.pwn_burp'
version = '0.0.001'
repositories {
mavenCentral()
}
dependencies {
compileOnly files('/opt/burpsuite/burpsuite-pro.jar')
implementation 'net.portswigger.burp.extensions:montoya-api:+'
implementation 'io.javalin:javalin:6.7.0'
implementation 'io.javalin.community.openapi:javalin-openapi-plugin:6.7.0'
implementation 'io.javalin.community.openapi:javalin-swagger-plugin:6.7.0'
//implementation 'io.javalin:javalin:+'
//implementation 'io.javalin.community.openapi:javalin-openapi-plugin:+'
//implementation 'io.javalin.community.openapi:javalin-swagger-plugin:+'
implementation 'com.google.code.gson:gson:+'
implementation 'org.slf4j:slf4j-api:+'
implementation 'org.webjars:swagger-ui:+'
annotationProcessor 'io.javalin.community.openapi:openapi-annotation-processor:6.7.0'
//annotationProcessor 'io.javalin.community.openapi:openapi-annotation-processor:+'
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:deprecation'
}
tasks.withType(Jar) {
manifest {
attributes 'Main-Class': 'com.pwn_burp.PwnBurp'
}
}
tasks.shadowJar {
archiveFileName = 'pwn-burp.jar'
}
tasks.processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from('src/main/resources') {
include '**/*'
into ''
}
}
// Task to extract Swagger UI assets from WebJar to src/main/resources/swagger-ui
task copySwaggerUiAssets(type: Copy) {
description 'Copy Swagger UI assets from WebJar to src/main/resources/swagger-ui'
group 'build'
// Find the swagger-ui WebJar file
from configurations.runtimeClasspath.findAll { it.name.contains('swagger-ui') }.collect { zipTree(it) }
// Only include necessary Swagger UI assets
include 'META-INF/resources/webjars/swagger-ui/**/*.js'
include 'META-INF/resources/webjars/swagger-ui/**/*.css'
// Output swaggeer-ui to src/main/resources/
into "${projectDir}/src/main/resources/"
// Strip the WebJar version path to simplify access
eachFile { file ->
// Adjust the path to remove version-specific directory
def versionPath = file.path.replaceFirst(
'META-INF/resources/webjars/swagger-ui/[^/]+/',
'swagger-ui/'
)
file.path = versionPath
}
// remove src/main/resources/META-INF if it exists
doLast {
def metaInfDir = file("${projectDir}/src/main/resources/META-INF")
if (metaInfDir.exists()) {
metaInfDir.deleteDir()
}
}
}
// Make processResources depend on copySwaggerUiAssets to ensure assets are copied before packaging
processResources.dependsOn copySwaggerUiAssets
// Clean up the project by removing Swagger UI assets, .gradle, & build
clean {
// Remove STRUCTURE.md if it exists
def oldStructureFile = file("${projectDir}/STRUCTURE.md")
if (oldStructureFile.exists()) {
oldStructureFile.delete()
}
def structureFile = file("${projectDir}/STRUCTURE.txt")
if (structureFile.exists()) {
structureFile.delete()
}
// Remove all Swagger UI assets from the resources directory
// except index.html
def swaggerUiDir = file("${projectDir}/src/main/resources/swagger-ui")
if (swaggerUiDir.exists()) {
swaggerUiDir.eachFile { file ->
if (file.name != 'index.html') {
file.delete()
}
}
}
// Delete .gradle
def gradleDir = file("${projectDir}/.gradle")
if (gradleDir.exists()) {
gradleDir.deleteDir()
}
// Delete build
def buildDir = file("${projectDir}/build")
if (buildDir.exists()) {
buildDir.deleteDir()
}
}