# FXML Compiler
## The project is not yet published to maven.
## Introduction
This projects aims at generating Java code from FXML files.
## Requirements
- Java 21+ for the plugin
- The generated code can be compatible with older java versions.
- Maven 3.6.3+
## Installation
Add the plugin to your project:
```xml
ch.gtache.fxml-compiler
fxml-compiler-maven-plugin
1.0.0
compile
```
Optionally add dependencies to the plugin (e.g. when using MediaView and controlsfx):
```xml
ch.gtache.fxml-compiler
fxml-compiler-maven-plugin
1.0.0
compile
org.openjfx
javafx-media
${javafx.version}
org.controlsfx
controlsfx
${controlsfx.version}
```
## Advantages
- Compile-time validation
- Faster startup speed for the application
- Possibility to use controller factories to instantiate controllers with final fields
- Very basic support for bidirectional bindings
- Easier time with JPMS
- No need to open the controllers packages to javafx.fxml
- No need to open the resources packages when using use-image-inputstream-constructor (if images or resource bundles
are in the project resources)
## Disadvantages
- `fx:script` is not supported
- Expect some bugs (file an issue if you see one)
- Expression binding support is very basic
- Probably not fully compatible with all FXML features (file an issue if you need one in specific)
- All fxml files must have a `fx:controller` attribute
## Parameters
### Controller injection
There are two ways to inject controllers into a view:
- `INSTANCE`: Inject the controller instance
- This is the default injection method
- `FACTORY`: Inject the controller factory
- This injection method is required if the FXML tree contains multiple times the same controller class.
- By default, the factory is a `Supplier`, but if used in conjunction with `field-injection`set to
`FACTORY`, the factory is a `Function