/EasyGradle

DSL for Gradle configuration with Kotlin

Primary LanguageKotlinApache License 2.0Apache-2.0

EasyGradle

EasyGradle is a set of utilities for simply the Gradle configuration.

It includes:

  • Gradle DSL+
  • EasyPublish on Bintray plugin for Java, Kotlin & Kotlin Multiplatform!
Version 1.x includes also ( few ) utils for Dokka which are not included yet in 2.x - it's still need to be evaluated whether a dedicated package for it is worth to be distributed. 1.x readme here

DSL+

It's mean to be included in the buildSrc module in the following way:

api("studio.forface.easygradle:dsl:$dslVersion")

or

api("studio.forface.easygradle:dsl-android:$dslVersion")

Features:

  • Library and Plugin dependencies ( check docs for full list )

    repositories {
      classpath(`kotlin-gradle-plugin`)
      classpath(`serialization-gradle-plugin`)
      // etc
    }
    
    dependencies {
      implementation(`kotlin-js` version "1.3.50" ) // version is optional
      implementation(`constraint-layout`)
      testImplementation(`mockk`)
      // etc
    }
  • External versions declaration

    fun initVersions() {
      `kotlin version` =        "1.3.50"        // Updated: Aug 22, 2019
      `espresso version` =      "3.2.0"         // Updated: May 30, 2019
      `lifecycle version` =     "2.2.0-alpha03" // Updated: Aug 09, 2019
      `material version` =      "1.1.0-alpha07" // Updated: May 31, 2019
      `android-test version` =  "1.2.0"         // Updated: May 31, 2019
    }

    This is a good idea to be called at the start of your buildscript

    buildscript {
      initVersions()
      ...
    }
  • Configuration accessors DSL

    api(
      `kotlin-jdk7`,
      `serialization`,
      // etc
    )
    implementation(
      `kotlin-reflect`,
      `coroutines-android`,
      // etc
    )
  • exclude extensions

    androidTestImplementation(
      `android-test`,
      `mockk-android` exclude `mockk`,
      `junit4` exclude jUnit5(`any`) and "another:lib"
    )
  • versioning, it is also compatible with Android for automatically generate versionName and versionCode from the given major, minor, channel, patch and build versions ( see Version )

    It can also be used by following ( avoiding to pass versionName and versionCode )

    android {
      defaultConfig {
        version = Version(1, 2, Beta, 2, 0)
      }
    }

EasyPublis plugin for Bintray ( wraps maven-publish )

Support Jvm, Android and Multiplatform

Apply with DSL

plugins {
  id("studio.forface.easy-publish") version easyPublishVersion
}

Apply with legacy

buildscript {
  repositories {
    maven {
      url = uri("https://plugins.gradle.org/m2/")
    }
  }
  dependencies {
    classpath("gradle.plugin.EasyGradle-publish:plugin:0.2.1")
  }
}

apply(plugin = "studio.forface.easy-publish")

Usage

Configure into your gradle and use ./gradlew uploadArchives

// build.gradle.kts
...
easyPublish {
  // optional config
}
  • It fetches params from your Project's properties ( group, name, version, etc or declared in gradle.properties file - see template - relative to the module or root )

  • or fetches from environment variables

  • or declared in DSL style

    easyPublish {
      artifact = "dsl"
      developers {
        developer {
          name = "Davide"
          id = "4face-studi0"
          email = "mail@face.studio"
        }
      }
      ...
    }
  • a default block could be stored and reused

    val config = PublishConfig { project ->
      version = Version(1, 2, Beta, 2, 0)
      ...
    }
    
    publish(config) {
      // optional additional block
    }
  • More to come