Coder Social home page Coder Social logo

handy-gradle-kotlin-dsl-example's Introduction

handy-gradle-kotlin-dsl-example

这是一个示例项目,向你分享我如何使用Gradle Kotlin DSL构建多模块项目。包括编译Spring Boot FatJar、混合编译Java+Kotlin项目。 以及如何更好的组织构建代码。

构建项目

gradlew package

简要说明

所有的构建逻辑都在根项目里便携,使用Kotlin扩展函数提高可读性。自模块中只需要声明所需依赖即可。

例如,定义以下针对Project的扩展函数:

fun Project.packageBootJar(){
    apply(plugin = "org.springframework.boot")
    tasks.withType<org.springframework.boot.gradle.tasks.bundling.BootJar>{
        archiveFileName.set("app.jar")
    }
}

如果需要项目可以编译为可执行的Spring Boot FatJar,仅需要声明:

project(":spring-boot-application").packageBootJar()

如果需要使项目可以编译Kotlin代码,仅需要声明:

project(":spring-boot-application").compileKotlin()

详细逻辑,请参考build.gradle.kts

handy-gradle-kotlin-dsl-example's People

Contributors

hehongyu1995 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.