google / j2cl

Java to Closure JavaScript transpiler
Apache License 2.0
1.24k stars 146 forks source link

Ensure junit_processor JAR contains META-INF/services for processor discovery #101

Closed tbroyer closed 4 years ago

tbroyer commented 4 years ago

Filing this as a feature request as it's related to using J2CL outside of the Bazel tooling (testing isn't supported with Bazel either anyway), although it really looks like an oversight in the Open Source version.

Is your feature request related to a problem? Please describe. bazel-bin/junit/generator/java/com/google/j2cl/junit/apt/libjunit_processor.jar (from //junit/generator/java/com/google/j2cl/junit/apt:junit_processor) doesn't contain a META-INF/services/javax.annotation.processing.Processor so non-Bazel tooling cannot rely on processor discovery in the processor path. This isn't a problem in Bazel as it doesn't use discovery and instead relies on java_plugin rules.

The J2clTestingProcessor is annotated with @AutoService though, so it looks like it was expected that this file would be generated https://github.com/google/j2cl/blob/f4420bf330be0c475dc66836c38393ceede9d143/junit/generator/java/com/google/j2cl/junit/apt/J2clTestingProcessor.java#L29-L30 but the //third_party:auto_service doesn't have exported_plugins (for itself? though annotations have been split into a separate Maven artifact since 1.0-rc5; J2CL uses 1.0-rc2), so the annotation isn't processed.

Describe the solution you'd like Add the auto-service processor to the build (as an exported plugin or auto-service-annotations) so thatMETA-INF/services` is generated.

gkdn commented 4 years ago

Fixed in https://github.com/google/j2cl/commit/22b629c9066e067ff7a951e03c6a0dd85ece5b94