Merge pull request #2 from InsanusMokrassar/rewrite_on_multiplatform

rewrite on multiplatform
This commit is contained in:
InsanusMokrassar 2021-03-01 21:20:34 +06:00 committed by GitHub
commit 741ee98e35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 353 additions and 126 deletions

View File

@ -1,16 +0,0 @@
name: Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Gradle
run: ./gradlew build

View File

@ -13,8 +13,12 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 11
- name: Set version from gradle.properties
run: echo "version=` cat gradle.properties | grep ^version= | grep -o [\\.0-9]* `" >> $GITHUB_ENV
- name: Build
run: ./gradlew packageUberJarForCurrentOS
env:
additional_version: ""
- name: Create Release
id: create_release
uses: actions/create-release@v1
@ -22,7 +26,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: build-${{ github.sha }}
release_name: Commit ${{ github.sha }}
release_name: "Build #${{ github.run_number }}"
body: It is just temporal release for ${{ github.sha }} commit
draft: false
prerelease: true
@ -33,6 +37,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./build/compose/jars/KotlinPublicationScriptsBuilder-linux-x64.jar
asset_path: "./desktop/build/compose/jars/kmppscriptbuilder.desktop-linux-x64-${{ env.version }}${{ env.additional_version }}.jar"
asset_name: KotlinPublicationScriptsBuilder-linux-x64.jar
asset_content_type: application/java-archive

2
.gitignore vendored
View File

@ -8,3 +8,5 @@ settings.xml
.gradle/
build/
out/
local.properties

View File

@ -1,53 +1,31 @@
buildscript {
repositories {
jcenter()
google()
mavenCentral()
mavenLocal()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "com.getkeepsafe.dexcount:dexcount-gradle-plugin:$dexcount_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokka_version"
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
google()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://maven.pkg.jetbrains.space/public/p/compose/dev" }
}
}
plugins {
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
id("org.jetbrains.compose") version "$compose_version"
}
apply plugin: 'kotlin'
project.group = "com.insanusmokrassar"
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://maven.pkg.jetbrains.space/public/p/compose/dev" }
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version"
implementation "dev.inmo:micro_utils.coroutines:$micro_utils_version"
implementation(compose.desktop.currentOs)
implementation "io.ktor:ktor-client:$ktor_version"
implementation "io.ktor:ktor-client-cio:$ktor_version"
}
compose.desktop {
application {
mainClass = "com.insanusmokrassar.kmppscriptbuilder.BuilderKt"
}
}
compileKotlin {
kotlinOptions {
jvmTarget = "11"
useIR = true
}
}
apply from: "./extensions.gradle"
// apply from: "./github_release.gradle"

20
core/build.gradle Normal file
View File

@ -0,0 +1,20 @@
plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
id "com.android.library"
}
apply from: "$mppProjectWithSerializationPresetPath"
kotlin {
sourceSets {
commonMain {
dependencies {
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
api "dev.inmo:micro_utils.coroutines:$micro_utils_version"
api "io.ktor:ktor-client-core:$ktor_version"
}
}
}
}

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.kmppscriptbuilder.export.jvm_only
package dev.inmo.kmppscriptbuilder.core.export.jvm_only
import com.insanusmokrassar.kmppscriptbuilder.models.*
import dev.inmo.kmppscriptbuilder.core.models.*
fun MavenConfig.buildJvmOnlyMavenConfig(licenses: List<License>): String = """
apply plugin: 'maven-publish'

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.kmppscriptbuilder.export.mpp
package dev.inmo.kmppscriptbuilder.core.export.mpp
import com.insanusmokrassar.kmppscriptbuilder.models.*
import dev.inmo.kmppscriptbuilder.core.models.*
fun MavenConfig.buildMultiplatformMavenConfig(licenses: List<License>): String = """
apply plugin: 'maven-publish'

View File

