12 changed files with 9 additions and 179 deletions
@ -1,6 +1,7 @@ |
|||||||
plugins { |
plugins { |
||||||
id "org.jetbrains.kotlin.multiplatform" |
id "org.jetbrains.kotlin.multiplatform" |
||||||
id "org.jetbrains.compose" |
id "org.jetbrains.compose" |
||||||
|
id "org.jetbrains.kotlin.plugin.compose" |
||||||
} |
} |
||||||
|
|
||||||
kotlin { |
kotlin { |
||||||
@ -1,50 +0,0 @@ |
|||||||
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform |
|
||||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat |
|
||||||
|
|
||||||
plugins { |
|
||||||
id "org.jetbrains.kotlin.multiplatform" |
|
||||||
id "org.jetbrains.compose" |
|
||||||
} |
|
||||||
|
|
||||||
kotlin { |
|
||||||
jvm("desktop") |
|
||||||
js(IR) { |
|
||||||
browser() |
|
||||||
binaries.executable() |
|
||||||
} |
|
||||||
sourceSets { |
|
||||||
desktopMain { |
|
||||||
dependencies { |
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib" |
|
||||||
implementation compose.desktop.currentOs |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
jsMain { |
|
||||||
dependencies { |
|
||||||
implementation compose.runtime |
|
||||||
implementation compose.web.core |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
compose { |
|
||||||
kotlinCompilerPlugin.set(COMPOSE_COMPILER_PLUGIN_PLACEHOLDER) |
|
||||||
kotlinCompilerPluginArgs.add(COMPOSE_COMPILER_PLUGIN_ARGS_PLACEHOLDER) |
|
||||||
|
|
||||||
desktop { |
|
||||||
application { |
|
||||||
mainClass = "Main" |
|
||||||
nativeDistributions { |
|
||||||
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) |
|
||||||
} |
|
||||||
|
|
||||||
def projectPath = project.projectDir.absolutePath |
|
||||||
if (DefaultNativePlatform.currentOperatingSystem.isWindows()) { |
|
||||||
projectPath = projectPath.replace("\\", "\\\\") |
|
||||||
} |
|
||||||
args(projectPath) |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
Before Width: | Height: | Size: 137 B |
@ -1,76 +0,0 @@ |
|||||||
import androidx.compose.foundation.background |
|
||||||
import androidx.compose.foundation.layout.* |
|
||||||
import androidx.compose.foundation.shape.CircleShape |
|
||||||
import androidx.compose.foundation.shape.GenericShape |
|
||||||
import androidx.compose.runtime.Composable |
|
||||||
import androidx.compose.ui.Alignment |
|
||||||
import androidx.compose.ui.ExperimentalComposeUiApi |
|
||||||
import androidx.compose.ui.Modifier |
|
||||||
import androidx.compose.ui.draw.clip |
|
||||||
import androidx.compose.ui.graphics.Color |
|
||||||
import androidx.compose.ui.graphics.Shape |
|
||||||
import androidx.compose.ui.renderComposeScene |
|
||||||
import org.jetbrains.skia.EncodedImageFormat |
|
||||||
import java.io.File |
|
||||||
import java.util.* |
|
||||||
|
|
||||||
object Main { |
|
||||||
@JvmStatic |
|
||||||
@OptIn(ExperimentalComposeUiApi::class) |
|
||||||
fun main(args: Array<String>) { |
|
||||||
val workingDir = args.getOrNull(0)?.let { File(it) } |
|
||||||
workingDir?.mkdirs() |
|
||||||
if (workingDir == null || !workingDir.isDirectory) { |
|
||||||
error("Working directory must be passes as the first argument. '$workingDir' is not a directory") |
|
||||||
} |
|
||||||
|
|
||||||
val image = renderComposeScene(height = 10, width = 10) { |
|
||||||
mainShape() |
|
||||||
} |
|
||||||
val encodedImage = image.encodeToData(EncodedImageFormat.PNG) ?: error("Could not encode image as png") |
|
||||||
workingDir.resolve("main-image.actual.png").writeBytes(encodedImage.bytes) |
|
||||||
|
|
||||||
val mainMethods = this.javaClass.declaredMethods |
|
||||||
.mapTo(TreeSet()) { it.name } |
|
||||||
.joinToString("\n") |
|
||||||
workingDir.resolve("main-methods.actual.txt").writeText(mainMethods) |
|
||||||
} |
|
||||||
|
|
||||||
@Composable |
|
||||||
fun mainShape() { |
|
||||||
triangle(Color.Magenta) |
|
||||||
} |
|
||||||
|
|
||||||
@Composable |
|
||||||
fun unused() { |
|
||||||
transitivelyUnused() |
|
||||||
} |
|
||||||
|
|
||||||
@Composable |
|
||||||
fun transitivelyUnused() { |
|
||||||
triangle(Color.Gray) |
|
||||||
} |
|
||||||
|
|
||||||
@Composable |
|
||||||
fun keptByKeepRule() { |
|
||||||
fillShape(Color.Blue, CircleShape) |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Composable |
|
||||||
fun triangle(color: Color) { |
|
||||||
fillShape(color, GenericShape { size, _ -> |
|
||||||
moveTo(size.width / 2f, 0f) |
|
||||||
lineTo(size.width, size.height) |
|
||||||
lineTo(0f, size.height) |
|
||||||
}) |
|
||||||
} |
|
||||||
|
|
||||||
@Composable |
|
||||||
fun fillShape(color: Color, shape: Shape){ |
|
||||||
Column(modifier = Modifier.fillMaxWidth().wrapContentSize(Alignment.Center)) { |
|
||||||
Box( |
|
||||||
modifier = Modifier.clip(shape).fillMaxSize().background(color) |
|
||||||
) |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,7 +0,0 @@ |
|||||||
import org.jetbrains.compose.web.* |
|
||||||
import org.jetbrains.compose.web.dom.* |
|
||||||
fun main() { |
|
||||||
renderComposableInBody { |
|
||||||
Div { } |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,26 +0,0 @@ |
|||||||
pluginManagement { |
|
||||||
plugins { |
|
||||||
id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER' |
|
||||||
id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' |
|
||||||
} |
|
||||||
repositories { |
|
||||||
mavenLocal() |
|
||||||
gradlePluginPortal() |
|
||||||
mavenCentral() |
|
||||||
google() |
|
||||||
maven { |
|
||||||
url 'https://maven.pkg.jetbrains.space/public/p/compose/dev' |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
dependencyResolutionManagement { |
|
||||||
repositories { |
|
||||||
mavenCentral() |
|
||||||
google() |
|
||||||
maven { |
|
||||||
url 'https://maven.pkg.jetbrains.space/public/p/compose/dev' |
|
||||||
} |
|
||||||
mavenLocal() |
|
||||||
} |
|
||||||
} |
|
||||||
rootProject.name = "jsMpp" |
|
||||||
Loading…
Reference in new issue