-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathcpg.common-conventions.gradle.kts
179 lines (154 loc) · 5 KB
/
cpg.common-conventions.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.services.BuildServiceParameters.None
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("cpg.formatting-conventions")
`java-library`
`jvm-test-suite`
jacoco
signing
`maven-publish`
kotlin("jvm")
kotlin("plugin.serialization")
id("org.jetbrains.dokka")
}
java {
withSourcesJar()
}
//
// common repositories
//
repositories {
mavenCentral()
ivy {
setUrl("https://download.eclipse.org/tools/cdt/releases/")
metadataSources {
artifact()
}
patternLayout {
artifact("[organisation].[module]_[revision].[ext]")
}
}
}
//
// common documentation, signing and publishing configuration
//
// this disables gradle's alternative to POM files, which cause problems when publishing on Maven
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
val dokkaHtml by tasks.getting(DokkaTask::class)
val javadocJar by tasks.registering(Jar::class) {
dependsOn(dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaHtml.outputDirectory)
}
publishing {
publications {
create<MavenPublication>(name) {
artifact(javadocJar)
from(components["java"])
pom {
url.set("https://github.com/Fraunhofer-AISEC/cpg")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("oxisto")
organization.set("Fraunhofer AISEC")
organizationUrl.set("https://www.aisec.fraunhofer.de")
}
}
scm {
connection.set("scm:git:git://github.com:Fraunhofer-AISEC/cpg.git")
developerConnection.set("scm:git:ssh://github.com:Fraunhofer-AISEC/cpg.git")
url.set("https://github.com/Fraunhofer-AISEC/cpg")
}
}
}
}
}
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
setRequired({
gradle.taskGraph.hasTask("publish")
})
sign(publishing.publications[name])
}
//
// common compilation configuration
//
// specify Java & Kotlin JVM version
kotlin {
jvmToolchain(17)
}
tasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlin.uuid.ExperimentalUuidApi", "-Xcontext-receivers")
}
}
// Configure our test suites
@Suppress("UnstableApiUsage")
testing {
suites {
// The default unit-test suite
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
}
// Our integration tests
val integrationTest by registering(JvmTestSuite::class) {
description = "Runs the integration tests"
dependencies {
implementation(project())
implementation(testFixtures(project(":cpg-core")))
}
// For legacy reasons we also include the unit-test resources in the integration tests,
// because some of them are shared
sources {
resources {
srcDirs("src/test/resources")
}
}
testType = TestSuiteType.INTEGRATION_TEST
}
// Our performance tests
val performanceTest by registering(JvmTestSuite::class) {
description = "Runs the performance tests"
dependencies {
implementation(project())
implementation(testFixtures(project(":cpg-core")))
}
testType = TestSuiteType.PERFORMANCE_TEST
targets {
all {
testTask.configure {
// do not parallelize tests within the task
maxParallelForks = 1
// make sure that several performance tests (e.g. in different frontends) also do NOT run in parallel
usesService(serialExecutionService)
}
}
}
}
}
}
// A build service that ensures serial execution of a group of tasks
abstract class SerialExecutionService : BuildService<None>
val serialExecutionService =
gradle.sharedServices.registerIfAbsent("serialExecution", SerialExecutionService::class.java) {
this.maxParallelUsages.set(1)
}
// Common dependencies that we need for all modules
val libs = the<LibrariesForLibs>() // necessary to be able to use the version catalog in buildSrc
dependencies {
implementation(libs.apache.commons.lang3)
implementation(libs.neo4j.ogm.core)
implementation(libs.jackson)
}