A Maven plugin to generate boilerplate loading code for FXML resources.
Assuming a FXML resource called ExamplePane.fxml
is available at compile- and run-time
the following code can then be used:
FXMLLoader loader = ExamplePaneFXML.getInstance().load();
Pane root = loader.getRoot();
ExampleController controller = loader.getController();
FXWrap generates a class for every FXML file it finds at compile-time. These are singletons
with a method public String getRelativePath()
which returns the path to the FXML file and
public FXMLLoader load() throws IOException
which loads the FXML file and returns the loader (a new FXMLLoader
is used every time).
To add the plugin you must add it to your POM along with a helper plugin and the JitPack repository.
<plugin>
<groupId>com.github.Fylipp</groupId>
<artifactId>fxwrap-maven-plugin</artifactId>
<version>v1.0.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>test</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Option | Type | Default | Description |
---|---|---|---|
classNameTemplate | String | %sFXML | The template for generated class names |
outputDirectory | File | ${project.build.directory}/generated-sources/ | The output directory |
resourceDirectories | Resource[] | ${project.build.resources} | The directories to scan |
fxmlFileFormat | String | fxml | The file extension used by FXML files |
MIT.