Skip to content

Commit

Permalink
Switch 'platf' modules to Kotlin JVM plugin (#1273)
Browse files Browse the repository at this point in the history
  • Loading branch information
VDovidaytis-HORIS authored Dec 26, 2024
1 parent 471d5a6 commit 27fd1bb
Show file tree
Hide file tree
Showing 53 changed files with 104 additions and 185 deletions.
109 changes: 77 additions & 32 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.gradle.internal.os.OperatingSystem
import org.gradle.jvm.tasks.Jar
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import java.io.ByteArrayOutputStream
import java.io.FileNotFoundException
Expand Down Expand Up @@ -161,14 +162,10 @@ nexusPublishing {
// Publish some sub-projects as Kotlin Multi-project libraries.
val publishLetsPlotCoreModulesToMavenLocalRepository by tasks.registering {
group=letsPlotTaskGroup
// Add platf-jfx-swing JVM publish task:
dependsOn("platf-jfx-swing:publishPlatfJfxSwingJvmPublicationToMavenLocalRepository")
}

val publishLetsPlotCoreModulesToMavenRepository by tasks.registering {
group=letsPlotTaskGroup
// Add platf-jfx-swing JVM publish task:
dependsOn("platf-jfx-swing:publishPlatfJfxSwingJvmPublicationToMavenRepository")
}

// Generating JavaDoc task for each publication task.
Expand All @@ -186,7 +183,7 @@ fun getJarJavaDocsTask(distributeName:String): TaskProvider<Jar> {
}
}


// Configure native targets for python-extension dependencies.
subprojects {
val pythonExtensionModules = listOf(
"commons",
Expand Down Expand Up @@ -226,39 +223,85 @@ subprojects {
}
}
}
}

val coreModulesForPublish = listOf(
"commons",
"datamodel",
"canvas",
"gis",
"livemap",
"plot-base",
"plot-builder",
"plot-stem",
"plot-livemap",
"platf-awt",
"platf-batik",
"deprecated-in-v4"
)
// Configure Lets-Plot Core multiplatform modules.
val multiPlatformCoreModulesForPublish = listOf(
"commons",
"datamodel",
"canvas",
"gis",
"livemap",
"plot-base",
"plot-builder",
"plot-stem",
"plot-livemap",
"deprecated-in-v4"
)

if (name in coreModulesForPublish) {
subprojects {
if (name in multiPlatformCoreModulesForPublish) {
apply(plugin = "org.jetbrains.kotlin.multiplatform")
apply(plugin = "maven-publish")
apply(plugin = "signing")

// For `jvmSourcesJar` task:
configure<KotlinMultiplatformExtension> {
jvm()
}
}
}

// Configure Lets-Plot Core JVM modules.
val jvmCoreModulesForPublish = listOf(
"platf-awt",
"platf-batik",
"platf-jfx-swing"
)

subprojects {
if(name in jvmCoreModulesForPublish) {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "maven-publish")

configure<KotlinJvmProjectExtension> {
tasks.register<Jar>("${name}-jvm-sources") {
archiveClassifier.set("sources")
from(sourceSets.getByName("main").kotlin.srcDirs)
}
}

configure<PublishingExtension> {
publications {
register("$name-jvm", MavenPublication::class) {
groupId = project.group as String
artifactId = name
version = project.version as String

artifact(tasks["jar"])
artifact(tasks["${name}-sources"])
}
}
}
}
}