@ -1,7 +1,7 @@
package com.insanusmokrassar.kmppscriptbuilder.models
package dev.inmo.kmppscriptbuilder.core.models
import com.insanusmokrassar.kmppscriptbuilder.export.jvm_only.buildJvmOnlyMavenConfig
import com.insanusmokrassar.kmppscriptbuilder.export.mpp.buildMultiplatformMavenConfig
import dev.inmo.kmppscriptbuilder.core.export.jvm_only.buildJvmOnlyMavenConfig
import dev.inmo.kmppscriptbuilder.core.export.mpp.buildMultiplatformMavenConfig
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.SerialDescriptor
@ -16,7 +16,7 @@ sealed class ProjectType {
}
@Serializer(ProjectType::class)
internal object ProjectTypeSerializer : KSerializer<ProjectType> {
object ProjectTypeSerializer : KSerializer<ProjectType> {
override val descriptor: SerialDescriptor = String.serializer().descriptor
override fun deserialize(decoder: Decoder): ProjectType {
return when (decoder.decodeString()) {

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder.models
package dev.inmo.kmppscriptbuilder.core.models
import kotlinx.serialization.Serializable

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.kmppscriptbuilder.models
package dev.inmo.kmppscriptbuilder.core.models
import com.insanusmokrassar.kmppscriptbuilder.utils.serialFormat
import dev.inmo.kmppscriptbuilder.core.utils.serialFormat
import io.ktor.client.HttpClient
import io.ktor.client.request.get
import io.ktor.client.request.url

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder.models
package dev.inmo.kmppscriptbuilder.core.models
import kotlinx.serialization.Serializable

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder.utils
package dev.inmo.kmppscriptbuilder.core.utils
import kotlinx.serialization.json.Json

View File

@ -0,0 +1 @@
<manifest package="dev.inmo.KotlinPublicationScriptsBuilder.core"/>

View File

@ -0,0 +1,40 @@
apply plugin: 'com.getkeepsafe.dexcount'
android {
compileSdkVersion "$android_compileSdkVersion".toInteger()
buildToolsVersion "$android_buildToolsVersion"
defaultConfig {
minSdkVersion "$android_minSdkVersion".toInteger()
targetSdkVersion "$android_compileSdkVersion".toInteger()
versionCode "${android_code_version}".toInteger()
versionName "$version"
}
buildTypes {
release {
minifyEnabled false
}
debug {
debuggable true
}
}
packagingOptions {
exclude 'META-INF/kotlinx-serialization-runtime.kotlin_module'
exclude 'META-INF/kotlinx-serialization-cbor.kotlin_module'
exclude 'META-INF/kotlinx-serialization-properties.kotlin_module'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}

37
desktop/build.gradle Normal file
View File

@ -0,0 +1,37 @@
plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
id("org.jetbrains.compose") version "$compose_version"
}
apply from: "$mppJavaProjectPresetPath"
kotlin {
jvm {
compilations.main.kotlinOptions {
jvmTarget = "11"
useIR = true
}
}
sourceSets {
commonMain {
dependencies {
implementation project(":kmppscriptbuilder.core")
}
}
jvmMain {
dependencies {
implementation(compose.desktop.currentOs)
api "io.ktor:ktor-client-cio:$ktor_version"
}
}
}
}
compose.desktop {
application {
mainClass = "dev.inmo.kmppscriptbuilder.desktop.BuilderKt"
}
}

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder
package dev.inmo.kmppscriptbuilder.desktop
import androidx.compose.desktop.Window
import androidx.compose.foundation.*
@ -7,8 +7,8 @@ import androidx.compose.material.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import com.insanusmokrassar.kmppscriptbuilder.utils.*
import com.insanusmokrassar.kmppscriptbuilder.views.*
import dev.inmo.kmppscriptbuilder.desktop.utils.*
import dev.inmo.kmppscriptbuilder.desktop.views.*
import java.io.File
//private val uncaughtExceptionsBC = BroadcastChannel<DefaultErrorHandler.ErrorEvent>(Channel.CONFLATED)

View File

@ -1,6 +1,7 @@
package com.insanusmokrassar.kmppscriptbuilder.utils
package dev.inmo.kmppscriptbuilder.desktop.utils
import com.insanusmokrassar.kmppscriptbuilder.models.Config
import dev.inmo.kmppscriptbuilder.core.models.Config
import dev.inmo.kmppscriptbuilder.core.utils.serialFormat
import java.io.File
import javax.swing.JFileChooser

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder.utils
package dev.inmo.kmppscriptbuilder.desktop.utils
import java.io.File
import javax.swing.filechooser.FileFilter

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder.utils
package dev.inmo.kmppscriptbuilder.desktop.utils
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder.utils
package dev.inmo.kmppscriptbuilder.desktop.utils
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.Composable

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder.views
package dev.inmo.kmppscriptbuilder.desktop.views
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
@ -8,8 +8,8 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.svgResource
import androidx.compose.ui.unit.dp
import com.insanusmokrassar.kmppscriptbuilder.models.Config
import com.insanusmokrassar.kmppscriptbuilder.utils.*
import dev.inmo.kmppscriptbuilder.core.models.Config
import dev.inmo.kmppscriptbuilder.desktop.utils.*
class BuilderView : View() {
private val projectTypeView = ProjectTypeView()

View File

@ -1,8 +1,8 @@
package com.insanusmokrassar.kmppscriptbuilder.views
package dev.inmo.kmppscriptbuilder.desktop.views
import androidx.compose.runtime.*
import com.insanusmokrassar.kmppscriptbuilder.models.Developer
import com.insanusmokrassar.kmppscriptbuilder.utils.*
import dev.inmo.kmppscriptbuilder.core.models.Developer
import dev.inmo.kmppscriptbuilder.desktop.utils.*
class DeveloperState(
id: String = "",

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder.views
package dev.inmo.kmppscriptbuilder.desktop.views
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
@ -7,9 +7,9 @@ import androidx.compose.material.Divider
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.insanusmokrassar.kmppscriptbuilder.models.License
import com.insanusmokrassar.kmppscriptbuilder.models.getLicenses
import com.insanusmokrassar.kmppscriptbuilder.utils.*
import dev.inmo.kmppscriptbuilder.core.models.License
import dev.inmo.kmppscriptbuilder.core.models.getLicenses
import dev.inmo.kmppscriptbuilder.desktop.utils.*
import io.ktor.client.HttpClient
import kotlinx.coroutines.*

View File

@ -1,12 +1,11 @@
package com.insanusmokrassar.kmppscriptbuilder.views
package dev.inmo.kmppscriptbuilder.desktop.views
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.insanusmokrassar.kmppscriptbuilder.models.Developer
import com.insanusmokrassar.kmppscriptbuilder.utils.*
import dev.inmo.kmppscriptbuilder.desktop.utils.*
abstract class ListView<T>(title: String) : VerticalView(title) {
protected val itemsList = mutableStateListOf<T>()

View File

@ -1,10 +1,10 @@
package com.insanusmokrassar.kmppscriptbuilder.views
package dev.inmo.kmppscriptbuilder.desktop.views
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.runtime.*
import com.insanusmokrassar.kmppscriptbuilder.models.MavenConfig
import com.insanusmokrassar.kmppscriptbuilder.models.SonatypeRepository
import com.insanusmokrassar.kmppscriptbuilder.utils.*
import dev.inmo.kmppscriptbuilder.core.models.MavenConfig
import dev.inmo.kmppscriptbuilder.core.models.SonatypeRepository
import dev.inmo.kmppscriptbuilder.desktop.utils.*
class MavenInfoView : VerticalView("Project information") {
private var projectNameProperty by mutableStateOf("")

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.kmppscriptbuilder.views
package dev.inmo.kmppscriptbuilder.desktop.views
import androidx.compose.foundation.layout.*
import androidx.compose.material.Switch
@ -6,8 +6,8 @@ import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.insanusmokrassar.kmppscriptbuilder.models.*
import com.insanusmokrassar.kmppscriptbuilder.utils.VerticalView
import dev.inmo.kmppscriptbuilder.core.models.*
import dev.inmo.kmppscriptbuilder.desktop.utils.VerticalView
class ProjectTypeView : VerticalView("Project type") {
private var projectTypeState by mutableStateOf<Boolean>(false)

View File

@ -1,8 +1,8 @@
package com.insanusmokrassar.kmppscriptbuilder.views
package dev.inmo.kmppscriptbuilder.desktop.views
import androidx.compose.runtime.*
import com.insanusmokrassar.kmppscriptbuilder.models.MavenPublishingRepository
import com.insanusmokrassar.kmppscriptbuilder.utils.*
import dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository
import dev.inmo.kmppscriptbuilder.desktop.utils.*
class RepositoryState(
name: String = "",

View File

Before

Width:  |  Height:  |  Size: 463 B

After

Width:  |  Height:  |  Size: 463 B

View File

Before

Width:  |  Height:  |  Size: 452 B

After

Width:  |  Height:  |  Size: 452 B

View File

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 744 B

View File

Before

Width:  |  Height:  |  Size: 502 B

After

Width:  |  Height:  |  Size: 502 B

24
extensions.gradle Normal file
View File

@ -0,0 +1,24 @@
allprojects {
ext {
projectByName = { String name ->
for (subproject in rootProject.subprojects) {
if (subproject.name == name) {
return subproject
}
}
return null
}
internalProject = { String name ->
projectByName(name)
}
mppProjectWithSerializationPresetPath = "${rootProject.projectDir.absolutePath}/mppProjectWithSerialization.gradle"
mppJavaProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppJavaProject.gradle"
mppAndroidProjectPresetPath = "${rootProject.projectDir.absolutePath}/mppAndroidProject.gradle"
defaultAndroidSettingsPresetPath = "${rootProject.projectDir.absolutePath}/defaultAndroidSettings.gradle"
// publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle"
}
}

View File

@ -1,10 +1,35 @@
kotlin.code.style=official
org.gradle.parallel=true
kotlin.js.generate.externals=true
kotlin.incremental=true
kotlin.incremental.js=true
android.useAndroidX=true
android.enableJetifier=true
kotlin_version=1.4.30
kotlin_coroutines_version=1.4.2
kotlin_serialisation_runtime_version=1.1.0
#tornadofx_version=1.7.20
kotlin_serialisation_core_version=1.1.0
ktor_version=1.5.1
micro_utils_version=0.4.25
javafxplugin_version=0.0.9
micro_utils_version=0.4.27
compose_version=0.3.0
# ANDROID
android_minSdkVersion=21
android_compileSdkVersion=30
android_buildToolsVersion=30.0.2
dexcount_version=2.0.0
junit_version=4.12
test_ext_junit_version=1.1.2
espresso_core=3.3.0
# Dokka
dokka_version=1.4.20
# Project data
group=dev.inmo
version=0.0.1
android_code_version=1

26
mppAndroidProject.gradle Normal file
View File

@ -0,0 +1,26 @@
project.version = "$version" + System.getenv("additional_version")
project.group = "$group"
// apply from: "$publishGradlePath"
kotlin {
android {
publishAllLibraryVariants()
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib')
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
}
}
apply from: "$defaultAndroidSettingsPresetPath"

30
mppJavaProject.gradle Normal file
View File

@ -0,0 +1,30 @@
project.version = "$version" + System.getenv("additional_version")
project.group = "$group"
// apply from: "$publishGradlePath"
kotlin {
jvm {
compilations.main.kotlinOptions.useIR = true
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib')
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
jvmTest {
dependencies {
implementation kotlin('test-junit')
}
}
}
}

View File

@ -0,0 +1,52 @@
project.version = "$version" + System.getenv("additional_version")
project.group = "$group"
// apply from: "$publishGradlePath"
kotlin {
jvm {
compilations.main.kotlinOptions.useIR = true
}
js (IR) {
browser()
nodejs()
}
android {
publishAllLibraryVariants()
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib')
api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_core_version"
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
jvmTest {
dependencies {
implementation kotlin('test-junit')
}
}
jsTest {
dependencies {
implementation kotlin('test-js')
implementation kotlin('test-junit')
}
}
androidTest {
dependencies {
implementation kotlin('test-junit')
implementation "androidx.test.ext:junit:$test_ext_junit_version"
implementation "androidx.test.espresso:espresso-core:$espresso_core"
}
}
}
}
apply from: "$defaultAndroidSettingsPresetPath"

View File

@ -5,4 +5,21 @@ pluginManagement {
}
}
rootProject.name = 'KotlinPublicationScriptsBuilder'
rootProject.name = 'kmppscriptbuilder'
String[] includes = [
":core",
":desktop"
]
includes.each { originalName ->
String projectDirectory = "${rootProject.projectDir.getAbsolutePath()}${originalName.replaceAll(":", File.separator)}"
String projectName = "${rootProject.name}${originalName.replaceAll(":", ".")}"
String projectIdentifier = ":${projectName}"
include projectIdentifier
ProjectDescriptor project = project(projectIdentifier)
project.name = projectName
project.projectDir = new File(projectDirectory)
}

View File

@ -1,13 +0,0 @@
package com.insanusmokrassar.kmppscriptbuilder.models
import kotlinx.serialization.Serializable
@Serializable
data class BintrayConfig(
val repoUser: String = "\${project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')}",
val repo: String,
val packageName: String,
val packageVcs: String,
val autoPublish: Boolean = false,
val overridePublish: Boolean = false
)