-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle
168 lines (148 loc) · 5.58 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
plugins {
id 'java'
id 'idea'
id ('org.openapi.generator') version('5.4.0') //we can't update now due to okhttp-gson-nextgen validates json attributes, but SSC sends an additional undocumented _href attribute
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
}
repositories {
mavenCentral()
}
group = 'com.fortify'
version = '24.4'
description 'Fortify SSC REST API client'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
ext {
modifiedSpecDir = "$buildDir/tmp"
originalSpecDir = "src/swagger/spec.json"
generatedCodeDir = "$buildDir/generatedCode"
}
dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
implementation 'com.google.code.gson:gson:2.11.0'
implementation 'io.gsonfire:gson-fire:1.9.0'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'io.swagger:swagger-annotations:1.6.14'
implementation 'jakarta.annotation:jakarta.annotation-api:1.3.5'
implementation 'com.squareup.okio:okio-jvm:3.9.1'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.25'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.25'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-common:1.9.25'
testImplementation 'junit:junit:4.13.2'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives(sourcesJar) {
type 'source'
}
archives(javadocJar) {
type 'javadoc'
}
}
task fixAndCopySwaggerSpec(type: Sync) {
description 'Read spec-rest.json and remove « and » characters and rename [Custom Tag] to [Custom Tag Audit] to avoid collision with [Custom tag] (lower case), also rename URI to URI_1 to avoid collision with java.net.URI in Resource.java. Write modified file to task temporaryDir'
into(modifiedSpecDir)
from(originalSpecDir) {
filteringCharset = "UTF-8"
filter({ String line ->
line.replaceAll(/[\u00ab\u00bb]/, "") // [«»]
.replaceAll(/([\/<"])Custom Tag([>"])/, '$1Custom Tag Audit$2') // upper case [Custom Tag]
.replaceAll(/([\/"])URI"/, '$1URI_1"') // avoid collision with java.net.URI
})
}
}
openApiGenerate {
generatorName = "java"
inputSpec = "$modifiedSpecDir/spec.json"
apiPackage = "com.fortify.ssc.restclient.api"
invokerPackage = "com.fortify.ssc.restclient"
outputDir = generatedCodeDir
modelPackage = 'com.fortify.ssc.restclient.model'
generateModelDocumentation = true
generateModelTests = false
generateApiDocumentation = false
generateApiTests = false
configOptions = [
dateLibrary: "java8",
library: "okhttp-gson",
serializationLibrary: "gson",
openApiNullable: "false",
hideGenerationTimestamp: "true",
annotationLibrary: "none", //this is only available in openapi generator v6.x
useJakartaEe: "true" //this is only available in openapi generator v7.x
]
}
tasks.named("openApiGenerate").configure {
dependsOn tasks.fixAndCopySwaggerSpec
}
compileJava.dependsOn tasks.openApiGenerate
sourceSets.main.java.srcDir generatedCodeDir
// codegen creates javadoc with tags which are unsupported
// in HTML 5. We disable doclint to avoid build procedure failure
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
publishing {
publications {
mavenJava(MavenPublication) {
pom {
groupId = project.group
artifactId = project.name
name = project.name
version = project.version
description = project.description
url = 'https://github.com/fortify/ssc-restapi-client'
licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'fortify'
name = 'Fortify'
email = '[email protected]'
organization = 'Open Text Fortify'
organizationUrl = 'https://www.microfocus.com/en-us/cyberres/application-security'
}
}
scm {
connection = "scm:git:https://github.com/fortify/${rootProject.name}.git"
developerConnection = "scm:git:https://github.com/fortify/${rootProject.name}.git"
url = "https://github.com/fortify/${rootProject.name}"
}
}
from components.java
artifact sourcesJar
artifact javadocJar
}
}
}
// Sign using signingKey and signingPassword properties
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
required { gradle.taskGraph.hasTask("publishToOSSRH") }
sign publishing.publications.mavenJava
}
// Publish using OSSRHUsername and OSSRHPassword properties
nexusPublishing {
repositories {
OSSRH {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}