explaingit

google/auto

10,554JavaAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A set of four Google-maintained Java code generators that eliminate repetitive boilerplate, automatically producing immutable value objects, factory classes, service-loader configs, and annotation processor utilities at compile time.

Mindmap

mindmap
  root((google auto))
    Tools
      AutoValue
      AutoFactory
      AutoService
      Common utils
    What it generates
      Immutable classes
      Factory classes
      ServiceLoader config
    How it works
      Annotation processor
      Compile time
    Distribution
      Maven Central
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Automatically generate equals, hashCode, and toString for Java data classes using AutoValue instead of writing them by hand

USE CASE 2

Generate factory classes for dependency-injection patterns without writing the boilerplate with AutoFactory

USE CASE 3

Register service-provider plugins for Java's ServiceLoader mechanism automatically using AutoService

USE CASE 4

Use the Common utilities subproject as a foundation when writing your own Java annotation processors

Tech stack

Java

Getting it running

Difficulty · easy Time to first run · 30min
Use freely for any purpose including commercial use, as long as you keep the copyright notice, Apache 2.0.

In plain English

Auto is a collection of code generators for Java, maintained by Google. The idea behind it is that Java programs often require large amounts of repetitive boilerplate code, the kind that a developer has to write again and again for different classes, and that can contain subtle mistakes precisely because it is so tedious to write. Auto generates that code automatically so that developers can focus on the parts that actually matter. The project is divided into four tools that each target a different type of repetitive Java code. AutoValue generates immutable value objects, which are classes whose only purpose is to hold data and compare equal when their data is the same. AutoFactory generates factory classes that follow a standard Java dependency-injection pattern called JSR-330. AutoService generates the configuration files that Java's ServiceLoader mechanism needs to discover plugins and extensions. The Common subproject provides shared utilities used by people writing their own annotation processors. All four tools work through Java's annotation processor mechanism, meaning you add a small annotation to your code and the generator produces the boilerplate at compile time. The generated code behaves exactly as if you had written it by hand, but you never have to look at it or maintain it. The repository is open source under the Apache 2.0 license and each subproject is available as a published library through Maven Central, the standard package registry for Java projects.

Copy-paste prompts

Prompt 1
Help me add AutoValue to my Maven project to auto-generate an immutable User data class with name and email fields, show the full annotation and build setup.
Prompt 2
Using google/auto AutoService, help me register a custom Java plugin so it is discoverable via ServiceLoader without editing META-INF files manually.
Prompt 3
Show me how to use google/auto AutoFactory to generate a factory class for a class that mixes injected and caller-provided constructor arguments.
Prompt 4
Help me set up google/auto AutoValue in a Gradle project and explain why it is better than Lombok for generating immutable value objects in Java.
Prompt 5
Using google/auto Common utilities, help me write a simple Java annotation processor that validates that a custom annotation is only applied to public classes.
Open on GitHub → Explain another repo

← google on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.