GithubHelp home page GithubHelp logo

wondfor / airin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from morfly/airin

0.0 0.0 0.0 58.53 MB

A framework for automated migration of your projects to Bazel build system.

License: Apache License 2.0

Kotlin 100.00%

airin's Introduction

Airin

Maven Central

Airin is a framework for automated migration of your projects to Bazel build system. It consists of 2 primary components:

  • Starlark Template Engine - a declarative, typesafe Starlark template engine and code generator. Define templates for your Bazel configuration files in Kotlin DSL which closely resembles Starlark itself. Check the documentation to learn more.
  • Automated Migration Component - a plugin to the build system of your project (Gradle) for automating its migration to Bazel. Define the set of Bazel file templates for your project and configure Airin Gradle plugin to migrate the project. Check the documentation to learn more.

Publications

How it works?

Step 1

In buildSrc directory define a set of Starlark templates for your project.

fun java_build(
    targetName: String,
    srcRoot: String,
    mainClass: String
    /**
     *
     */
) = BUILD.bazel {
    load("@rules_java//java:defs.bzl", "java_binary")

    java_binary(
        name = targetName,
        srcs = glob("$srcRoot/**/*.java"),
        main_class = mainClass,
        deps = list["//library"]
    )
}

Step 2

Also, in buildSrc implement TemplateProvider's for each type of your Gradle modules to correctly map the right templates to the right modules.

Step 3

In root build.gradle file configure Airin Gradle plugin by registering your newly created template providers for each type of modules or usecases.

Kotlin
airin {
  
  templates {
    
    register<Workspace>()
    register<KotlinModuleBuild>()
    register<AndroidModuleBuild>()
  }
}
Groovy
airin {
  
  templates {
    
    register Workspace
    register KotlinModuleBuild
    register AndroidModuleBuild
  }
}

In the example above Workspace, KotlinModuleBuild and AndroidModuleBuild are Starlark code template providers that implement GradleTemplateProvider interface.

Step 4

Run the migration.

./gradlew migrateToBazel

See the documentation to learn more about the migration process.

Installation

Migration from Gradle

In the buildSrc/build.gradle file add the following:

dependencies {
    // Gradle plugin.
    implementation "org.morfly.airin:airin-gradle:0.4.0"
  
    // Optional - Android specific extensions.
    implementation "org.morfly.airin:airin-gradle-android:0.4.0"
    // Optional. Required for airin-gradle-android.
    runtimeOnly("com.android.tools.build:gradle:<version>")
    // Optional. Required for projects that use Jetpack Compose.
    runtimeOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:<version>")
}

Then, in the root build.gradle file apply Airin Gradle plugin:

plugins {
    id "org.morfly.airin"
}

Standalone Template Engine

In case you need only Starlark code generator:

dependencies {
    // Starlark template engine.
    implementation "org.morfly.airin:airin-starlark:0.4.0"
    // Collection of common rules and functions.
    implementation "org.morfly.airin:airin-starlark-stdlib:0.4.0"
  
    // Optional - Starlark rules and functions generator.
    ksp "org.morfly.airin:airin-starlark-libgen:0.4.0"
}

Don't forget to add id("com.google.devtools.ksp") to plugins section of your build.gradle(.kts) file if you are using ksp.


Now you are ready for the migration.

Also, learn more about generating DSL for custom rules and functions.

Examples

Learn more about Airin by checking example projects.

License

Copyright 2021 Pavlo Stavytskyi

Licensed 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.

airin's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.