I am trying to use the Gluon Desktop tools to make a JavaFX app. I have tried creating a new Maven-driven app in both of these ways:
- The Gluon Start web app
- The Gluon - Single View Project new project template provided by the Gluon plugin for IntelliJ.
In both cases, the provided POM file uses a property named gluonfx.target
in this line:
<target>${gluonfx.target}</target>
Further down in the POM, a couple of profile
elements defines gluonfx.target
for values of ios
and android
. But:
- those definitions do not prevent IntelliJ from reporting the error
Cannot resolve symbol 'gluonfx.target'
; and - I am trying to build a Gluon Desktop app, not an iOS or Android app.
Is the gluonfx.target
property defined somewhere outside the POM? Or am I supposed to define that property? If so, where and how? Should I add an element to the properties
element of the POM? If so what are the possible values for the property? Or is a profile
element missing for development of a desktop app?
Here is an entire provided POM (modified by me to use Java 20):
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>work.basil.example</groupId>
<artifactId>gluon-singleviewproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Gluon-SingleViewProject</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>20</maven.compiler.release>
<javafx.version>20</javafx.version>
<attach.version>4.0.18</attach.version>
<gluonfx.plugin.version>1.0.19</gluonfx.plugin.version>
<javafx.plugin.version>0.0.8</javafx.plugin.version>
<mainClassName>work.basil.example.GluonApplication</mainClassName>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq</groupId>
<artifactId>charm-glisten</artifactId>
<version>6.2.3</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>display</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>lifecycle</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>statusbar</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>storage</artifactId>
<version>${attach.version}</version>
</dependency>
<dependency>
<groupId>com.gluonhq.attach</groupId>
<artifactId>util</artifactId>
<version>${attach.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>Gluon</id>
<url>https://nexus.gluonhq.com/nexus/content/repositories/releases</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.plugin.version}</version>
<configuration>
<mainClass>${mainClassName}</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>gluonfx-maven-plugin</artifactId>
<version>${gluonfx.plugin.version}</version>
<configuration>
<target>${gluonfx.target}</target>
<attachList>
<list>display</list>
<list>lifecycle</list>
<list>statusbar</list>
<list>storage</list>
</attachList>
<mainClass>${mainClassName}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ios</id>
<properties>
<gluonfx.target>ios</gluonfx.target>
</properties>
</profile>
<profile>
<id>android</id>
<properties>
<gluonfx.target>android</gluonfx.target>
</properties>
</profile>
</profiles>
</project>
The
target
property for the GluonFX maven/gradle plugins is defined here: https://docs.gluonhq.com/#_targetIf you don't set the target value, it defaults to
host
, which is the target for a desktop application, to run on Linux, macOS or Windows.For other platforms (mobile or embedded), you need to set a different value.
While the Gluon samples, do define the maven property:
this doesn't apply to the samples generated from the GluonFX IDE plugins or start.gluon.io, though this doesn't really matter, given that the default
host
will be used.In any case, since IntelliJ does complain about the missing value, this can be easily fix, adding such property to the pom (and removing the mobile profiles if not needed):
Note that if you define an empty or a non valid target, you will get a runtime exception when you try
mvn gluonfx:build
.