Skip to content

Commit

Permalink
Merge pull request #17 from rjaros/main
Browse files Browse the repository at this point in the history
Version 0.5.0. Upgrade to KVision 5.15.0
  • Loading branch information
rjaros authored Sep 13, 2022
2 parents cf0629a + ee33f21 commit f922205
Show file tree
Hide file tree
Showing 38 changed files with 376 additions and 48 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'org.jetbrains.intellij' version '1.5.2'
id 'org.jetbrains.intellij' version '1.9.0'
id 'org.jetbrains.kotlin.jvm' version '1.6.20'
id 'idea'
}

group 'tech.stonks'
version '0.4.0'
version '0.5.0'

repositories {
mavenCentral()
Expand All @@ -17,7 +17,7 @@ dependencies {
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'io.reactivex.rxjava3:rxjava:3.1.4'
implementation 'io.reactivex.rxjava3:rxjava:3.1.5'
implementation 'io.reactivex.rxjava3:rxkotlin:3.0.1'
}

Expand All @@ -32,7 +32,7 @@ compileKotlin {

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = '2022.1'
version = '2022.1.4'
plugins = ['gradle', 'java', 'org.jetbrains.kotlin']
updateSinceUntilBuild = false
}
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
kotlin.code.style=official
kotlin.code.style=official
kotlin.stdlib.default.dependency=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
26 changes: 12 additions & 14 deletions src/main/kotlin/tech/stonks/kvizard/KVisionModuleBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import tech.stonks.kvizard.data.model.VersionData
import tech.stonks.kvizard.generator.FrontendTreeGenerator
import tech.stonks.kvizard.generator.JavalinTreeGenerator
import tech.stonks.kvizard.generator.JoobyTreeGenerator
import tech.stonks.kvizard.generator.KtorKoinTreeGenerator
import tech.stonks.kvizard.generator.KtorTreeGenerator
import tech.stonks.kvizard.generator.MicronautTreeGenerator
import tech.stonks.kvizard.generator.SpringTreeGenerator
Expand All @@ -41,6 +42,7 @@ class KVisionModuleBuilder : ModuleBuilder() {
companion object {
val supportedProjectTypes = arrayOf(
KVisionProjectType.FRONTEND_ONLY,
KVisionProjectType.KTOR_KOIN,
KVisionProjectType.KTOR,
KVisionProjectType.SPRING_BOOT,
KVisionProjectType.JAVALIN,
Expand Down Expand Up @@ -81,23 +83,19 @@ class KVisionModuleBuilder : ModuleBuilder() {
if (projectType == KVisionProjectType.FRONTEND_ONLY) {
RunConfigurationUtil.createFrontendConfiguration(modifiableRootModel.project)
} else {
runGenerateSources(modifiableRootModel.project)
RunConfigurationUtil.createFullstackConfiguration(modifiableRootModel.project)
}
}
}

private fun runGenerateSources(project: Project) {
project.runGradle("generateKVisionSources")
}

private fun installGradleWrapper(project: Project) {
project.runGradle("wrapper --gradle-version 7.4.2 --distribution-type all")
project.runGradle("wrapper --gradle-version 7.5.1 --distribution-type all")
}

private fun createGenerator(): TreeGenerator {
return when (projectType) {
KVisionProjectType.FRONTEND_ONLY -> FrontendTreeGenerator()
KVisionProjectType.KTOR_KOIN -> KtorKoinTreeGenerator()
KVisionProjectType.KTOR -> KtorTreeGenerator()
KVisionProjectType.SPRING_BOOT -> SpringTreeGenerator()
KVisionProjectType.JAVALIN -> JavalinTreeGenerator()
Expand Down Expand Up @@ -125,14 +123,14 @@ class KVisionModuleBuilder : ModuleBuilder() {
VersionApi.create().getVersionData().blockingGet()
} catch (ex: Exception) {
VersionData(
kVision = "5.9.0",
kotlin = "1.6.20",
serialization = "1.3.2",
coroutines = "1.6.1",
templateJooby = TemplateJooby("2.13.0"),
templateKtor = TemplateKtor("2.0.0"),
templateMicronaut = TemplateMicronaut("3.4.2"),
templateSpring = TemplateSpring(springBoot = "2.6.6"),
kVision = "5.15.0",
kotlin = "1.7.10",
serialization = "1.4.0",
coroutines = "1.6.4",
templateJooby = TemplateJooby("2.16.1"),
templateKtor = TemplateKtor("2.1.1"),
templateMicronaut = TemplateMicronaut("3.6.3"),
templateSpring = TemplateSpring(springBoot = "2.7.3"),
templateVertx = TemplateVertx(vertxPlugin = "1.3.0"),
modules = emptyList()
)
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/tech/stonks/kvizard/KVisionModuleType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class KVisionModuleType : ModuleType<KVisionModuleBuilder>("KVISION_WIZARD") {

enum class KVisionProjectType(val displayName: String) {
FRONTEND_ONLY("Frontend project"),
KTOR("Ktor fullstack project"),
KTOR_KOIN("Ktor/Koin fullstack project"),
KTOR("Ktor/Guice fullstack project"),
SPRING_BOOT("Spring Boot fullstack project"),
JAVALIN("Javalin fullstack project"),
JOOBY("Jooby fullstack project"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package tech.stonks.kvizard.generator

class KtorKoinTreeGenerator: TreeGenerator(
"ktorkoin",
backendResourcesFiles = arrayOf(
"application.conf",
"logback.xml"
),
backendFiles = arrayOf(
"Main.kt",
"Service.kt"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ abstract class TreeGenerator(
),
private val rootFiles: Array<String> = arrayOf(
".gettext.json",
".gitignore",
"system.properties"
".gitignore"
),
private val webpackFiles: Array<String> = arrayOf(
"bootstrap.js",
Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<idea-plugin>
<idea-version since-build="203.5981"/>
<idea-version since-build="221"/>
<id>kvision.project.wizard</id>
<name>KVision Project Wizard</name>
<vendor email="[email protected]" url="https://stonks.tech">Stonks.tech</vendor>
<change-notes>
&lt;i&gt;Version 0.5.0:&lt;/i&gt;
&lt;ul&gt;
&lt;li&gt;Upgrade to KVision 5.15.0&lt;/li&gt;
&lt;li&gt;Upgrade to IntelliJ IDEA 2022.1.4&lt;/li&gt;
&lt;li&gt;Add new Ktor/Koin fullstack project type&lt;/li&gt;
&lt;/ul&gt;

&lt;i&gt;Version 0.4.0:&lt;/i&gt;
&lt;ul&gt;
&lt;li&gt;Upgrade to KVision 5.9.0&lt;/li&gt;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package ${PACKAGE_NAME}

import io.kvision.remote.getService

object Model {

private val pingService = PingService()
private val pingService = getService<IPingService>()

suspend fun ping(message: String): String {
return pingService.ping(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package ${PACKAGE_NAME}

import io.javalin.Javalin
import io.kvision.remote.applyRoutes
import io.kvision.remote.getAllServiceManagers
import io.kvision.remote.kvisionInit

fun main() {
Javalin.create().start(8080).apply {
kvisionInit()
applyRoutes(PingServiceManager)
getAllServiceManagers().forEach { applyRoutes(it) }
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ${PACKAGE_NAME}

@Suppress("ACTUAL_WITHOUT_EXPECT")
actual class PingService : IPingService {

override suspend fun ping(message: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ kotlin {
jvm("backend") {
withJava()
compilations.all {
java {
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
freeCompilerArgs = listOf("-Xjsr305=strict")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
javaVersion=1.8
javaVersion=11
#Plugins
systemProp.kotlinVersion=${kotlin_version}
serializationVersion=${serialization_version}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package ${PACKAGE_NAME}

import io.jooby.runApp
import io.kvision.remote.applyRoutes
import io.kvision.remote.getAllServiceManagers
import io.kvision.remote.kvisionInit

fun main(args: Array<String>) {
runApp(args) {
kvisionInit()
applyRoutes(PingServiceManager)
getAllServiceManagers().forEach { applyRoutes(it) }
onStarted {
// Initialization
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ${PACKAGE_NAME}

@Suppress("ACTUAL_WITHOUT_EXPECT")
actual class PingService : IPingService {

override suspend fun ping(message: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ serializationVersion=${serialization_version}
#Dependencies
systemProp.kvisionVersion=${kvision_version}
systemProp.joobyVersion=${jooby_version}
logbackVersion=1.2.3
logbackVersion=1.4.0

kotlin.mpp.stability.nowarn=true
kotlin.js.compiler=${compiler_backend}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import io.ktor.server.application.*
import io.ktor.server.plugins.compression.*
import io.ktor.server.routing.*
import io.kvision.remote.applyRoutes
import io.kvision.remote.getAllServiceManagers
import io.kvision.remote.kvisionInit

fun Application.main() {
install(Compression)
routing {
applyRoutes(PingServiceManager)
getAllServiceManagers().forEach { applyRoutes(it) }
}
kvisionInit()
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ${PACKAGE_NAME}

@Suppress("ACTUAL_WITHOUT_EXPECT")
actual class PingService : IPingService {

override suspend fun ping(message: String): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ serializationVersion=${serialization_version}
#Dependencies
systemProp.kvisionVersion=${kvision_version}
ktorVersion=${ktor_version}
logbackVersion=1.2.3
logbackVersion=1.4.0

kotlin.mpp.stability.nowarn=true
kotlin.js.compiler=${compiler_backend}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ktor {
development = true
deployment {
port = 8080
watch = [build/classes/kotlin/backend/main]
}

application {
modules = [${PACKAGE_NAME}.MainKt.main]
}
}

db {
driver = "org.h2.Driver"
jdbcUrl = "jdbc:h2:mem:test"
username = null
password = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="15 seconds" debug="false">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>

<appender name="FILE-ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/ktor.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>logs/archived/ktor.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<!-- each archived file, size max 10MB -->
<maxFileSize>10MB</maxFileSize>
<!-- total size of all archive files, if total size > 20GB, it will delete old archived file -->
<totalSizeCap>20GB</totalSizeCap>
<!-- 60 days to keep -->
<maxHistory>60</maxHistory>
</rollingPolicy>

<encoder>
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="FILE-ROLLING"/>
</root>
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
Loading

0 comments on commit f922205

Please sign in to comment.