Git Product home page Git Product logo

project-starter's Introduction

Starter


Build Project ย ktlint

version

Motivation

Maintaining multiple multi-module Android project often requires copying project configuration across different projects. Even when project reaches more advanced stage it is still required to put non-minimal effort to maintain its configuration.
Starting a new project, from the scratch, takes more than a day to configure every tool you usually want to use. Sometimes people create template project or another way of keeping your project configuration in a good shape is using buildSrc plugins. Less code written, ease of sharing between projects but still some part of the code needed to be copied.

This project goes further and addresses that issue by exposing set of plugins useful when approaching multi-module setup with Gradle build system.

Content

Repository consists of several plugins that makes initial project configuration effortless and easily extensible. Each module consists of configuration code most commonly used in Android project configuration.

Module plugins

Kotlin Library Plugin

Plugin configures code style tasks, hooks for common tasks, sets coverage reports generation and manages versioning of the artifact

Apply plugin to project level build.gradle

plugins {
    id("com.starter.library.kotlin") version("x.y.z")
}

// optional config with default values
projectConfig {
    javaFilesAllowed false
}
  • javaFilesAllowed - defines if the project can contain java files, fails the build otherwise

Multiplatform Library Plugin

For kotlin multiplatform libraries apply plugin to project level build.gradle

plugins {
    id("com.starter.library.multiplatform") version("x.y.z")
}

Android Application/Library Plugin

In addition to customizations made to Kotlin Library Plugin Android plugins tweaks default Android Gradle Plugin setup by disabling BuildConfig file generation or recognizing src/main/kotlin (and similar) path as a valid source set.

Android Library plugin requires adding to project level build.gradle:

plugins {
    id("com.starter.library.android") version("x.y.z") 
    // or id("com.starter.application.android") version("x.y.z") 
}

// optional config with default values
projectConfig {
    javaFilesAllowed false
    coverageExclusions [""]
}

// overridden settings for single project
android {
    defaultConfig {
        minSdkVersion 21
    }
}
  • javaFilesAllowed - defines if the project can contain java files, fails the build otherwise.
    (Useful in large projects where you want to enforce new code written in new modules to be written in Java.)
  • coverageExclusions - defines jacoco coverage exclusions for specific module
Day-to-day use

After applying Library/Application plugin following tasks become available:

  • ./gradlew projectTest
    Runs tests for all modules using either predefined tasks (i.e. test for kotlin modules or testDebugUnitTest for android libraries) or use customized values.
  • ./gradlew projectLint
    Runs Android lint checks against all modules (if custom lint checks are applied then for Kotlin modules too)
  • ./gradlew projectCodeStyle
    Verifies if code style matches modern standards using tools such as ktlint, Detekt with predefined config.
  • ./gradlew projectCoverage
    Automatically generates test coverage reports for all modules using Jacoco

Those tasks allows you to run tests efficiently for all modules by typing just a single task.

Standalone plugins

Quality Plugin

To only configure codestyle tools apply plugin to project level build.gradle

plugins {
    id("com.starter.quality") version("x.y.z") 
}

which applies and configures code style tasks for the project automatically.

Tasks available:

  • ./gradlew projectCodeStyle - checks codestyle using all tools
  • ./gradlew issueLinksReport - finds and check state of all issuetracker links linked in code comments

Quality Plugin gets applied automatically when using any of module Application/Library plugins above.

Versioning Plugin

Uses simple tag-based versioning, in a Configuration Cache compatible way.

To enable it as a standalone plugin, apply plugin to root project build.gradle

 apply plugin: 'com.starter.versioning'

Versioning plugin gets applied automatically when using any of module Application/Library plugins above and can be disabled using Global Configuration

Advanced usage

See Advanced usage

Sample project

Sample Github Browser project - a customized, buildSrc based plugin application.

License

The library is available under MIT License and highly benefits from binary dependencies:

project-starter's People

Contributors

dependabot[bot] avatar mateuszkwiecinski avatar renovate[bot] avatar trz3ci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

project-starter's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Location: .github/renovate.json
Error type: Invalid JSON (parsing failed)
Message: Syntax error: expecting end of expression or separator near ] "exte

Remove local.properties from the repository

local.properties should not be included in VCS