// Configure Maven publication for Lets-Plot Core modules.
subprojects {
if(name in multiPlatformCoreModulesForPublish + jvmCoreModulesForPublish) {
apply(plugin = "maven-publish")
apply(plugin = "signing")
// Do not publish 'native' targets:
val publicationsToPublish = listOf("jvm", "js", "kotlinMultiplatform", "metadata")
val targetsToPublish = listOf(
"platf-awt-jvm",
"platf-batik-jvm",
"platf-jfx-swing-jvm",
"jvm",
"js",
"kotlinMultiplatform",
"metadata")

configure<PublishingExtension> {
publications {
withType(MavenPublication::class) {
if (name in publicationsToPublish) {
if (name in targetsToPublish) {
// Configure this publication.
artifact(getJarJavaDocsTask("${name}-${project.name}"))

Expand Down Expand Up @@ -293,22 +336,24 @@ subprojects {
}
}
}

afterEvaluate {
// Add LICENSE file to the META-INF folder inside published JAR files.
tasks.named<Jar>("jvmJar") {
metaInf {
from("$rootDir") {
include("LICENSE")
tasks.filterIsInstance<Jar>()
.forEach {
if (it.name == "jvmJar" || it.name == "jar") { // "jar" for 'org.jetbrains.kotlin.jvm' plugin
it.metaInf {
from("$rootDir") {
include("LICENSE")
}
}
}
}
}

// Configure artifacts signing process for release versions.
val publicationsToSign = mutableListOf<Publication>()

for (task in tasks.withType(PublishToMavenRepository::class)) {
if (task.publication.name in publicationsToPublish) {
if (task.publication.name in targetsToPublish) {
val repoName = task.repository.name

if (repoName == "MavenLocal") {
Expand Down
42 changes: 10 additions & 32 deletions platf-awt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,14 @@
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/

plugins {
kotlin("multiplatform")
}

kotlin {
jvm()

sourceSets {
commonMain {
dependencies {
compileOnly(project(":commons"))
compileOnly(project(":datamodel"))
compileOnly(project(":plot-livemap"))
compileOnly(project(":canvas"))
compileOnly(project(":plot-base"))
compileOnly(project(":plot-builder"))
compileOnly(project(":plot-stem"))
}
}

commonTest {
dependencies {
implementation(project(":demo-and-test-shared"))
}
}

jvmTest {
dependencies {
implementation(kotlin("test-junit"))
}
}
}
dependencies {
compileOnly(project(":commons"))
compileOnly(project(":datamodel"))
compileOnly(project(":plot-livemap"))
compileOnly(project(":canvas"))
compileOnly(project(":plot-base"))
compileOnly(project(":plot-builder"))
compileOnly(project(":plot-stem"))
testImplementation(project(":demo-and-test-shared"))
testImplementation(kotlin("test-junit"))
}
59 changes: 16 additions & 43 deletions platf-batik/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,22 @@
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/

plugins {
kotlin("multiplatform")
}

val batikVersion = project.extra["batik_version"] as String

kotlin {
jvm()

sourceSets {
commonMain {
dependencies {
compileOnly(project(":commons"))
compileOnly(project(":datamodel"))
compileOnly(project(":plot-stem"))
}
}

commonTest {
dependencies {
implementation(project(":commons"))
implementation(project(":datamodel"))
implementation(project(":plot-base"))
implementation(project(":plot-builder"))
implementation(project(":plot-stem"))
implementation(project(":demo-and-test-shared"))
}
}

jvmMain {
dependencies {
compileOnly(project(":platf-awt"))
compileOnly("org.apache.xmlgraphics:batik-codec:$batikVersion")
}
}

jvmTest {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
implementation("org.apache.xmlgraphics:batik-codec:$batikVersion")
implementation(project(":platf-awt"))
}
}
}
dependencies {
compileOnly(project(":commons"))
compileOnly(project(":datamodel"))
compileOnly(project(":plot-stem"))
compileOnly(project(":platf-awt"))
compileOnly("org.apache.xmlgraphics:batik-codec:$batikVersion")
testImplementation(project(":commons"))
testImplementation(project(":datamodel"))
testImplementation(project(":plot-base"))
testImplementation(project(":plot-builder"))
testImplementation(project(":plot-stem"))
testImplementation(project(":demo-and-test-shared"))
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit"))
testImplementation("org.apache.xmlgraphics:batik-codec:$batikVersion")
testImplementation(project(":platf-awt"))
}
77 changes: 0 additions & 77 deletions platf-jfx-swing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,19 @@ import org.gradle.jvm.tasks.Jar
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/

plugins {
kotlin("jvm")
`maven-publish`
signing
}

val artifactBaseName = "platf-jfx-swing-jvm"
val artifactGroupId = project.group as String
val artifactVersion = project.version as String
val jfxVersion = project.extra["jfx_version"] as String
val jfxPlatform = project.extra["jfxPlatformResolved"] as String
val mavenLocalPath = rootProject.project.extra["localMavenRepository"]

dependencies {
compileOnly(project("::platf-awt"))
compileOnly(project(":commons"))
compileOnly(project(":datamodel"))
compileOnly(project(":canvas"))
compileOnly(project(":plot-stem"))

compileOnly("org.openjfx:javafx-base:$jfxVersion:$jfxPlatform")
compileOnly("org.openjfx:javafx-graphics:$jfxVersion:$jfxPlatform")
compileOnly("org.openjfx:javafx-swing:$jfxVersion:$jfxPlatform")

compileOnly(project(":platf-awt"))

testImplementation(project(":demo-and-test-shared"))
testImplementation(project(":platf-awt"))
testImplementation(kotlin("test"))
Expand All @@ -39,67 +26,3 @@ dependencies {
testImplementation("org.openjfx:javafx-graphics:$jfxVersion:$jfxPlatform")
testImplementation("org.openjfx:javafx-swing:$jfxVersion:$jfxPlatform")
}

tasks {
jar {
from(rootProject.file("LICENSE")) {
into("META-INF")
}
}
val platfJfxSwingJvmSourcesJar by creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
val platfJfxSwingJvmJavadocJar by creating(Jar::class) {
archiveClassifier.set("javadoc")
from("$rootDir/README.md")
}
}

publishing {
publications {
register("platfJfxSwingJvm", MavenPublication::class) {

groupId = artifactGroupId
artifactId = artifactBaseName
version = artifactVersion

artifact(tasks["jar"])
artifact(tasks["platfJfxSwingJvmSourcesJar"])
artifact(tasks["platfJfxSwingJvmJavadocJar"])

pom {
name = "Lets-Plot core artifact"
description = "A part of the Lets-Plot library."

url = "https://github.com/JetBrains/lets-plot"
licenses {
license {
name = "MIT"
url = "https://raw.githubusercontent.com/JetBrains/lets-plot/master/LICENSE"
}
}
developers {
developer {
id = "jetbrains"
name = "JetBrains"
email = "[email protected]"
}
}
scm {
url = "https://github.com/JetBrains/lets-plot"
}
}
}
}
repositories {
mavenLocal {
url = uri("$mavenLocalPath")
}
}
}
signing {
if (!project.version.toString().contains("SNAPSHOT")) {
sign(publishing.publications["platfJfxSwingJvm"])
}
}
2 changes: 1 addition & 1 deletion plot-image-export/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ publishing {

dep = deps.appendNode("dependency")
dep.appendNode("groupId", project.group)
dep.appendNode("artifactId", "platf-awt")
dep.appendNode("artifactId", "platf-awt-jvm")
dep.appendNode("version", project.version)

}
Expand Down

0 comments on commit 27fd1bb

Please sign in to comment.