Skip to content

Commit ac174e7

Browse files
lamba92Lamba92
authored and
Lamba92
committed
moving to bintray, centralized gradle logic with custom plugin
1 parent a21b913 commit ac174e7

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.github.lamba92.dragalialost.build
2+
3+
import com.jfrog.bintray.gradle.BintrayExtension
4+
import org.gradle.api.Plugin
5+
import org.gradle.api.Project
6+
import org.gradle.kotlin.dsl.configure
7+
import org.gradle.kotlin.dsl.withGroovyBuilder
8+
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
9+
10+
@Suppress("unused")
11+
class DragaliaPlugin : Plugin<Project> {
12+
13+
private val kotlinVersion = "1.3.50"
14+
private val bintrayVersion = "1.8.4"
15+
16+
override fun apply(target: Project) = with(target) {
17+
18+
plugins.apply("org.jetbrains.kotlin.multiplatform")
19+
plugins.apply("org.gradle.maven-publish")
20+
plugins.apply("com.jfrog.bintray")
21+
22+
extensions.findByName("buildScan")?.withGroovyBuilder {
23+
setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service")
24+
setProperty("termsOfServiceAgree", "yes")
25+
}
26+
27+
extensions.configure<KotlinMultiplatformExtension> {
28+
metadata {
29+
mavenPublication {
30+
artifactId = "${rootProject.name}-${project.name}-metadata"
31+
}
32+
}
33+
34+
jvm {
35+
compilations.all {
36+
kotlinOptions {
37+
jvmTarget = "1.8"
38+
}
39+
}
40+
mavenPublication {
41+
artifactId = "${rootProject.name}-${project.name}-jvm"
42+
}
43+
}
44+
45+
js {
46+
// nodejs()
47+
mavenPublication {
48+
artifactId = "${rootProject.name}-${project.name}-js"
49+
}
50+
}
51+
52+
sourceSets.all {
53+
languageSettings.enableLanguageFeature("InlineClasses")
54+
}
55+
56+
}
57+
58+
extensions.configure<BintrayExtension> {
59+
user = searchPropertyOrNull("bintrayUsername")
60+
key = searchPropertyOrNull("bintrayApiKey")
61+
pkg {
62+
version {
63+
name = project.version.toString()
64+
}
65+
repo = "com.github.lamba92"
66+
name = "dragalia-library"
67+
setLicenses("Apache-2.0")
68+
vcsUrl = "https://github.com/lamba92/dragalia-library"
69+
issueTrackerUrl = "https://github.com/lamba92/dragalia-library/issues"
70+
}
71+
publish = true
72+
setPublications("jvm", "js", "kotlinMultiplatform")
73+
}
74+
75+
}
76+
77+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@file:Suppress("unused")
2+
3+
package com.github.lamba92.dragalialost.build
4+
5+
import com.jfrog.bintray.gradle.BintrayExtension
6+
import org.gradle.api.Project
7+
import org.gradle.kotlin.dsl.closureOf
8+
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
9+
10+
fun KotlinDependencyHandler.kodein(module: String, version: String? = null): Any =
11+
"org.kodein.di:kodein-di-$module${version?.let { ":$version" } ?: ""}"
12+
13+
fun KotlinDependencyHandler.ktor(module: String, version: String? = null): Any =
14+
"io.ktor:ktor-$module${version?.let { ":$version" } ?: ""}"
15+
16+
fun KotlinDependencyHandler.lamba(module: String, version: String? = null): Any =
17+
"com.github.lamba92:$module${version?.let { ":$version" } ?: ""}"
18+
19+
fun Project.searchPropertyOrNull(propertyName: String): String? =
20+
findProperty(propertyName) as String? ?: System.getenv(propertyName)
21+
22+
fun BintrayExtension.pkg(action: BintrayExtension.PackageConfig.() -> Unit) {
23+
pkg(closureOf(action))
24+
}
25+
26+
fun BintrayExtension.PackageConfig.version(action: BintrayExtension.VersionConfig.() -> Unit) {
27+
version(closureOf(action))
28+
}
29+
30+
fun KotlinDependencyHandler.kotlinx(module: String, version: String? = null): Any =
31+
"org.jetbrains.kotlinx:kotlinx-$module${version?.let { ":$version" } ?: ""}"
32+
33+
fun KotlinDependencyHandler.serialization(module: String, version: String? = null): Any =
34+
"org.jetbrains.kotlinx:kotlinx-serialization-$module${version?.let { ":$version" } ?: ""}"

0 commit comments

Comments
 (0)