summaryrefslogtreecommitdiff
path: root/buildSrc/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-06 16:16:10 +0200
committerGitHub <noreply@github.com>2021-05-06 16:16:10 +0200
commit375f329d6b276f802aafc14ce90520e807398d6e (patch)
tree69f1a0edf7223e42e143e2d1d094c6eaaad0c400 /buildSrc/src
parente1d892bcbaa7e8361c150f684ca6a0dc5e036a87 (diff)
parentd4eb8ccd4f5d93d9e858b9c3ed6ff48763e68820 (diff)
chore: Prepare for OpenDC 2.0 release (v2)
This pull request performs several preparations for the official release of OpenDC 2.0. With this pull request, we focus on the deployment of OpenDC to DockerHub and Maven Central. * Add workflow for creating releases on Github and publishing to Maven Central * Add workflow for publishing images on DockerHub * Add support for runtime variables in frontend Docker image * Add support for building Dokka documentation
Diffstat (limited to 'buildSrc/src')
-rw-r--r--buildSrc/src/main/kotlin/experiment-conventions.gradle.kts2
-rw-r--r--buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts44
-rw-r--r--buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts23
-rw-r--r--buildSrc/src/main/kotlin/publishing-conventions.gradle.kts107
4 files changed, 156 insertions, 20 deletions
diff --git a/buildSrc/src/main/kotlin/experiment-conventions.gradle.kts b/buildSrc/src/main/kotlin/experiment-conventions.gradle.kts
index 580f67cb..26780205 100644
--- a/buildSrc/src/main/kotlin/experiment-conventions.gradle.kts
+++ b/buildSrc/src/main/kotlin/experiment-conventions.gradle.kts
@@ -23,8 +23,8 @@ import gradle.kotlin.dsl.accessors._9bf86420fccbde1948375f641de89b70.sourceSets
*/
plugins {
- `java-library`
distribution
+ id("kotlin-conventions")
id("com.github.johnrengelman.shadow")
}
diff --git a/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts
new file mode 100644
index 00000000..7bab52fc
--- /dev/null
+++ b/buildSrc/src/main/kotlin/kotlin-conventions.gradle.kts
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+
+plugins {
+ `java-library`
+ kotlin("jvm")
+ id("org.jlleitschuh.gradle.ktlint")
+}
+
+/* Project configuration */
+repositories {
+ mavenCentral()
+}
+
+java {
+ sourceCompatibility = Versions.jvmTarget
+}
+
+tasks.withType<KotlinCompile>().configureEach {
+ kotlinOptions.jvmTarget = Versions.jvmTarget.toString()
+ kotlinOptions.useIR = true
+ kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
+}
diff --git a/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts b/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts
index 43b1d148..296d5967 100644
--- a/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts
+++ b/buildSrc/src/main/kotlin/kotlin-library-conventions.gradle.kts
@@ -1,7 +1,5 @@
/*
- * MIT License
- *
- * Copyright (c) 2019 atlarge-research
+ * Copyright (c) 2021 AtLarge Research
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -22,30 +20,17 @@
* SOFTWARE.
*/
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-
plugins {
- `java-library`
- kotlin("jvm")
- id("org.jlleitschuh.gradle.ktlint")
+ id("kotlin-conventions")
+ id("publishing-conventions")
id("dokka-conventions")
}
/* Project configuration */
-repositories {
- mavenCentral()
-}
-
java {
- sourceCompatibility = Versions.jvmTarget
+ withSourcesJar()
}
kotlin {
explicitApi()
}
-
-tasks.withType<KotlinCompile>().configureEach {
- kotlinOptions.jvmTarget = Versions.jvmTarget.toString()
- kotlinOptions.useIR = true
- kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
-}
diff --git a/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts b/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts
new file mode 100644
index 00000000..76f54102
--- /dev/null
+++ b/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2021 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.gradle.api.credentials.PasswordCredentials
+
+plugins {
+ `maven-publish`
+ signing
+ id("dokka-conventions")
+}
+
+val isSnapshot = project.version.toString().contains("SNAPSHOT")
+
+// Ensure project is built successfully before publishing it
+tasks.withType<PublishToMavenRepository>().configureEach {
+ dependsOn(tasks.build)
+}
+tasks.withType<PublishToMavenLocal>().configureEach {
+ dependsOn(tasks.build)
+}
+
+val javadocJar by tasks.registering(Jar::class) {
+ // Note that we publish the Dokka HTML artifacts as Javadoc
+ dependsOn(tasks.dokkaHtml)
+ archiveClassifier.set("javadoc")
+ from(tasks.dokkaHtml)
+}
+
+signing {
+ val signingKeyId: String? by project
+ val signingKey: String? by project
+ val signingPassword: String? by project
+
+ if (!signingKey.isNullOrBlank()) {
+ if (signingKeyId?.isNotBlank() == true) {
+ useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
+ } else {
+ useInMemoryPgpKeys(signingKey, signingPassword)
+ }
+ }
+
+ sign(publishing.publications)
+}
+
+publishing {
+ publications {
+ create<MavenPublication>("maven") {
+ from(components["java"])
+ artifact(javadocJar)
+
+ pom {
+ name.set(project.name)
+ description.set("Open-source platform for datacenter simulation")
+ url.set("https://opendc.org")
+ licenses {
+ license {
+ name.set("MIT")
+ url.set("https://opensource.org/licenses/MIT")
+ }
+ }
+ developers {
+ developer {
+ id.set("AtLarge Research")
+ name.set("AtLarge Research Team")
+ organization.set("AtLarge Research")
+ organizationUrl.set("https://atlarge-research.com")
+ }
+ }
+ scm {
+ connection.set("scm:git:git://github.com/atlarge-research/opendc.git")
+ developerConnection.set("scm:git:git://github.com/atlarge-research/opendc.git")
+ url.set("https://github.com/atlarge-research/opendc")
+ }
+ }
+ }
+ }
+
+ repositories {
+ maven {
+ val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
+ val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
+
+ name = "ossrh"
+ url = if (isSnapshot) snapshotsRepoUrl else releasesRepoUrl
+ credentials(PasswordCredentials::class)
+ }
+ }
+}