square / wire

gRPC and protocol buffers for Android, Kotlin, Swift and Java.
https://square.github.io/wire/
Apache License 2.0
4.23k stars 571 forks source link

[Bug] Propagate the deprecated flag on EnumType after pruning by wire-gradle-plugin #3076

Closed aaron-edwards closed 2 weeks ago

aaron-edwards commented 3 weeks ago

Relates to https://github.com/square/wire/issues/3075

When generating java and kotlin enums that have the option deprecated = true; flag the resulting enum generated does not contain the @Deprecated annotation. This appears to be due to the pruning functionality not retaining the deprecated flag and only affects the enum classes (enum constants, messages and fields all work as expected)

Example

test/period.proto

syntax = "proto2";

enum Period {
  option deprecated = true;
  CRETACEOUS = 1;
}

Before

public enum class Period(
  override val `value`: Int,
) : WireEnum {
  CRETACEOUS(1),
  ;

After

@Deprecated(message = "Period is deprecated")
public enum class Period(
  override val `value`: Int,
) : WireEnum {
  CRETACEOUS(1),
  ;