Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cvb941 committed Jul 22, 2022
1 parent 98070fd commit db155eb
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 69 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ gradle-app.setting
# gradle/wrapper/gradle-wrapper.properties

.firebase

node_modules/
1 change: 1 addition & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/runConfigurations.xml

This file was deleted.

9 changes: 4 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
plugins {
kotlin("js") version "1.5.30"
kotlin("js") version "1.7.10"
}

group = "net.kusik"
version = "1.1-SNAPSHOT"
version = "1.2-SNAPSHOT"

repositories {
jcenter()
mavenCentral()
maven { url = uri("https://dl.bintray.com/kotlin/kotlinx") }
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
}

dependencies {
testImplementation(kotlin("test-js"))
implementation("org.jetbrains.kotlinx:kotlinx-html:0.7.3")
implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.8.0")
}

kotlin {
Expand Down
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.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
11 changes: 6 additions & 5 deletions src/main/kotlin/GradleKotlinConverter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,12 @@ object GradleKotlinConverter {

// this will only catch id "..." version ..., should skip id("...")
// should get the id "..."
val idExp = "id\\s*\".*?\"".toRegex()
val idExp = "(id)\\s*\"(.*?)\"".toRegex()

return this.replace(idExp) {
// remove the "id " before the real id
val idValue = it.value.replace("id\\s*".toRegex(), "")
"id($idValue)"
val (id, value) = it.destructured
"""$id("$value")"""
}
}

Expand All @@ -381,13 +381,14 @@ object GradleKotlinConverter {
// versionCode = 4
fun String.addEquals(): String {

val compileSdk = "compileSdk"
val signing = "keyAlias|keyPassword|storeFile|storePassword"
val other = "multiDexEnabled|correctErrorTypes|javaMaxHeapSize|jumboMode|dimension|useSupportLibrary"
val databinding = "dataBinding|viewBinding"
val defaultConfig = "applicationId|versionCode|versionName|testInstrumentationRunner"
val defaultConfig = "applicationId|minSdk|targetSdk|versionCode|versionName|testInstrumentationRunner"
val negativeLookAhead = "(?!\\{)[^\\s]" // Don't want '{' as next word character

val versionExp = """($defaultConfig|$signing|$other|$databinding)\s*${negativeLookAhead}.*""".toRegex()
val versionExp = """($compileSdk|$defaultConfig|$signing|$other|$databinding)\s*${negativeLookAhead}.*""".toRegex()

return this.replace(versionExp) {
val split = it.value.split(" ")
Expand Down
4 changes: 0 additions & 4 deletions src/main/kotlin/client.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import org.w3c.dom.Node
import kotlinx.browser.document
import kotlinx.browser.window
import org.w3c.dom.HTMLInputElement
import org.w3c.dom.HTMLTextAreaElement
import org.w3c.dom.events.Event
import org.w3c.dom.events.KeyboardEvent
import org.w3c.dom.get

fun main() {
window.onload = {
Expand Down
94 changes: 60 additions & 34 deletions src/main/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,84 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Gradle Kotlinize | Convert build.gradle to Kotlin DSL</title>
<title>Convert Groovy to Kotlin Online | Gradle Kotlinize</title>
<meta name="google-site-verification" content="YigAcC2VCpUF29Bnk9u5MLRRJmkgzmZUTIh-m-QkLg8">
<meta property="og:image" content="https://gradle-kotlinize.web.app/assets/img/Screenshot 2021-02-25 214819.png">
<meta name="twitter:title" content="Gradle Kotlinize | Convert build.gradle to Kotlin DSL">
<meta name="description" content="Online tool to migrate your build.gradle files written in Groovy language to the new build.gradle.kts files using the Kotlin DSL.">
<meta name="twitter:title" content="Convert Groovy to Kotlin Online | Gradle Kotlinize">
<meta name="description"
content="Online tool to convert your build.gradle files written in Groovy language to the new build.gradle.kts files using the Kotlin DSL.">
<meta property="og:type" content="website">
<meta name="twitter:description" content="Online tool to migrate your build.gradle files written in Groovy language to the new build.gradle.kts files using the Kotlin DSL.">
<meta name="twitter:description"
content="Online tool to convert your build.gradle files written in Groovy language to the new build.gradle.kts files using the Kotlin DSL.">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gradle-kotlinize.web.app/assets/img/Screenshot 2021-02-25 214819.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700">
<link rel="stylesheet" href="assets/css/styles.css">
<script src="GradleKotlinize.js"></script>
<script src="GradleKotlinize.js"></script>
</head>

<body>
<header class="d-flex justify-content-between align-items-center justify-content-xl-start align-items-xl-center" style="background: var(--bs-green);height: 64px;padding-right: 42px;">
<h2 class="me-auto" style="padding-left: 16px;color: var(--bs-white);padding-bottom: 8px;padding-top: 8px;height: 50px;">Gradle Kotlinize</h2> <a href="https://github.com/cvb941/gradlekotlinize">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/cvb941/gradlekotlinize?style=social">
<header class="d-flex justify-content-between align-items-center justify-content-xl-start align-items-xl-center"
style="background: var(--bs-green);height: 64px;padding-right: 42px;">
<h2 class="me-auto" style="padding-left: 16px;color: var(--bs-white);padding-bottom: 8px;padding-top: 8px;height: 50px;">Gradle Kotlinize - Groovy
to Kotlin converter online</h2> <a href="https://github.com/cvb941/gradlekotlinize">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/cvb941/gradlekotlinize?style=social">
</a>
</header>
<p style="padding: 16px;padding-bottom: 8px;">Paste your build.gradle into the left box. The contents will then be converted from Groovy to the new Kotlin-based Gradle build file format in the right box. Use the output in a file named build.gradle.kts in your project.</p>
<div class="container" style="max-width: 90%;height: 75vh;">
<div class="row" style="height: 100%;">
<div class="col-md-6"><strong>Groovy input - build.gradle<br></strong><textarea id="groovyInput" class="prism-live language-groovy" style="width: 100%;height: 92%;"></textarea></div>
<div class="col-md-6"><strong>Kotlin output - build.gradle.kts<br></strong><textarea id="kotlinOutput" style="width: 100%;height: 92%;" readonly=""></textarea></div>
</div>
</header>
<p style="padding: 16px;padding-bottom: 8px;">Paste your build.gradle into the left box. The contents will then be converted from Groovy to the new
Kotlin-based Gradle build file format in the right box. Use the output in a file named build.gradle.kts in your project.</p>
<div class="container" style="max-width: 90%;height: 75vh;">
<div class="row" style="height: 100%;">
<div class="col-md-6"><strong>Groovy input - build.gradle<br></strong><textarea id="groovyInput" class="prism-live language-groovy"
style="width: 100%;height: 92%;"></textarea></div>
<div class="col-md-6"><strong>Kotlin output - build.gradle.kts<br></strong><textarea id="kotlinOutput" style="width: 100%;height: 92%;"
readonly=""></textarea></div>
</div>
<footer>
<p class="text-center" style="font-size: 12px;">This tool uses the&nbsp;<a href="https://github.com/bernaferrari/GradleKotlinConverter">GradleKotlinConverter</a>&nbsp;project created by&nbsp;<a href="https://github.com/bernaferrari">bernaferrari</a><br></p>
</footer><!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="/__/firebase/8.2.9/firebase-app.js"></script>
</div>
<p style="padding-left: 64px;padding-right: 64px;text-align: center">Gradle Kotlinize is an online tool to convert Gradle Groovy to Kotlin kts
format.</p>

<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="/__/firebase/8.2.9/firebase-analytics.js"></script>
<script src="/__/firebase/8.2.9/firebase-performance.js"></script>
<footer>
<p class="text-center" style="font-size: 12px;">This tool uses the&nbsp;<a href="https://github.com/bernaferrari/GradleKotlinConverter">GradleKotlinConverter</a>&nbsp;project
created by&nbsp;<a href="https://github.com/bernaferrari">bernaferrari</a><br></p>
</footer>

<!-- Initialize Firebase -->
<script src="/__/firebase/init.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/prism.min.js"
integrity="sha512-YBk7HhgDZvBxmtOfUdvX0z8IH2d10Hp3aEygaMNhtF8fSOvBZ16D/1bXZTJV6ndk/L/DlXxYStP8jrF77v2MIg==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/components/prism-css.min.js"
integrity="sha512-1qYok2x2Rsm2y+mrdyrp00iH7xYSgVyIQ1egDAoT7CBZ3kSzlaJK+NhWAh746NeL3gnH6dnP8FGS+3xOdwO7ig==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/autoloader/prism-autoloader.min.js"
integrity="sha512-zc7WDnCM3aom2EziyDIRAtQg1mVXLdILE09Bo+aE1xk0AM2c2cVLfSW9NrxE5tKTX44WBY0Z2HClZ05ur9vB6A==" crossorigin="anonymous"></script>

<script>
var perf = firebase.performance();
</script>
<script src="https://unpkg.com/codeflask/build/codeflask.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta2/js/bootstrap.bundle.min.js"></script>


<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/prism.min.js" integrity="sha512-YBk7HhgDZvBxmtOfUdvX0z8IH2d10Hp3aEygaMNhtF8fSOvBZ16D/1bXZTJV6ndk/L/DlXxYStP8jrF77v2MIg==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/components/prism-css.min.js" integrity="sha512-1qYok2x2Rsm2y+mrdyrp00iH7xYSgVyIQ1egDAoT7CBZ3kSzlaJK+NhWAh746NeL3gnH6dnP8FGS+3xOdwO7ig==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha512-zc7WDnCM3aom2EziyDIRAtQg1mVXLdILE09Bo+aE1xk0AM2c2cVLfSW9NrxE5tKTX44WBY0Z2HClZ05ur9vB6A==" crossorigin="anonymous"></script>
<script type="module">
// Import the functions you need from the SDKs you need
import {initializeApp} from "https://www.gstatic.com/firebasejs/9.9.1/firebase-app.js";
import {getAnalytics} from "https://www.gstatic.com/firebasejs/9.9.1/firebase-analytics.js";
// TODO: Add SDKs for Firebase products that you want to use0
// https://firebase.google.com/docs/web/setup#available-libraries

<script src="https://unpkg.com/codeflask/build/codeflask.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta2/js/bootstrap.bundle.min.js"></script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyCMF4cTcw29I6rFhrcO6pnl23WbFbpDAdk",
authDomain: "gradle-kotlinize.firebaseapp.com",
projectId: "gradle-kotlinize",
storageBucket: "gradle-kotlinize.appspot.com",
messagingSenderId: "213473070623",
appId: "1:213473070623:web:c428d1581aab4974a08f2a",
measurementId: "G-8SFMRNXWCW"
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);

</script>
</body>

</html>
</html>
8 changes: 1 addition & 7 deletions src/test/kotlin/TestClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,4 @@ import kotlin.test.Test
import kotlin.test.assertEquals

class TestClient {
@Test
fun testSayHello() {
val container = document.createElement("div")
container.sayHello()
assertEquals("Hello from JS", container.textContent)
}
}
}

0 comments on commit db155eb

Please sign in to comment.