|
1 | | -import com.diffplug.gradle.spotless.SpotlessExtension |
2 | | -import org.jetbrains.kotlin.gradle.dsl.KotlinCompile |
3 | | - |
4 | 1 | buildscript { |
5 | 2 | repositories { |
6 | 3 | mavenCentral() |
7 | | - google() |
8 | 4 | } |
9 | 5 | dependencies { |
10 | | - classpath(plugin.Spotless()) |
11 | | - } |
12 | | -} |
13 | | - |
14 | | -plugins { |
15 | | - kotlin("multiplatform") version "1.4.30" |
16 | | - kotlin("plugin.serialization") version "1.4.30" |
17 | | - id("maven-publish") |
18 | | - id("signing") |
19 | | -} |
20 | | - |
21 | | -apply(plugin = "com.diffplug.spotless") |
22 | | - |
23 | | -repositories { |
24 | | - mavenCentral() |
25 | | - google() |
26 | | -} |
27 | | - |
28 | | -version = Library.version |
29 | | -group = Library.group |
30 | | - |
31 | | -kotlin { |
32 | | - explicitApi() |
33 | | - jvm { |
34 | | - compilations.all { |
35 | | - kotlinOptions { |
36 | | - jvmTarget = "1.8" |
37 | | - } |
38 | | - } |
39 | | - } |
40 | | - |
41 | | - sourceSets { |
42 | | - all { |
43 | | - languageSettings.progressiveMode = true |
44 | | - } |
45 | | - val commonMain by getting { |
46 | | - kotlin.srcDirs("$buildDir/generated/sources/templates/kotlin/main") |
47 | | - dependencies { |
48 | | - api(Ktor("client")) |
49 | | - api(Ktor("client-json")) |
50 | | - api(Ktor("client-logging")) |
51 | | - api(Ktor("client-serialization")) |
52 | | - } |
53 | | - } |
54 | | - val commonTest by getting { |
55 | | - dependencies { |
56 | | - implementation(kotlin("test")) |
57 | | - implementation(kotlin("test-annotations-common")) |
58 | | - implementation(Ktor("client")) |
59 | | - implementation(Ktor("client-mock")) |
60 | | - } |
61 | | - } |
62 | | - val jvmTest by getting { |
63 | | - dependencies { |
64 | | - implementation(kotlin("test-junit")) |
65 | | - implementation(Ktor("client-okhttp")) |
66 | | - implementation(Ktor("client-apache")) |
67 | | - implementation(Ktor("client-android")) |
68 | | - } |
69 | | - } |
70 | | - } |
71 | | -} |
72 | | - |
73 | | -tasks { |
74 | | - |
75 | | - withType<KotlinCompile<*>>().configureEach { |
76 | | - dependsOn("copyTemplates") |
77 | | - kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" |
78 | | - } |
79 | | - |
80 | | - register(name = "copyTemplates", type = Copy::class) { |
81 | | - from("src/commonMain/templates") |
82 | | - into("$buildDir/generated/sources/templates/kotlin/main") |
83 | | - expand("projectVersion" to Library.version) |
84 | | - filteringCharset = "UTF-8" |
85 | | - } |
86 | | - |
87 | | - withType<Test> { |
88 | | - maxParallelForks = Runtime.getRuntime().availableProcessors().minus(1).coerceAtLeast(1) |
89 | | - } |
90 | | -} |
91 | | - |
92 | | -configure<SpotlessExtension> { |
93 | | - kotlin { |
94 | | - target("**/*.kt") |
95 | | - ktlint("0.40.0") |
96 | | - trimTrailingWhitespace() |
97 | | - endWithNewline() |
| 6 | + val kotlinVersion = "1.5.10" |
| 7 | + classpath(kotlin("gradle-plugin", version = kotlinVersion)) |
| 8 | + classpath(kotlin("serialization", version = kotlinVersion)) |
| 9 | + classpath(MavenPublish()) |
| 10 | + classpath(Spotless()) |
98 | 11 | } |
99 | 12 | } |
100 | 13 |
|
101 | | -//** Publish **// |
102 | | -val emptyJar by tasks.creating(Jar::class) { |
103 | | - archiveAppendix.set("empty") |
| 14 | +project.extensions.extraProperties.apply { |
| 15 | + set("GROUP", Library.group) |
| 16 | + set("VERSION_NAME", Library.version) |
104 | 17 | } |
105 | 18 |
|
106 | | -publishing { |
| 19 | +subprojects { |
107 | 20 | repositories { |
108 | | - maven { |
109 | | - name = "MavenCentral" |
110 | | - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") |
111 | | - credentials { |
112 | | - username = System.getenv("SONATYPE_USER") |
113 | | - password = System.getenv("SONATYPE_KEY") |
114 | | - } |
115 | | - } |
116 | | - } |
117 | | - |
118 | | - publications.withType<MavenPublication>().all { |
119 | | - groupId = Library.group |
120 | | - version = Library.version |
121 | | - artifactId = when (name) { |
122 | | - "kotlinMultiplatform" -> Library.artifact |
123 | | - else -> "${Library.artifact}-$name" |
124 | | - } |
125 | | - |
126 | | - artifact(emptyJar) { classifier = "javadoc" } |
127 | | - |
128 | | - pom.withXml { |
129 | | - asNode().apply { |
130 | | - appendNode("name", "Algolia Search API Client for Kotlin") |
131 | | - appendNode("description", |
132 | | - "Algolia is a powerful search-as-a-service solution, made easy to use with API clients, UI libraries," + |
133 | | - "and pre-built integrations. Algolia API Client for Kotlin lets you easily use the Algolia Search" + |
134 | | - "REST API from your JVM project, such as Android or backend implementations.") |
135 | | - appendNode("url", "https://github.com/algolia/algoliasearch-client-kotlin") |
136 | | - appendNode("licenses") |
137 | | - .appendNode("license").apply { |
138 | | - appendNode("name", "MIT") |
139 | | - appendNode("url", "http://www.opensource.org/licenses/mit-license.php") |
140 | | - appendNode("distribution", "repo") |
141 | | - } |
142 | | - appendNode("developers") |
143 | | - .appendNode("developer").apply { |
144 | | - appendNode("id", "algolia") |
145 | | - appendNode("name", "The Algolia Team") |
146 | | - appendNode( "email", "[email protected]") |
147 | | - appendNode("organization", "Algolia") |
148 | | - appendNode("organizationUrl", "https://algolia.com") |
149 | | - } |
150 | | - appendNode("scm").apply { |
151 | | - appendNode("url", "https://github.com/algolia/algoliasearch-client-kotlin") |
152 | | - appendNode("connection", "scm:git:git://github.com/algolia/algoliasearch-client-kotlin.git") |
153 | | - appendNode("developerConnection", |
154 | | - "scm:git:ssh://github.com:algolia/algoliasearch-client-kotlin.git") |
155 | | - } |
156 | | - } |
157 | | - } |
| 21 | + mavenCentral() |
158 | 22 | } |
159 | 23 | } |
160 | 24 |
|
161 | | -signing { |
162 | | - val signingKeyId = System.getenv("SIGNING_KEY_ID") |
163 | | - val signingKey = System.getenv("SIGNING_KEY") |
164 | | - val signingPassword = System.getenv("SIGNING_PASSWORD") |
165 | | - useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) |
166 | | - sign(publishing.publications) |
| 25 | +tasks.register<Delete>("clean") { |
| 26 | + delete(rootProject.buildDir) |
167 | 27 | } |
0 commit comments