Skip to content

driver733/infix-functions-generator

Repository files navigation

Infix functions generator

Build Maven Central

semantic-release

Licence

This project allows generating infix extension functions for instance methods with multiple parameters.

For example, by annotating the createBy instance method with the @Infix annotation,

class ClientService {
    // intermediate methods' names are customizable (default = "and")
    @Infix("createWithName", "age", "andHeight") 
    fun createBy(name: String, age: Int, height: Int) = "Carl"
}

the ClientService can be used in a DSL fashion:

clientService createWithName "Alex" age 23 andHeight 170

Such notation adopts the codebase to the DDD, allowing reading the code as sentences in a context of the domain.

Distribution

This project is available on the Maven Central repository.

Getting Started

Install

Gradle

Groovy DSL

Add this to your project's build.gradle:

dependencies {
    implementation 'com.driver733.infix-functions-generator:annotation:2.0.1'
    annotationProcessor 'com.driver733.infix-functions-generator:processor:2.0.1'
}
Kotlin DSL
  1. Apply the KAPT plugin.

    plugins {
      id("org.jetbrains.kotlin.kapt") version "1.3.72"
    }
  2. Add this to your project's build.gradle.kts:

    dependencies {
        implementation("com.driver733.infix-functions-generator:annotation:2.0.1")
        kapt("com.driver733.infix-functions-generator:processor:2.0.1")
    }

Maven

Add this to your project's pom.xml:

<dependencies>
    <dependency>
      <groupId>com.driver733.infix-functions-generator</groupId>
      <artifactId>annotations</artifactId>
      <version>2.0.1</version>
    </dependency>
    <dependency>
      <groupId>com.driver733.infix-functions-generator</groupId>
      <artifactId>processor</artifactId>
      <version>2.0.1</version>
      <scope>provided</scope>
    </dependency>
</dependencies>

Development

Prerequisites

JDK, preferably >= v. 1.8

Build

./gradlew clean build

CI/CD

Github actions is used for CI/CD.

Releases

Releases to the Maven Central repository are automatically made on each commit on the master branch with the help of the semantic-release.

Contributing

  1. Create an issue and describe your problem/suggestion in it.
  2. Submit a pull request with a reference to the issue that the pull request closes.
  3. I will review your changes and merge them.
  4. A new version with your changes will be released automatically right after merging.

Versioning

We use SemVer for versioning. For the versions available, see the tags.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments