Thomas Kellerer schrieb am 26.04.2020 um 10:56:
> Java has been supporting providing a classpath with a wildcard for quite some
> time now, e.g.:
>
> java -cp libs/* com.package.MyClass
>
> which is really usefull especially if you are using libraries with version
> numbers.
>
> However in an Ant based project in NetBeans, it's not possible to define such
> a classpath.
>
> My project uses dynamic classes resolved at runtime (not at compile
> time) and for that it would be really helpful if it was possible to
> add such a classpath entry to the project libraries ("Run"
> Classpath)
>
> I wonder if there is any Ant target I can override in my own build
> script to add the "dynamic" directory to the run classpath without
> having NetBeans complaining about missing references all the time.
For anyone who is interested: I managed to do this by overwriting the -pre-init
task.
As Ant variables can't be changed through a <property> task, I had to override
the run.classpath property by loading them from a properties file:
<target name="-pre-init">
<property file="nb-classpath.properties"/>
</target>
The nb-classpath.properties contains the following:
run.classpath=\
${build.classes.dir}:\
${javac.classpath}:\
../install/ext/*
This uses the classpath defined through the UI and then adds my "ext" directory
using the * syntax.
One drawback of this solution is, that "Compile on Save" has to be disabled,
because the Ant script is not used to run the application when it's enabled.
Thomas
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists