|
1 |
| -import java.net.HttpURLConnection |
2 |
| -import kotlin.io.encoding.Base64 |
3 |
| -import kotlin.io.encoding.ExperimentalEncodingApi |
4 |
| - |
5 | 1 | plugins {
|
6 | 2 | `java-library`
|
7 |
| - `maven-publish` |
8 |
| - signing |
9 | 3 | id("com.diffplug.spotless") version "7.0.2"
|
| 4 | + id("com.quantori.cqp-build") |
10 | 5 | }
|
11 | 6 |
|
12 |
| -group = "com.quantori" |
13 | 7 | description = "Chem query platform. Compound quick search"
|
14 | 8 | version = "0.0.10"
|
15 | 9 |
|
16 |
| -repositories { |
17 |
| - mavenLocal() |
18 |
| - mavenCentral() |
19 |
| -} |
20 |
| - |
21 |
| -java { |
22 |
| - toolchain { |
23 |
| - languageVersion = JavaLanguageVersion.of(17) |
24 |
| - } |
25 |
| - withSourcesJar() |
26 |
| - withJavadocJar() |
27 |
| -} |
28 |
| - |
29 |
| -publishing { |
30 |
| - publications { |
31 |
| - create<MavenPublication>("mavenJava") { |
32 |
| - from(components["java"]) |
33 |
| - |
34 |
| - pom { |
35 |
| - artifactId = "cqp-core" |
36 |
| - name = project.name |
37 |
| - description = project.description |
38 |
| - packaging = "jar" |
39 |
| - url = "https://github.com/quantori/chem-query-platform" |
40 |
| - |
41 |
| - licenses { |
42 |
| - license { |
43 |
| - name = "The Apache License, Version 2.0" |
44 |
| - url = "https://www.apache.org/licenses/LICENSE-2.0.txt" |
45 |
| - } |
46 |
| - } |
47 |
| - |
48 |
| - developers { |
49 |
| - developer { |
50 |
| - id = "artem.chukin" |
51 |
| - name = "Artem Chukin" |
52 |
| - email = "artem.chukin@quantori.com" |
53 |
| - } |
54 |
| - developer { |
55 |
| - id = "dmitriy gusev" |
56 |
| - name = "Dmitriy Gusev" |
57 |
| - email = "dmitriy.gusev@quantori.com" |
58 |
| - } |
59 |
| - |
60 |
| - developer { |
61 |
| - id = "valeriy burmistrov" |
62 |
| - name = "Valeriy Burmistrov" |
63 |
| - email = "valeriy.burmistrov@quantori.com" |
64 |
| - } |
65 |
| - |
66 |
| - developer { |
67 |
| - id = "boris sukhodoev" |
68 |
| - name = "Boris Sukhodoev" |
69 |
| - email = "boris.sukhodoev@quantori.com" |
70 |
| - } |
71 |
| - } |
72 |
| - |
73 |
| - scm { |
74 |
| - connection = "scm:git:git://github.com/quantori/chem-query-platform.git" |
75 |
| - developerConnection = "scm:git:ssh://github.com/quantori/chem-query-platform.git" |
76 |
| - url = "https://github.com/quantori/chem-query-platform" |
77 |
| - } |
78 |
| - } |
79 |
| - } |
80 |
| - } |
81 |
| - repositories { |
82 |
| - maven { |
83 |
| - name = "localStaging" |
84 |
| - // change URLs to point to your repos, e.g. http://my.org/repo |
85 |
| - val releasesRepoUrl = uri(layout.buildDirectory.dir("repos/releases")) |
86 |
| - val snapshotsRepoUrl = uri(layout.buildDirectory.dir("repos/snapshots")) |
87 |
| - url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl |
88 |
| - } |
89 |
| - } |
90 |
| -} |
91 |
| - |
92 |
| -tasks.test { |
93 |
| - useJUnitPlatform() |
94 |
| - testLogging { |
95 |
| - events("passed", "skipped", "failed") |
96 |
| - } |
97 |
| -} |
98 |
| - |
99 |
| -artifacts { |
100 |
| - archives(tasks.named("javadocJar")) |
101 |
| - archives(tasks.named("sourcesJar")) |
102 |
| -} |
103 |
| - |
104 |
| -signing { |
105 |
| - setRequired { |
106 |
| - !version.toString().endsWith("SNAPSHOT") && gradle.taskGraph.hasTask("publish") |
107 |
| - } |
108 |
| - val signingSecretKey = findProperty("signing.secretKey") as String? ?: System.getenv("GPG_SIGNING_SECRET_KEY") |
109 |
| - val signingPassword = findProperty("signing.password") as String? ?: System.getenv("GPG_SIGNING_PASSWORD") |
110 |
| - |
111 |
| - useInMemoryPgpKeys(signingSecretKey, signingPassword) |
112 |
| - sign(publishing.publications["mavenJava"]) |
113 |
| - sign(configurations.archives.get()) |
114 |
| -} |
115 |
| - |
116 |
| -// Fix Javadoc warnings on JDK 9+ (optional but recommended) |
117 |
| -if (JavaVersion.current().isJava9Compatible) { |
118 |
| - tasks.withType<Javadoc>().configureEach { |
119 |
| - (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet") |
120 |
| - (options as StandardJavadocDocletOptions).addBooleanOption("html5", true) |
121 |
| - } |
122 |
| -} |
123 |
| - |
124 |
| -@OptIn(ExperimentalEncodingApi::class) |
125 |
| -fun String.toBase64(): String { |
126 |
| - return Base64.encode(this.toByteArray(Charsets.UTF_8)) |
127 |
| -} |
128 |
| - |
129 |
| -val publishToLocalStaging = tasks.getByName("publishMavenJavaPublicationToLocalStagingRepository") |
130 |
| - |
131 |
| -publishToLocalStaging.outputs.dir(layout.buildDirectory.dir("repos/releases")) |
132 |
| - |
133 |
| -val zipBundle by tasks.registering(Zip::class) { |
134 |
| - archiveFileName = "central-bundle.zip" |
135 |
| - destinationDirectory = project.layout.buildDirectory.dir("distributions") |
136 |
| - inputs.files(publishToLocalStaging.outputs.files) |
137 |
| - from(publishToLocalStaging.outputs.files.files) |
138 |
| -} |
139 |
| - |
140 |
| -val uploadToMavenCentral by tasks.registering { |
141 |
| - val url = uri("https://central.sonatype.com/api/v1/publisher/upload").toURL() |
142 |
| - val boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW" |
143 |
| - inputs.file(zipBundle.map { it.archiveFile }.get()) |
144 |
| - doLast { |
145 |
| - val file = zipBundle.get().archiveFile.get().asFile |
146 |
| - val mavenCentralUsername = |
147 |
| - findProperty("mavenCentralUsername") as String? ?: System.getenv("MAVEN_CENTRAL_USERNAME") |
148 |
| - val mavenCentralPassword = |
149 |
| - findProperty("mavenCentralPassword") as String? ?: System.getenv("MAVEN_CENTRAL_PASSWORD") |
150 |
| - val token = "$mavenCentralUsername:$mavenCentralPassword\n".toBase64() |
151 |
| - |
152 |
| - val connection = (url.openConnection() as HttpURLConnection).apply { |
153 |
| - requestMethod = "POST" |
154 |
| - doOutput = true |
155 |
| - setRequestProperty("Authorization", "Bearer $token") |
156 |
| - setRequestProperty("Content-Type", "multipart/form-data; boundary=$boundary") |
157 |
| - } |
158 |
| - |
159 |
| - val outputStream = connection.outputStream |
160 |
| - outputStream.bufferedWriter().use { writer -> |
161 |
| - writer.append("--$boundary\r\n") |
162 |
| - writer.append("Content-Disposition: form-data; name=\"bundle\"; filename=\"${file.name}\"\r\n") |
163 |
| - writer.append("Content-Type: application/octet-stream\r\n\r\n") |
164 |
| - writer.flush() |
165 |
| - |
166 |
| - file.inputStream().use { it.copyTo(outputStream) } |
167 |
| - |
168 |
| - writer.append("\r\n--$boundary--\r\n") |
169 |
| - writer.flush() |
170 |
| - } |
171 |
| - |
172 |
| - val responseCode = connection.responseCode |
173 |
| - println("Response Code: $responseCode") |
174 |
| - println("Response Message: ${connection.inputStream.bufferedReader().readText()}") |
175 |
| - } |
176 |
| -} |
177 |
| - |
178 |
| - |
179 |
| - |
180 |
| - |
181 | 10 | dependencies {
|
182 | 11 | implementation("com.lightbend.akka.discovery:akka-discovery-aws-api_2.13:1.5.0-M1")
|
183 | 12 | implementation("com.typesafe.akka:akka-discovery_2.13:2.9.0-M2")
|
|
0 commit comments