Project splitting and deployment

This commit is contained in:
Alexander Nozik 2022-07-16 21:34:19 +03:00
parent 7cfc76f2c7
commit 9f6386a8c2
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
20 changed files with 190 additions and 70 deletions

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
build/ build/
.gradle/ .gradle/
.idea/ .idea/
*.iml /*.iml
mapCache/ mapCache/

View File

@ -1,14 +1,12 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins { plugins {
kotlin("multiplatform") base
id("org.jetbrains.compose")
`maven-publish`
} }
group = "center.sciptog" val ktorVersion by extra("2.0.3")
version = "1.0-SNAPSHOT"
subprojects {
group = "center.sciprog"
version = "0.1.0-SNAPSHOT"
repositories { repositories {
google() google()
@ -16,43 +14,64 @@ repositories {
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
} }
val ktorVersion by extra("2.0.3") plugins.withId("maven-publish") {
kotlin { configure<PublishingExtension> {
jvm { val vcs = "https://github.com/mipt-npm/maps-kt"
compilations.all {
kotlinOptions.jvmTarget = "11" // Process each publication we have in this project
} publications {
withJava() withType<MavenPublication> {
} pom {
sourceSets { name.set(project.name)
commonMain{ description.set(project.description)
dependencies{ url.set(vcs)
api(compose.runtime)
api(compose.foundation) licenses {
api(compose.material) license {
api("io.ktor:ktor-client-core:$ktorVersion") name.set("The Apache Software License, Version 2.0")
implementation("io.ktor:ktor-client-cio:$ktorVersion") url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
implementation("io.github.microutils:kotlin-logging:2.1.23") distribution.set("repo")
}
}
val jvmMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
implementation("ch.qos.logback:logback-classic:1.2.11")
}
}
val jvmTest by getting
} }
} }
compose.desktop { developers {
application { developer {
mainClass = "MainKt" id.set("SPC")
nativeDistributions { name.set("Scientific programming centre")
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) organization.set("MIPT")
packageName = "maps-kt-compose" organizationUrl.set("https://sciprog.center/")
packageVersion = "1.0.0" }
}
scm {
url.set(vcs)
tag.set(project.version.toString())
} }
} }
} }
}
val spaceRepo = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven"
val spaceUser: String? = project.findProperty("publishing.space.user") as? String
val spaceToken: String? = project.findProperty("publishing.space.token") as? String
if (spaceUser != null && spaceToken != null) {
project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]")
repositories.maven {
name = "space"
url = uri(spaceRepo)
credentials {
username = spaceUser
password = spaceToken
}
}
}
}
}
}

40
demo/build.gradle.kts Normal file
View File

@ -0,0 +1,40 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
}
val ktorVersion: String by rootProject.extra
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
withJava()
}
sourceSets {
val jvmMain by getting {
dependencies {
implementation(projects.mapsKtCompose)
implementation(compose.desktop.currentOs)
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("ch.qos.logback:logback-classic:1.2.11")
}
}
val jvmTest by getting
}
}
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "maps-kt-compose"
packageVersion = "1.0.0"
}
}
}

View File

@ -1,4 +1,5 @@
kotlin.code.style=official kotlin.code.style=official
kotlin.version=1.6.10 kotlin.version=1.6.10
agp.version=4.2.2
compose.version=1.1.1 compose.version=1.1.1
agp.version=4.2.2
android.useAndroidX=true

View File

@ -0,0 +1,29 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
`maven-publish`
}
val ktorVersion: String by rootProject.extra
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
sourceSets {
commonMain{
dependencies{
api(projects.mapsKtCore)
api(compose.foundation)
api("io.ktor:ktor-client-core:$ktorVersion")
}
}
val jvmMain by getting
val jvmTest by getting
}
}

View File

@ -31,6 +31,17 @@ private fun Color.toPaint(): Paint = Paint().apply {
private fun IntRange.intersect(other: IntRange) = max(first, other.first)..min(last, other.last) private fun IntRange.intersect(other: IntRange) = max(first, other.first)..min(last, other.last)
internal fun MapViewPoint.move(deltaX: Double, deltaY: Double): MapViewPoint {
val newCoordinates = GeodeticMapCoordinates.ofRadians(
(focus.latitude + deltaY / scaleFactor).coerceIn(
-MercatorProjection.MAXIMUM_LATITUDE,
MercatorProjection.MAXIMUM_LATITUDE
),
focus.longitude + deltaX / scaleFactor
)
return MapViewPoint(newCoordinates, zoom)
}
private val logger = KotlinLogging.logger("MapView") private val logger = KotlinLogging.logger("MapView")
/** /**

View File

@ -0,0 +1,26 @@
plugins {
kotlin("multiplatform")
`maven-publish`
}
val ktorVersion: String by rootProject.extra
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
}
js(IR){
browser()
}
sourceSets {
commonMain{
dependencies{
api("io.github.microutils:kotlin-logging:2.1.23")
}
}
val jvmMain by getting
val jvmTest by getting
}
}

View File

@ -1,14 +1,12 @@
package centre.sciprog.maps package centre.sciprog.maps
import androidx.compose.ui.unit.DpSize
import centre.sciprog.maps.compose.MapFeature
import kotlin.math.* import kotlin.math.*
class GmcBox(val a: GeodeticMapCoordinates, val b: GeodeticMapCoordinates) class GmcBox(val a: GeodeticMapCoordinates, val b: GeodeticMapCoordinates)
fun GmcBox(latitudes: ClosedFloatingPointRange<Double>, longitudes: ClosedFloatingPointRange<Double>) = GmcBox( fun GmcBox(latitudes: ClosedFloatingPointRange<Double>, longitudes: ClosedFloatingPointRange<Double>) = GmcBox(
Gmc.ofRadians(latitudes.start, longitudes.start), GeodeticMapCoordinates.ofRadians(latitudes.start, longitudes.start),
Gmc.ofRadians(latitudes.endInclusive, longitudes.endInclusive) GeodeticMapCoordinates.ofRadians(latitudes.endInclusive, longitudes.endInclusive)
) )
val GmcBox.center val GmcBox.center

View File

@ -1,7 +1,6 @@
package centre.sciprog.maps package centre.sciprog.maps
import kotlin.math.pow import kotlin.math.pow
import kotlin.math.roundToInt
/** /**
* Observable position on the map. Includes observation coordinate and [zoom] factor * Observable position on the map. Includes observation coordinate and [zoom] factor
@ -13,20 +12,6 @@ data class MapViewPoint(
val scaleFactor by lazy { WebMercatorProjection.scaleFactor(zoom) } val scaleFactor by lazy { WebMercatorProjection.scaleFactor(zoom) }
} }
/**
*
*/
internal fun MapViewPoint.move(deltaX: Double, deltaY: Double): MapViewPoint {
val newCoordinates = GeodeticMapCoordinates.ofRadians(
(focus.latitude + deltaY / scaleFactor).coerceIn(
-MercatorProjection.MAXIMUM_LATITUDE,
MercatorProjection.MAXIMUM_LATITUDE
),
focus.longitude + deltaX / scaleFactor
)
return MapViewPoint(newCoordinates, zoom)
}
fun MapViewPoint.move(delta: GeodeticMapCoordinates): MapViewPoint { fun MapViewPoint.move(delta: GeodeticMapCoordinates): MapViewPoint {
val newCoordinates = GeodeticMapCoordinates.ofRadians( val newCoordinates = GeodeticMapCoordinates.ofRadians(
(focus.latitude + delta.latitude).coerceIn( (focus.latitude + delta.latitude).coerceIn(

View File

@ -1,4 +1,7 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. rootProject.name = "maps-kt"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement { pluginManagement {
repositories { repositories {
google() google()
@ -9,9 +12,17 @@ pluginManagement {
plugins { plugins {
kotlin("multiplatform").version(extra["kotlin.version"] as String) kotlin("multiplatform").version(extra["kotlin.version"] as String)
kotlin("android").version(extra["kotlin.version"] as String)
id("com.android.application").version(extra["agp.version"] as String)
id("com.android.library").version(extra["agp.version"] as String)
id("org.jetbrains.compose").version(extra["compose.version"] as String) id("org.jetbrains.compose").version(extra["compose.version"] as String)
} }
} }
rootProject.name = "maps-kt"
include(
":maps-kt-core",
":maps-kt-compose",
":demo"
)