All Projects → bernaferrari → Gradlekotlinconverter

bernaferrari / Gradlekotlinconverter

Licence: apache-2.0
Convert from Groovy to Kotlin DSL for Gradle, focused on Android.

Programming Languages

kotlin
9241 projects
groovy
2714 projects

Labels

Projects that are alternatives of or similar to Gradlekotlinconverter

Gradle Test Logger Plugin
A Gradle plugin for printing beautiful logs on the console while running tests
Stars: ✭ 460 (-17.71%)
Mutual labels:  gradle
Vbrowser Android
全网视频嗅探缓存APP
Stars: ✭ 499 (-10.73%)
Mutual labels:  gradle
Let
Annotation based simple API flavored with AOP to handle new Android runtime permission model
Stars: ✭ 532 (-4.83%)
Mutual labels:  gradle
Gradle Lint Plugin
A pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts.
Stars: ✭ 473 (-15.38%)
Mutual labels:  gradle
Laziertracker
本项目通过Android字节码插桩插件实现Android端无埋点(或自动埋点),并且支持根据配置文件实现业务数据的自动采集。
Stars: ✭ 485 (-13.24%)
Mutual labels:  gradle
Android Showcase
💎 Android application following best practices: Kotlin, Coroutines, JetPack, Clean Architecture, Feature Modules, Tests, MVVM, DI, Static Analysis...
Stars: ✭ 5,214 (+832.74%)
Mutual labels:  gradle
Bnd
Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
Stars: ✭ 446 (-20.21%)
Mutual labels:  gradle
Mixin
Mixin is a trait/mixin and bytecode weaving framework for Java using ASM
Stars: ✭ 557 (-0.36%)
Mutual labels:  gradle
Android Studio Poet
Generate large Android Studio projects
Stars: ✭ 489 (-12.52%)
Mutual labels:  gradle
Pygradle
Using Gradle to build Python projects
Stars: ✭ 525 (-6.08%)
Mutual labels:  gradle
Android Tips Tricks
☑️ [Cheatsheet] Tips and tricks for Android Development
Stars: ✭ 4,496 (+704.29%)
Mutual labels:  gradle
Gradle In Action Source
Source code for the Manning book "Gradle in Action"
Stars: ✭ 483 (-13.6%)
Mutual labels:  gradle
Packer Ng Plugin
下一代Android打包工具,100个渠道包只需要10秒钟
Stars: ✭ 4,732 (+746.51%)
Mutual labels:  gradle
Android Tech Docs
Android官方技术文档翻译
Stars: ✭ 460 (-17.71%)
Mutual labels:  gradle
Gradle Docker
a Gradle plugin for orchestrating docker builds and pushes.
Stars: ✭ 537 (-3.94%)
Mutual labels:  gradle
Skript
Skript is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
Stars: ✭ 458 (-18.07%)
Mutual labels:  gradle
Hibernate Orm
Hibernate's core Object/Relational Mapping functionality
Stars: ✭ 4,806 (+759.75%)
Mutual labels:  gradle
Gradle Git
Git plugin for Gradle
Stars: ✭ 559 (+0%)
Mutual labels:  gradle
Gradle Advanced Build Version
A plugin to generate the Android version code and version name automatically based on git commits number, date and ...
Stars: ✭ 545 (-2.5%)
Mutual labels:  gradle
Arcgis Runtime Samples Android
ArcGIS Runtime SDK for Android Samples
Stars: ✭ 518 (-7.33%)
Mutual labels:  gradle

Image of GradleKotlinConverter

Gradle Kotlin DSL converter

Welcome! After a lot of pain trying to migrate from Gradle's Groovy to Kotlin DSL on Android Studio, I developed this tool to solve most migration issues and reduce the amount of work you need in order to make things ready.

Please see this tool as a helper, a first resource like Android Studio's Java converter to Kotlin: it won't make a perfect conversion, but it helps a lot in reducing the time you would spend on repetitive tasks.

💻 Getting Started

