google / closure-templates

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

[feature request] Infer Java package from soy namespace in SoyParseInfoGenerator #184

Open Yannic opened 5 years ago

Yannic commented 5 years ago

It would be great if SoyParseInfoGenerator had an option to infer the Java package from the soy namespace of the file.

See https://github.com/closure-tools/closure-templates/commit/7acea66c65ee0d7b4ceab2d18247cf8d8f15a437 for a prototype.

/cc @robfig @sgammon

iteriani commented 5 years ago

Internally we infer the java namespace from the file path and that comes from our bzl rule. Is there a reason to infer from soy namespace?

I think we have long term plans (hopes and dreams) to no longer require soy namespaces and allow users to import using file import ie

import {foo} from '../templates/bar.soy'

Yannic commented 5 years ago

There is similar functionality to infer the Java package from the file path in rules_closure, but it's very opinionated about the project layout, and I've found myself manually specifying the Java package most of the time.

If there is a better implementation to infer the package inside Google, that might work as well.