Introduction

Gropify is a type-safe and modern properties plugin for Gradle.

Background

This plugin is designed for Gradle build scripts. It aims to bring properties similar to those in the gradle.properties file into build scripts in a type-safe way, avoiding problems that hard-coded strings might cause.

The project icon was designed by MaiTungTMopen in new window. The name comes from GradlePropify, meaning a plugin for Gradle properties.

It is a brand-new project rebuilt from SweetPropertyopen in new window, borrowing previous design ideas and making it more polished and easier to use.

The configuration plan format of Gropify is similar to SweetProperty. If you are using SweetProperty, you can consider migrating to Gropify.

Usage

Gropify is mainly designed for Kotlin DSL build scripts. Groovy can directly use properties from the gradle.properties file as variables, but you can still use Gropify to achieve type-safe property access.

Gropify also supports generating properties (similar to those defined in a gradle.properties file) in a type-safe way into the source code of Kotlin, Java, and Android projects for use at application runtime—similar to Android's BuildConfig's buildConfigField feature.

Suppose we have the following gradle.properties file.

The following example

project.app.name=Gropify-Demo
project.app.version=1.0.0

Here is an example of calling the code automatically generated by Gropify.

Build Script (Kotlin DSL, Groovy DSL)

val appName = gropify.project.app.name
val appVersion = gropify.project.app.version
def appName = gropify.project.app.name
def appVersion = gropify.project.app.version

Source Code (Kotlin, Java)

val appName = MyAppProperties.PROJECT_APP_NAME
val appVersion = MyAppProperties.PROJECT_APP_VERSION
var appName = MyAppProperties.PROJECT_APP_NAME;
var appVersion = MyAppProperties.PROJECT_APP_VERSION;

Gropify also supports Kotlin Multiplatform projects, and you can use the generated property classes in the commonMain source set.

Language Requirement

It's recommended to use Kotlin DSL to configure your project's build scripts. Groovy is also supported, but in pure Groovy projects some configuration syntax may have compatibility issues.

In Groovy DSL, we will no longer be responsible for troubleshooting and fixing any issues that arise from using this plugin, and it may be completely unsupported in future versions.

Contribution

The maintenance of this project is inseparable from the support and contributions of all developers.

This project is currently in its early stages, and there may still be some problems or lack of functions you need.

If possible, feel free to submit a PR to contribute features you think are needed to this project or go to GitHub Issuesopen in new window to make suggestions to us.