1 year ago
#359988
I try so hard but I cry harder
Obtain return value of "condition" apache ant
I need to determine whether the user is on linux OS or windows OS.
For this I use the condition
statement. I gave it a value and an else
value. My only question now is: How can I obtain the condition
value regardless and use it? I need the obtained value to concatenate it to a part of my string so I can retrieve the correct JAR files.
My code looks like this:
<project name="myproj" default="dist">
<property file="build.properties"/>
<property file="${user.home}/build.properties"/>
<path id="run.classpath">
<fileset dir="${dist.dir}">
<include name="${project.name}.jar"/>
</fileset>
</path>
<condition property="platformDetected" value="win" else="linux">
<os family="windows" />
</condition>
<target name="compile">
<mkdir dir="${bin.dir}"/>
<javac srcdir="${src.dir}"
destdir="${bin.dir}"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
includeantruntime="false">
<classpath>
<fileset dir="${lib.dir}/javafx-sdk-18-${platformDetected}/lib">
<include name="**/*.jar" />
</fileset>
</classpath>
<classpath>
<fileset dir="${lib.dir}/postgresql">
<include name="**/*.jar" />
</fileset>
</classpath>
<classpath>
<fileset dir="${lib.dir}/csvreader">
<include name="**/*.jar" />
</fileset>
</classpath>
<compilerarg line="--module-path ${lib.dir}/javafx-sdk-18-${platformDetected}/lib/"/>
<compilerarg line="--add-modules javafx.controls"/>
</javac>
</target>
<target name="dist" depends="compile">
<mkdir dir="${dist.dir}"/>
<jar jarfile="${dist.dir}/${project.name}.jar"
basedir="${bin.dir}"
manifest="${src.dir}/Manifest.mf">
<zipgroupfileset dir="${lib.dir}/javafx-sdk-18-${platformDetected}/lib" includes="**/*.jar"/>
<zipgroupfileset dir="${lib.dir}/postgresql" includes="**/*.jar"/>
<zipgroupfileset dir="${lib.dir}/csvreader" includes="**/*.jar"/>
</jar>
</target>
<target name="build" depends="dist">
<java jar="${dist.dir}/${project.name}.jar" fork="true">
<jvmarg line="--module-path ${lib.dir}/javafx-sdk-18-${platformDetected}/lib/"/>
<jvmarg line="--add-modules javafx.controls"/>
</java>
</target>
<target name="clean">
<delete dir="${bin.dir}"/>
<delete dir="${dist.dir}"/>
</target>
</project>
How can I call this:
<condition property="platformDetected" value="win" else="linux">
<os family="windows" />
</condition>
and pass it to this line (for example):
<jvmarg line="--module-path ${lib.dir}/javafx-sdk-18-${platformDetected}/lib/"/>
Edit: Aparently I am already doing it right(?), but I end up having an error.
The error which is produced when I run ant build
is:
[java] Graphics Device initialization failed for : d3d, sw
[java] Error initializing QuantumRenderer: no suitable pipeline found
[java] java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
[java] at javafx.graphics@18/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
[java] at javafx.graphics@18/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:253)
[java] at javafx.graphics@18/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:266)
[java] at javafx.graphics@18/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
[java] at javafx.graphics@18/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
[java] at javafx.graphics@18/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
[java] at javafx.graphics@18/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
[java] at javafx.graphics@18/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
[java] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
[java] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[java] at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071)
[java] Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
[java] at javafx.graphics@18/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)
[java] at javafx.graphics@18/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
[java] at java.base/java.lang.Thread.run(Thread.java:831)
[java] Exception in thread "main" java.lang.reflect.InvocationTargetException
[java] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
[java] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[java] at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071)
[java] Caused by: java.lang.RuntimeException: No toolkit found
[java] at javafx.graphics@18/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:278)
[java] at javafx.graphics@18/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
[java] at javafx.graphics@18/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
[java] at javafx.graphics@18/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
[java] at javafx.graphics@18/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
[java] at javafx.graphics@18/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
[java] ... 5 more
[java] Java Result: 1
java
ant
0 Answers
Your Answer