google / google/auto

AutoService: should override the service config file instead of appending new contents

Open
#516 3 comments 0 reactions 0 assignees View on GitHub
Component: service P3
Dominant language
Java
Stars
10.6k
Forks
1.2k
Avg merge
6h 32m
Merged PRs (30d)
13

Description

When generating a service config file (e.g `META-INF/services/serviceloader.Dictionary`), the processor reads the old content from the existing config file, adding new services and then writes to the config file.

The problem I observed is that if I delete a service class (e.g ExtendedDictionary) after the first build and then build and run at the second time, I wll get `java.util.ServiceConfigurationError: serviceloader.Dictionary: Provider serviceloader.ExtendedDictionary not found` error since the old entry `serviceloader.ExtendedDictionary` is still in the newly generated file.

I can use `mvn clean package` to avoid this problem. But if I use some IDE like Intellij, it's not a good practice to have to delete the file manually every time. I don't see why we should append the file instead of overriding.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.