The script was written in Kotlin and depends on JVM (for File access). If you need to install Kotlin for command line access, check here (brew install kotlin or scoop install kotlin -g on windows with Scoop).

File mode:
$ ./gradlekotlinconverter.kts build.gradle
$ kotlinc -script gradlekotlinconverter.kts build.gradle

Clipboard mode:
$ ./gradlekotlinconverter.kts

Motivation: on my own apps, I've used apostrophes ' instead of quotation marks " since forever, so it wasn't fun when I discovered I would need to modify more than 100 lines of code to make Kotlin DSL work. Besides this, the tool also solves a few common issues that might appear, like the task clean(type: Delete) that becomes a completely different thing.

📋 Clipboard mode

Sometimes you just want to copy and paste. Just copy whatever you want, run the script, then paste on your IDE. The GIF showcases how simple it is:

GIF

😱 Things it can do

Description Before After
Replace all ' with " 'kotlin-android' "kotlin-android"
Replace "def " with "val " def appcompat = "1.0.0" val appcompat = "1.0.0"
Convert plugins apply plugin: "kotlin-kapt" apply(plugin = "kotlin-kapt")
Add ( ) to dependencies implementation ":epoxy" implementation(":epoxy")
Convert Maven maven { url "https://jitpack.io" } maven("https://jitpack.io")
Convert Sdk Version compileSdkVersion 28 compileSdkVersion(28)
Convert Version Code versionCode 4 versionCode = 4
Convert Build Types debuggable true isDebuggable = true
Convert proguardFiles proguardFiles getDef..., "..." setProguardFiles(listOf(getDef..., "...")
Convert sourceCompatibility sourceCompatibility = "1.8" sourceCompatibility = JavaVersion.VERSION_1_8
Convert androidExtensions androidExtensions { experimental = true } androidExtensions { isExperimental = true }
Convert include include ":app", ":diffutils" include(":app", ":diffutils")
Convert signingConfigs signingConfigs { debug { ... } } signingConfigs { register("debug") { ... } }
Convert buildTypes buildTypes { debug { ... } } buildTypes { named("debug") { ... } })
Convert classpath.exclude configurations.classpath.exclude group: '...lombok' configurations.classpath { exclude(group = "...lombok") }
Kt dependencies (1/3) "org.jetbrains.kotlin:kotlin-gradle-plugin:$kt_v" kotlin("gradle-plugin", version = "$kt_v")
Kt dependencies (2/3) "org.jetbrains.kotlin:kotlin-stdlib:$kt_v" kotlin("stdlib", KotlinCompilerVersion.VERSION)
Kt dependencies (3/3) "org.jetbrains.kotlin:kotlin-reflect" kotlin("reflect")
Convert signingConfig signingConfig signingConfigs.release signingConfig = signingConfigs.getByName("release")
Convert extras ext.enableCrashlytics = false extra.set("enableCrashlytics", false)
Convert plugins apply(...) apply(...) plugins { id(...) id(...) }
Convert plugin ids id "io.gitlab.arturbosch.detekt" version "1.0" id("io.gitlab.arturbosch.detekt") version "1.0"
Convert ":" to " =" testImpl(name: "junit", version: "4.12") testImpl(name = "junit", version = "4.12")

You can find all the details on the source code.

The script was made to convert build.gradle in build.gradle.kts, but it can also help in the migration if you paste something that is not in Kotlin DSL format and you want it converted. If you paste something like a implementation '...' and want it converted to implementation("..."), you are free to call the script on build.gradle.kts file and see it working as expected.

When applying on build.gradle, the script will create, for example, build.gradle.kts. When applying on a file that already ends in .kts, the script will overrite the file. In that case, please make sure you are using git or have a backup, in case things turn out wrong.

😨 Things it still can't do

  • If you find anything, just tell me.

Issue Tracking

Found a bug? Have an idea for an improvement? Feel free to add an issue.

License

Copyright 2018 Bernardo Ferrari.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].