This file must NOT be checked into Version Control Systems,
as it contains information specific to your local configuration.

Can't include the plugins without google() repository

Seems like adding dependency on com.project.starter:plugins:0.21.1 tries to also pull com.android.tools.build:gradle:4.1.0:

> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:4.1.0.
     Searched in the following locations:
       - https://plugins.gradle.org/m2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > com.project.starter:plugins:0.21.1

It would be nice to not require Google's repository and not pull unnecessary stuff if Android-related plugins are not used.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/default.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
  • gradle/actions v4
  • codecov/codecov-action v4
  • actions/upload-artifact v4
  • actions/upload-artifact v4
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
.github/workflows/dependencies.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
  • usefulness/dependency-tree-diff-action v2
  • peter-evans/find-comment v3
  • peter-evans/create-or-update-comment v4
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
  • usefulness/dependency-tree-diff-action v2
  • peter-evans/find-comment v3
  • peter-evans/create-or-update-comment v4
.github/workflows/publish_release.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
.github/workflows/publish_snapshot.yml
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
  • actions/checkout v4
  • actions/setup-java v4
  • gradle/actions v4
  • actions/cache v4
.github/workflows/run_diffuse.yml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/cache v4
  • gradle/actions v4
  • peter-evans/find-comment v3
  • peter-evans/create-or-update-comment v4
  • actions/upload-artifact v4
gradle
gradle.properties
settings.gradle
  • com.gradle.develocity 3.17.6
build.gradle
android/build.gradle
config/build.gradle
gradle/libs.versions.toml
  • com.android.tools.build:gradle 8.5.2
  • com.android.tools.build:gradle-api 8.5.2
  • org.jetbrains.kotlin:kotlin-gradle-plugin 2.0.10
  • org.jetbrains.kotlin:kotlin-gradle-plugin-api 2.0.10
  • com.gradle.publish:plugin-publish-plugin 1.2.1
  • com.github.usefulness:issuechecker 0.4.0
  • io.github.usefulness:ktlint-gradle-plugin 0.9.0
  • io.gitlab.arturbosch.detekt:detekt-gradle-plugin 1.23.6
  • org.junit.jupiter:junit-jupiter 5.11.0
  • org.assertj:assertj-core 3.26.3
  • org.eclipse.jgit:org.eclipse.jgit 6.10.0.202406032230-r
  • org.jetbrains.dokka:dokka-gradle-plugin 1.9.20
  • org.jetbrains.kotlin.jvm 2.0.10
  • pl.droidsonroids.jacoco.testkit 1.0.12
  • com.starter.config 0.76.0
  • com.starter.library.kotlin 0.76.0
  • com.starter.versioning 0.76.0
  • org.jetbrains.kotlin.plugin.sam.with.receiver 2.0.10
  • com.osacky.doctor 0.10.0
  • org.jetbrains.kotlinx.binary-compatibility-validator 0.16.3
gradle/plugins/settings.gradle
  • org.gradle.toolchains.foojay-resolver-convention 0.8.0
gradle/plugins/build.gradle
jvm/build.gradle
multiplatform/build.gradle
quality/build.gradle
sample/android/gradle.properties
sample/android/settings.gradle
sample/android/build.gradle
sample/android/moduleAndroidApplication/build.gradle
sample/android/moduleAndroidLibrary/build.gradle
sample/android/moduleKotlinLibrary/build.gradle
sample/android/moduleRoot/build.gradle
sample/android/moduleRoot/moduleAndroidLibrary/build.gradle
sample/android/moduleRoot/moduleKotlinLibrary/build.gradle
sample/android/moduleRootAndroid/build.gradle
sample/android/moduleRootAndroid/moduleAndroidLibrary/build.gradle
sample/android/moduleRootAndroid/moduleKotlinLibrary/build.gradle
sample/kotlin/gradle.properties
sample/kotlin/settings.gradle
sample/kotlin/build.gradle
sample/kotlin/moduleKotlinLibrary/build.gradle
sample/kotlin/moduleRoot/build.gradle
sample/kotlin/moduleRoot/moduleKotlinLibrary/build.gradle
testing/build.gradle
versioning/build.gradle
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.10

  • Check this box to trigger a request for Renovate to run again on this repository

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.