Skip to content

An experimental Gradle plugin to build Flix language projects

License

Notifications You must be signed in to change notification settings

KengoTODA/flix-gradle-plugin

Repository files navigation

Flix Gradle Plugin

An experimental Gradle plugin to build Flix language projects.

.github/workflows/build.yml Gradle Plugin Portal Codacy Badge semantic-release

Getting Started

Configure the plugin for existing Gradle projects

To integrate Flix into a Gradle project with other languages, apply the convention plugin jp.skypencil.flix:

plugins {
  `application`
  id("jp.skypencil.flix") version "1.1.2"
}
configure<JavaPluginExtension> {
  toolchain {
    languageVersion.set(JavaLanguageVersion.of(17))
  }
}
configure<FlixExtension> {
  sourceSets {
    main {
      setSrcDirs(["src/main/flix"])
    }
    test {
      setSrcDirs(["src/test/flix"])
    }
  }
}

Unlike common Flix projects, you need to locate files as follows:

  • Source files should be stored under the src/main/flix directory.
  • Test files should be stored under the src/test/flix directory.

Configure the plugin for a pure Flix project

To build a Flix project created by flix init command, apply the base plugin jp.skypencil.flix-base and create necessary tasks individually:

import jp.skypencil.flix.FlixCompile
import jp.skypencil.flix.FlixTest
plugins {
    id("jp.skypencil.flix-base") version "1.1.2"
}

val compileFlix = tasks.register<FlixCompile>("compileFlix") {
    source = fileTree("src")
    destinationDirectory.set(file("build/classes/flix/main"))
}
val testFlix = tasks.register<FlixTest>("testFlix") {
    source = fileTree("test")
    destinationDirectory.set(file("build/classes/flix/test"))
    report.set(file("build/reports/flix/main.txt"))
}

tasks.named<Task>("assemble") { dependsOn(compileFlix) }
tasks.named<Task>("check") { dependsOn(testFlix) }

Limitation

  • No support for resource files such as src/main/resources and src/test/resources.
  • Test reports generated at build/reports/flix/main.txt is quite simple.

Developers' guideline

TODO

  • integrate with application plugin
  • add testFlix task
  • add a task to make a .fpkg file
  • support the Gradle Java toolchain
  • use Gradle worker API to introduce the classloader level separation
  • support dependency management (based on an investigation)
  • create a JUnit XML file based on test result

Copyright

Copyright © 2021-2022 Kengo TODA