Paullo612 / mlfx

OpenJFX's FXML language AOT compler
Apache License 2.0
12 stars 0 forks source link

Consider injecting fxml file URL to controller instead of compiled class URL #4

Closed Paullo612 closed 1 year ago

Paullo612 commented 1 year ago

Now, if you declare injectable URL in controller, it is compiled class URL. Compiled class URL is also passed to initialize method, if controller implements Initializable.

Looks like it will be better to return fxml file URL here, as fxml files should be included to resulting jar or native-image, because loaders search logic heavily relies on fxml files URLs anyway (for compatibility reasons).

Using fxml files URLs instead of class ones can free us from including compiled .class files in native-image's resource-config.json. fxml files are included there by gluonfx-maven-plugin by default. Here is gluonfx-maven-plugin's default resource config:

{
  "resources": [
    {"pattern": ".*\\.png$"},
    {"pattern": ".*\\.jpg$"},
    {"pattern": ".*\\.jpeg$"},
    {"pattern": ".*\\.gif$"},
    {"pattern": ".*\\.bmp$"},
    {"pattern": ".*\\.ttf$"},
    {"pattern": ".*\\.raw$"},
    {"pattern": ".*\\.xml$"},
    {"pattern": ".*\\.fxml$"},
    {"pattern": ".*\\.css$"},
    {"pattern": ".*\\.gls$"},
    {"pattern": ".*\\.json$"},
    {"pattern": ".*\\.dat$"},
    {"pattern": ".*\\.license$"},
    {"pattern": ".*\\.frag$"},
    {"pattern": ".*\\.vert$"},
    {"pattern": ".*\\.obj$"},
    {"pattern": ".*\\.mtl$"},
    {"pattern": ".*\\.js$"}
  ]
}