0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Amper / Kotlin

Last updated at Posted at 2024-05-23

自分用メモ

今後Kotlin用ビルド定義ファイルの主流(になるか?)
これまでGradleのプラグインとしての実装だった

環境

  • Windows 11
  • Intelli-J 2024.1.2

Intelli-J Amper Pluginでお試し

  1. Intelli-J → Plugin → Amper 追加
  2. → 新規 → プロジェクト → Kotlin(現時点ではKotlinプロジェクトでのみAmperを選択できる模様)
  3. → ビルドシステム:Amper → 作成

➜生成されたプロジェクト

生成された module.yaml
product: jvm/app
生成された settings.gradle.kts
pluginManagement {
    repositories {
        mavenCentral()
        google()
        gradlePluginPortal()
        maven("https://maven.pkg.jetbrains.space/public/p/amper/amper")
        maven("https://www.jetbrains.com/intellij-repository/releases")
        maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
    }
}

plugins {
    id("org.jetbrains.amper.settings.plugin").version("0.2.0")
}
使用可能になるGradleタスクの確認
gradlew tasks
ビルド・実行
gradlew run

Compose Desktop / jvm

module.yaml
product: jvm/app

dependencies:
  - $compose.desktop.currentOs

settings:
  compose: enabled

既存のbuild.gradle.ktsと共存

現状 module.yaml で設定できない部分だけ別途 build.gradle.kts に記載すればよさそう。
最終的には build.gradle.kts は無用に?

例: Compose Desktop で Windows用インストーラを作成

build.gradle.kts
import org.jetbrains.compose.desktop.application.dsl.TargetFormat

compose.desktop {
    application {
        mainClass = "MainKt"
        nativeDistributions {
            targetFormats(TargetFormat.Msi)
            packageName = "AmperTrial"
            packageVersion = "0.0.1"
            windows {
                shortcut = true
                menu = true
                upgradeUuid = "836f0fc9-0000-0000-0000-4e0b7513cd72"
            }
        }
    }
}
ビルド
gradlew packageMsi

➜コード

所感

gradleのカスタマイズ性はすばらしいが使いこなすのは困難。
一般的な設定は簡単に実現できるべきということでAmperに期待。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?