google / closure-templates

A client- and server-side templating system that helps you dynamically build reusable HTML and UI elements
Apache License 2.0
640 stars 194 forks source link

Run compilers from Java #194

Open Yannic opened 5 years ago

Yannic commented 5 years ago

It would be great if it was possible to run the compilers from Java, e.g. for use in Bazel persistent workers. Unfortunately, the only (somewhat) public method calls System.exit, making it unusable for persistent workers.

iteriani commented 5 years ago

Hmm I don't know too much about the entry points. Where does it call system.exit

Yannic commented 5 years ago

The entry points all look like this: new MyCompiler().runMain(args); e.g. https://github.com/google/closure-templates/blob/2153cfdf2e985c2c2d502a7c5d84b2610eb196bf/java/src/com/google/template/soy/SoyToPySrcCompiler.java#L116 which calls System.exit.

It should be sufficient to remove the @VisibleForTesting annotaton here: https://github.com/google/closure-templates/blob/2153cfdf2e985c2c2d502a7c5d84b2610eb196bf/java/src/com/google/template/soy/AbstractSoyCompiler.java#L196

lukesandberg commented 5 years ago

We should just release the bazel worker entry point we developed internally. People shouldn't build their own.

On Mon, Oct 28, 2019 at 12:10 PM Yannic notifications@github.com wrote:

The entry points all look like this: new MyCompiler().runMain(args); e.g. https://github.com/google/closure-templates/blob/2153cfdf2e985c2c2d502a7c5d84b2610eb196bf/java/src/com/google/template/soy/SoyToPySrcCompiler.java#L116 which calls System.exit.

It should be sufficient to remove the @VisibleForTesting annotaton here: https://github.com/google/closure-templates/blob/2153cfdf2e985c2c2d502a7c5d84b2610eb196bf/java/src/com/google/template/soy/AbstractSoyCompiler.java#L196

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/closure-templates/issues/194?email_source=notifications&email_token=AABTJXH6IC7IDWSRHPHODGDQQ42JZA5CNFSM4IWXS5GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECOBXWQ#issuecomment-547101658, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABTJXAWFE6IX632G6QM53DQQ42JZANCNFSM4IWXS5GA .

iteriani commented 5 years ago

Do we just want to expose soy_java_library?

lukesandberg commented 5 years ago

expose our bazel rules?

Maybe eventually? im not sure how difficult sharing the code would be, but it is worth considering. Releasing UberSoyCompiler for the worker support would be a good first step

On Tue, Oct 29, 2019 at 3:10 PM iteriani notifications@github.com wrote:

Do we just want to expose soy_java_library?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/closure-templates/issues/194?email_source=notifications&email_token=AABTJXHOWMTJWVGOXZOUKATQRCYFDA5CNFSM4IWXS5GKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECSICYQ#issuecomment-547651938, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABTJXEJCCVYB3ZG5EDUQTTQRCYFDANCNFSM4IWXS5GA .