-
Notifications
You must be signed in to change notification settings - Fork 64
/
build.gradle
173 lines (146 loc) · 5.66 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
168
169
170
171
172
173
//file:noinspection GroovyAssignabilityCheck
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
buildscript {
ext.kotlin_version = '1.9.24'
ext.embedded_kotlin_version = '1.9.24'
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
google()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id "io.github.gradle-nexus.publish-plugin" version "1.3.0" //can only be applied to root project
}
apply from: 'versionTasks.gradle'
nexusPublishing {
repositories {
sonatype {
username = "$System.env.SONATYPE_NEXUS_USERNAME"
password = "$System.env.SONATYPE_NEXUS_PASSWORD"
stagingProfileId = SONATYPE_STAGING_PROFILE_ID
}
}
}
allprojects {
// The maven-publish plugin seems to be able to find the group and version name by itself
// but the gradle-nexus publish-plugin can not do this. It is very important to set
// group and version on the _root_ project or the version name used for publishing
// to sonatype will be undefined
group = GROUP
version = VERSION_NAME
buildscript {
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
google()
maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap' }
}
}
repositories {
mavenCentral()
google()
maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://www.jetbrains.com/intellij-repository/snapshots' }
maven { url 'https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/' }
}
apply plugin: 'kotlin'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'signing'
apply plugin: 'maven-publish'
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
subprojects {
task sourcesJar(type: Jar, dependsOn: classes) {
//noinspection GroovyAccessibility // alternatively replace this with archiveClassifier.set('...')
archiveClassifier = 'sources'
from sourceSets.main.allSource, 'build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
//noinspection GroovyAccessibility //alternatively replace this with archiveClassifier.set('...')
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
afterEvaluate {
archivesBaseName = POM_ARTIFACT_ID
}
publishing {
publications {
mavenJava(MavenPublication) {
pom {
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME
name = POM_NAME
packaging = POM_PACKAGING
description = POM_DESCRIPTION
url = POM_URL
from components.java
artifact sourcesJar
artifact javadocJar
scm {
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
}
licenses {
license {
name = POM_LICENCE_NAME
url = POM_LICENCE_URL
distribution = POM_LICENCE_DIST
}
}
developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
}
}
}
}
}
}
signing {
// Skip signing if publishing to mavenLocal and credentials are not available
required { !gradle.taskGraph.hasTask("publishToMavenLocal") && project.hasProperty("signing.keyId") }
if (!project.hasProperty("signing.secretKeyRingFile") && !project.hasProperty("signing.password")) {
/* If in CI, the signing password and signing key are defined in the environment variables
ORG_GRADLE_PROJECT_signingPassword and ORG_GRADLE_PROJECT_signingKey
(https://blog.solidsoft.pl/2020/06/03/simpler-and-safer-artifact-signing-on-ci-server-with-gradle/,
https://stackoverflow.com/questions/57921325/gradle-signarchives-unable-to-read-secret-key).
Otherwise they are defined in the user's home directory gradle.properties.
*/
useInMemoryPgpKeys(findProperty("signingKey"), findProperty("signingPassword"))
}
sign publishing.publications.mavenJava
}
test {
useJUnitPlatform()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testImplementation "org.junit.jupiter:junit-jupiter:5.9.3"
testImplementation "org.mockito:mockito-core:4.7.0"
testImplementation "org.mockito.kotlin:mockito-kotlin:4.1.0"
testImplementation "org.assertj:assertj-core:3.24.2"
}
sourceCompatibility = 1.8
tasks.withType(KotlinCompilationTask).configureEach {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
}
}