forked from dzikoysk/reposilite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
189 lines (163 loc) · 6.19 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
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
179
180
181
182
183
184
185
186
187
188
189
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
/*
* Copyright (c) 2023 dzikoysk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
`java-library`
application
`maven-publish`
val kotlinVersion = "1.8.10"
kotlin("jvm") version kotlinVersion
kotlin("kapt") version kotlinVersion
id("pl.allegro.tech.build.axion-release")
}
scmVersion {
checks.apply {
isUncommittedChanges = false
}
tag.apply {
prefix = ""
}
nextVersion.apply {
suffix = "next"
}
versionIncrementer("incrementPrerelease")
hooks.apply {
fileUpdate(".github/README.md") { version -> "reposilite-$version.jar" }
fileUpdate(".github/README.md") { version -> "dzikoysk/reposilite:$version" }
fileUpdate("docker-compose.yml") { version -> "image: reposilite:$version" }
fileUpdate("reposilite-backend/src/main/kotlin/com/reposilite/Reposilite.kt") { version -> "const val VERSION = \"$version\"" }
fileUpdate("reposilite-frontend/package.json") { version -> "\"version\": \"$version\"" }
fileUpdate("reposilite-frontend/package-lock.json") { version -> "\"version\": \"$version\"" }
fileUpdate("reposilite-site/data/guides/developers/endpoints.md") { version -> "\"version\": \"$version\"" }
fileUpdate("reposilite-site/data/guides/developers/plugin-api.md") { version -> "\"com.reposilite:reposilite:$version\"" }
fileUpdate("reposilite-site/data/guides/installation/docker.md") { version -> version }
commit { version -> "Release $version" }
}
scmVersion {
checks.isSnapshotDependencies = false
}
}
allprojects {
version = rootProject.scmVersion.version
// Give a friendly error when building project and git tags aren't available
// ~ https://github.com/dzikoysk/reposilite/issues/1725
if (version == "0.1.0-SNAPSHOT") {
throw IllegalStateException("Version is not set, please run 'git fetch --tags' command to fetch tags from main repository.")
}
repositories {
maven("https://maven.reposilite.com/maven-central") {
mavenContent {
releasesOnly()
}
}
maven("https://maven.reposilite.com/releases") {
mavenContent {
releasesOnly()
}
}
maven("https://maven.reposilite.com/snapshots") {
mavenContent {
snapshotsOnly()
}
}
maven("https://jitpack.io") {
mavenContent {
releasesOnly()
}
}
}
}
subprojects {
apply(plugin = "java-library")
apply(plugin = "application")
apply(plugin = "maven-publish")
group = "com.reposilite"
dependencies {
testImplementation("org.assertj:assertj-core:3.23.1")
val junit = "5.8.2"
testImplementation("org.junit.jupiter:junit-jupiter-params:$junit")
testImplementation("org.junit.jupiter:junit-jupiter-api:$junit")
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junit")
}
java {
withJavadocJar()
withSourcesJar()
}
sourceSets.main {
java.srcDirs("src/main/kotlin")
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "11"
languageVersion = "1.7"
freeCompilerArgs = listOf("-Xjvm-default=all") // For generating default methods in interfaces
}
}
publishing {
repositories {
maven {
name = "panda-repository"
url = uri("https://maven.reposilite.com/${if (version.toString().endsWith("-SNAPSHOT")) "snapshots" else "releases"}")
credentials {
username = System.getenv("MAVEN_NAME") ?: property("mavenUser").toString()
password = System.getenv("MAVEN_TOKEN") ?: property("mavenPassword").toString()
}
}
}
publications {
create<MavenPublication>("library") {
from(components.getByName("java"))
// Gradle generator does not support <repositories> section from Maven specification.
// ~ https://github.com/gradle/gradle/issues/15932
pom.withXml {
val repositories = asNode().appendNode("repositories")
project.repositories.findAll(closureOf<Any> {
if (this is MavenArtifactRepository && this.url.toString().startsWith("https")) {
val repository = repositories.appendNode("repository")
repository.appendNode("id", this.url.toString().replace("https://", "").replace(".", "-").replace("/", "-"))
repository.appendNode("url", this.url.toString())
}
})
}
}
}
}
tasks.withType<Test> {
testLogging {
events(
TestLogEvent.STARTED,
TestLogEvent.PASSED,
TestLogEvent.FAILED,
TestLogEvent.SKIPPED
)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
showStandardStreams = true
}
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2)
.takeIf { it > 0 }
?: 1
useJUnitPlatform()
}
}