Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Create an Android plugin using Kotlin
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Bruno Oliveira
September 24, 2016
Programming
76
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Create an Android plugin using Kotlin
Presentation @Google Developers Group Lisbon
27/09/2016
Bruno Oliveira
September 24, 2016
More Decks by Bruno Oliveira
See All by Bruno Oliveira
Speedy Development with Kotlin
bmoliveira
1
80
Other Decks in Programming
See All in Programming
オーケストレーション記述言語 Katari
yukikurage
0
230
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
310
Spec-driven Development with AI
simas
PRO
0
2.3k
Crash Auto Pipelines
veronikapj
1
380
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
200
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
220
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
280
DroidKnights 2026 Android A2UI Jetpack Compose 기반의 안전한 AI UI 렌더링 - 박제창
itsmedreamwalker
1
190
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
410
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
190
Seven New Principles of Software Engineering
yegor256
0
460
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
350
Featured
See All Featured
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
570
Accessibility Awareness
sabderemane
1
290
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
520
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
650
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
610
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
290
Mobile First: as difficult as doing things right
swwweet
225
10k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
810
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
390
Transcript
Create your Gradle plugin using Kotlin Bruno Oliveira Mobile developer
@Faber-Ventures
Build a Gradle plugin using Kotlin • Why Kotlin •
Localizable.io • Android specific plugin • Build the plugin step-by-step
Localizable.io • Managing strings in a live app is a
problem
Localizable.io • Making the developer life easier
Localizable.io • Change directly in Produc3on
Our vision • Localizable.setup(this) • Localizable.getString(R.string.welcome) • Localizable.availableLocales() • Localizable.setLocale(Localizable.availableLocales().get(0))
Our vision
Why do we need a plugin? • Build (me analyse
android resources • Parse generated values folders • Extract Strings • Manifest • Make a seamless experience
What/How are we doing with it? • Extract strings from
values • Cache and send to server • Try to automate as much as possible
Biggest problems at start • Android studio • Trying to
implement the sample right in the same project • Deploy development dependency to local maven repo
Let's start
Let's start
Let's start
Setup dependencies aka build.gradle • Kotlin • GradleApi • Build
Tools apply plugin: "kotlin" dependencies { compile gradleApi() compile "org.jetbrains.kotlin:kotlin-stdlib:1.0.3" compile "com.android.tools.build:gradle:2.1.3" }
Declare a plugin • src/main/resources/META-INF.gradle-plugins
Declare a plugin • Plugin class class LocalizablePlugin : Plugin<Project>
{ override fun apply(project: Project?) { project?.let { ProjectHandler(it).createTasks() } } }
Declare a plugin • Use the plugin apply plugin: 'localizable'
buildscript { dependencies { classpath "io.localizable:sync:1.0.4-SNAPSHOT" } }
When tasks added fun createTasks() { if (!isAndroidProject) { throw
Throwable("You should apply android to your project first") } tasks.whenTaskAdded { handleTask(it) } }
Android build tools check private val isAndroidProject: Boolean by lazy
{ project.plugins.hasPlugin(AppPlugin::class.java) } private val appExtension: AppExtension by lazy { project.extensions.getByType(AppExtension::class.java) } private val flavorNames: List<String> by lazy { val configs = appExtension.productFlavors.map { it.name } if (configs.isNotEmpty()) configs else listOf("") } private val buildTypes: Collection<BuildType> by lazy { appExtension.buildTypes }
Handle everything • We don't wanna miss a thing. private
fun handleTask(task: Task) { buildTypes.forEach { build -> flavorNames.forEach { flavor -> processBuild(build.name, flavor, task) } } }
Find the One private fun processBuild(buildName: String, flavorName: String, task:
Task) { val taskAffix = LocalizableHelper.taskAffix(buildName, flavorName) val processTask = "process${taskAffix}Resources" if (processTask.equals(task.name)) { createLocalizableFromTask(task, taskAffix, buildName, flavorName) } }
Create a task val localizableTaskName = "localizable$taskAffix" val nTask =
project.task(localizableTaskName)
Execute • Execute block • Follow the behaviors • Use
the build cache folders if needed nTask.doFirst { val manifest = LocalizableHelper.manifestFileForTarget(project, buildName, flavorName) if (manifest == null) { println("Could not find any manifest file") return@doFirst } nTask.didWork = LocalizableTask(project, manifest, localizableTaskName).syncResources() }
Add task to Android stack • Task in the middle
• mergeDebugEpicResources > localizableEpicResources > ProcessDebugEpicResources task.dependsOn(nTask) val mergeTask = "merge${taskAffix}Resources" project.tasks.getByName(localizableTaskName).dependsOn(mergeTask)
Execute order • mergeEpicDebugResources • localizableEpicDebugResources • processEpicDebugResources
Deploy locally Run the task - Command line ./gradlew :plugin:uploadArchives
uploadArchives { repositories { mavenDeployer { repository(url: mavenLocal().url) pom.groupId = GROUP_ID pom.artifactId = ARTIFACT_PLUGIN_ID pom.version = PLUGIN_VERSION } } }
Deploy locally Run the task - On interface
Debug :( • Network interceptor private val interceptor: HttpLoggingInterceptor by
lazy { val interceptor = HttpLoggingInterceptor(HttpLoggingInterceptor.Logger { println(" -> $it") }) interceptor.level = HttpLoggingInterceptor.Level.BODY interceptor }
Deploy to Maven • guide to maven • h/p:/ /zserge.com/blog/gradle-maven-publish.html
• jitpack • jitpack.io
Contacts •
[email protected]
• github.com/bmoliveira • twi5er.com/_bmoliveira Localizable.io