Skip to content

Commit 51a69c9

Browse files
committed
building: use maven central or mary from environment
When publishing to maven central we don't want any other repositories listed in our pom.xml or (even if just compile-only) dependencies in it. When you set the environment variable `MAVEN_REPOSITORY` to `CENTRAL` then it will comply with that. Otherwise (still the default) it will still use mary. Question for the future: Should this be the default option? Maven central is pretty much the default and everybody is scared of custom repositories.
1 parent 8fc7487 commit 51a69c9

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

build.gradle.kts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
1-
import magik.github
2-
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
31
import java.util.*
2+
import magik.github
43

54
plugins {
6-
kotlin("jvm") version embeddedKotlinVersion
5+
kotlin("jvm") version "2.2.0"
76
id("elect86.magik") version "0.3.2"
87
`maven-publish`
98
signing
109
// id("com.github.johnrengelman.shadow") version "8.1.1"
1110
}
1211

12+
enum class MavenRepository(val group: String) {
13+
MARY("kotlin.graphics"),
14+
CENTRAL("io.github.kotlin-graphics"),
15+
;
16+
}
17+
18+
val repository = System.getenv("MAVEN_REPOSITORY")?.takeIf { !it.isBlank() }?.let { MavenRepository.valueOf(it) } ?: MavenRepository.MARY
19+
20+
1321
repositories {
1422
mavenCentral()
15-
github("kotlin-graphics/mary")
23+
if (repository == MavenRepository.MARY) {
24+
github("kotlin-graphics/mary")
25+
}
1626
}
1727

1828
dependencies {
19-
compileOnly("kotlin.graphics:unsigned:3.3.32")
20-
compileOnly("kotlin.graphics:kool:0.9.77")
29+
compileOnly(repository.group, "unsigned", "3.3.32")
30+
compileOnly(repository.group, "kool", "0.9.77")
31+
2132
compileOnly("org.lwjgl:lwjgl-jemalloc:3.3.2")
2233

2334

2435
testImplementation("io.kotest:kotest-runner-junit5:5.6.2")
2536
testImplementation("io.kotest:kotest-assertions-core:5.6.2")
2637

27-
testImplementation("kotlin.graphics:kool:0.9.77")
28-
testImplementation("kotlin.graphics:unsigned:3.3.32")
38+
testImplementation(repository.group, "kool", "0.9.77")
39+
testImplementation(repository.group, "unsigned", "3.3.32")
2940
}
3041

3142
kotlin.jvmToolchain { languageVersion.set(JavaLanguageVersion.of(8)) }
3243

3344
tasks {
34-
withType<KotlinCompile<*>>().all { kotlinOptions { freeCompilerArgs += listOf("-opt-in=kotlin.RequiresOptIn") } }
3545
test { useJUnitPlatform() }
3646
}
3747

@@ -45,7 +55,7 @@ java {
4555
configure<PublishingExtension> {
4656
publications {
4757
create<MavenPublication>("mavenCentral") {
48-
groupId = "io.github.kotlin-graphics"
58+
groupId = MavenRepository.CENTRAL.group
4959
artifactId = "glm"
5060
from(components["java"])
5161
versionMapping {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)