forked from dector/sarif-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
146 lines (127 loc) · 3.93 KB
/
build.gradle.kts
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
import com.github.eirnym.js2p.GenerateJsonSchemaJavaTask
import java.net.URL
import java.nio.file.Files
plugins {
`java-library`
`maven-publish`
signing
kotlin("jvm") version Versions.kotlin
id(Deps.json_scheme_generator) version Versions.js2p
id("io.codearte.nexus-staging") version Versions.nexus
}
dependencies {
implementation(Deps.jackson)
testImplementation(kotlin("stdlib"))
testImplementation(Deps.junit)
testImplementation(Deps.jsonpath)
testImplementation(Deps.assertj)
}
sourceSets["main"].java {
srcDir(buildDir.resolve("generated-sources/js2p"))
}
group = "io.github.detekt.${rootProject.name}"
version = "1.0.0"
repositories {
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
tasks.withType(Javadoc::class).configureEach {
val customArgs = projectDir.resolve("javadoc-silence.txt")
customArgs.writeText("""
-Xdoclint:none
""".trimIndent())
options.optionFiles?.add(customArgs)
}
tasks.withType(Test::class).configureEach {
useJUnitPlatform()
}
val getSchema by tasks.registering {
val schemaFile = projectDir.resolve("src/main/resources/json/sarif-schema-2.1.0.json").toPath()
outputs.file(schemaFile)
doLast {
val schema = URL("https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json")
.openStream()
.readBytes()
Files.write(schemaFile, schema)
}
}
tasks.withType<GenerateJsonSchemaJavaTask>().configureEach {
dependsOn(getSchema)
}
jsonSchema2Pojo {
targetPackage = "io.github.detekt.sarif4j"
initializeCollections = false
isGenerateBuilders = true
setInclusionLevel("NON_DEFAULT")
setAnnotationStyle(org.jsonschema2pojo.AnnotationStyle.JACKSON.toString())
}
val sonatypeUsername: String? =
findProperty("sonatypeUsername")?.toString()
?: System.getenv("MAVEN_CENTRAL_USER")
val sonatypePassword: String? =
findProperty("sonatypePassword")?.toString()
?: System.getenv("MAVEN_CENTRAL_PW")
publishing {
repositories {
maven {
name = "mavenCentral"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2")
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
maven {
name = "mavenSnapshot"
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
publications.register<MavenPublication>(rootProject.name) {
groupId = project.group as? String
artifactId = project.name
version = project.version as? String
from(components["java"])
pom {
description.set("SARIF models for the JVM")
name.set(rootProject.name)
url.set("https://detekt.github.io/detekt")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("Artur Bosch")
name.set("Artur Bosch")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/detekt/sarif4j")
}
}
}
}
if (findProperty("signing.keyId") != null) {
signing {
sign(publishing.publications[rootProject.name])
}
}
nexusStaging {
packageGroup = "io.github.detekt"
stagingProfileId = "117c7a00a4d531"
username = sonatypeUsername
password = sonatypePassword
}