KotlinSample - Template project for building a GTK3 Kotlin/Native app against the elementary Flatpak runtime

Overview

GTK3 Kotlin/Native Sample

This is a working example of how to write and build a GTK3 application in Kotlin/Native. It includes a Flatpak manifest that successfully builds the application against the elementary Flatpak runtime.

The GTK-KT library is used to wrap GTK in a nice Kotlin-like API. If you wish to build this project locally, you will first need to build and install GTK-KT to your local Maven repository as per the instructions in its README.

Most of the files here are the standard Kotlin/Native template files as produced by IntelliJ IDEA. The following customizations have been made:

maven-modules.json

This is generated by flatpak-maven-generator with the following command:

flatpak-maven-generator -r https://plugins.gradle.org/m2/ org.jetbrains.kotlin.multiplatform:org.jetbrains.kotlin.multiplatform.gradle.plugin:1.5.0 org.jetbrains.kotlin:kotlin-stdlib:1.5.21 org.jetbrains.kotlin:kotlin-reflect:1.5.21 org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-native-mt org.jetbrains.kotlinx:kotlinx-coroutines-core-linuxx64:1.5.0-native-mt org.jetbrains.kotlinx:atomicfu:0.16.1

This JSON file instructs flatpak-builder to download the requested Maven artifacts (and their recursive dependencies) into a local Maven repository. As the flatpak-builder sandbox does not allow internet access, the Gradle build scripts cannot download dependencies, so we have to pre-provide them in this way.

build.gradle.kts

The following section was added to the standard IDEA template:

repositories {
    mavenCentral()
    mavenLocal()
    maven() { url = uri("/app/maven-local") }
}

This allows the build to work locally (outside the Flatpak sandbox), by using mavenLocal for GTK-KT and mavenCentral on the internet for other dependencies. The /app/maven-local line allows the build inside the sandbox to find dependencies by using the mirrored maven repository created by the JSON file above.

settings.gradle.kts

The following section was added to the standard IDEA template:

pluginManagement {
    repositories {
        maven(url = "/app/maven-local")
        gradlePluginPortal()
    }
}

Again, this allows Gradle to find plugins in the local Maven repository inside the sandbox, this wouldn't be necessary if not building as a Flatpak.

local-maven-repository.patch

This is a patch applied to gtk-kt during a Flatpak build to allow it to find its Maven artifacts.

io.github.davidmhewitt.KotlinSample.yml

This is the Flatpak build manifest. In order:

  • The kotlin-native module downloads and unpacks the Kotlin Native compiler to /app/kotlin-native. This is entirely cleaned up after the build has finished to make the resulting Flatpak as small as possible.
  • The konan-deps module downloads dependencies of the Kotlin compiler. This is essentially a full GCC/Clang/LLVM toolchain. This is fairly inefficient use of bandwidth during the build as these tools could be available in the Flatpak SDK, but it seems Kotlin does not fully support using the host's toolchain yet. This is entirely cleaned up after the build.
  • The maven-modules module downloads a local mirror of the artifacts required from Maven repos to /app/maven-local as specified in the JSON file. This repository is cleaned up after the build.
  • The gtk-kt module clones and builds gtk-kt and publishes it to the /app/maven-local repository. We're selective about which subprojects we build to save time. This is cleaned up after the build.
  • Finally, the sample module builds our application against the published gtk-kt module and copies the executable to the /app/bin folder as expected by Flatpak.
You might also like...
An Android base project building on MVVM Architecture Pattern. This can help you build new apps faster
An Android base project building on MVVM Architecture Pattern. This can help you build new apps faster

MVVM Explanation If you can't imagine what is MVVM, please read my medium article here first. It can fully explain the revolution of Software architec

Advent of Code template project for Kotlin

Advent of Code Kotlin Template Advent of Code – an annual event in December since 2015. Every year since then, with the first day of December, a progr

A Kotlin/JVM Project Template with Gradle

kotlin-project-template A Kotlin/JVM Project Template with Gradle. Clone or npx

A Task Management and Habit-building App, representating my journey in Android as well as my first Kotlin App. 🤗 ✨
A Task Management and Habit-building App, representating my journey in Android as well as my first Kotlin App. 🤗 ✨

A Task Management and Habit-building App, representating my journey in Android as well as my first Kotlin App. 🤗 ✨

Get a libGDX-powered Android live wallpaper up and running quickly with this project template

This project is a libGDX Android live wallpaper template. It's the demo application created by the libGDX code generator, remade as a live wallpaper.

Dose a Android app that reminds you medications exactly when your body needs them, building entirely using Kotlin and Jetpack Compose with MVVM + Clean Architecture
Dose a Android app that reminds you medications exactly when your body needs them, building entirely using Kotlin and Jetpack Compose with MVVM + Clean Architecture

💊⏰ Dose is a work-in-progress Android app that reminds you medications exactly when your body needs them, building entirely using Kotlin and Jetpack Compose with MVVM + Clean Architecture

An android app that allows building a todo list

Project 1 - SimpleToDo1 SimpleToDo1 is an android app that allows building a todo list and basic todo items management functionality including adding

Easy Note: Building a Notes app using MVVM, JetPack Compose with a clean multi-module architecture approach.
Easy Note: Building a Notes app using MVVM, JetPack Compose with a clean multi-module architecture approach.

Easy Note Easy Note: Notes app using JetPack Compose and MVVM with a clean architecture approach. This app shows the usage of the new Navigation Archi

SimpleTodo - An android app that allows building a todo list and basic todo items management functionality
SimpleTodo - An android app that allows building a todo list and basic todo items management functionality

Pre-work - SimpleTodo SimpleTodo is an android app that allows building a todo l

Owner
David Hewitt
David Hewitt
Android App to test API requests against the GitHub API.

Reproducing an issue with GitHub's IP allowlist feature GitHub provides a feature for Enterprise orgs to define an IP allowlist. Requests to the GitHu

Tom Hombergs 2 Aug 7, 2022
Udacity-shoestore - A template provided for use when building your README file for students

README Template Below is a template provided for use when building your README f

Burak Demir 0 Jan 5, 2022
Android Studio project wrapper around the Elixir TodoApp Desktop app to run on Android including the Erlang runtime

TodoApp Android: An Android Sample App This Android Studio project wraps the Desktop Sample App to run on an Android phone. How to build & run Install

elixir-desktop 78 Dec 10, 2022
A framework for building native applications using React

React Native Learn once, write anywhere: Build mobile apps with React. Getting Started · Learn the Basics · Showcase · Contribute · Community · Suppor

Meta 106.9k Jan 8, 2023
A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.

Ionic Ionic is an open source app development toolkit for building modern, fast, top-quality cross-platform native and Progressive Web Apps from a sin

Ionic 48.4k Jan 3, 2023
A Python native extension written in Kotlin Native

Kotlin Python Ext This is a proof of concept for a Python extension in Kotlin. It is recommended to read the Official Python C API Documentation befor

Martmists 20 Jun 22, 2022
📲💬 react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in android and iOS devices.

React Native Fontext react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in androi

mroads 9 Dec 3, 2021
Native-loader - Safely load native libraries in Java

Native Loader ??️ Safe native loading in Java based off of the native-loader use

Mixtape 1 Oct 19, 2022
Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in the official package.

@mccsoft/react-native-matomo Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in th

MCC Soft 4 Dec 29, 2022