On Wed, May 8, 2019 at 6:25 AM Jaroslav Tulach <[email protected]>
wrote:
> Dne úterý 7. května 2019 2:46:19 CEST, Damjan Jovanovic napsal(a):
> > Hi
> >
> > I am trying to develop some improvements to Java Free-Form projects, such
> > as auto-detection of the Java version and sources classpath from the Ant
> > file, but I am struggling to import Ant into the java/java.freeform
> module.
> >
> > In fact, it seems NetBeans goes to great lengths to avoid ever using Ant
> > APIs directly: in the whole repository, org.apache.tools.ant.Project is
> > only ever imported in extide/o.apache.tools.ant.module/src-bridge.
> >
> > Are NetBeans modules not allowed to use Ant directly? Why?
>
> Hello Damjan,
> I guess it is for historic reasons. In the early stages, when Ant was
> developed hectically, it wasn't very compatible from the Java API point of
> view. This separation might have been primarily a shield against
> incompatible
> changed.
>
> The other aspect is that the Ant support can run with any installed
> version of
> Ant, not just the bundled one. I think.
>
>
Thank you. That makes sense.
I now have a different problem.
I found NetBeans's Ant parser in
extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/api/support/TargetLister.java
[1]
and patched
java/java.freeform/src/org/netbeans/modules/java/freeform/ui/SourceFoldersPanel.java
[2]
to use it to extract Ant targets, search the child XML nodes of the
"compile" target for the "javac" task, and extract more information (eg.
Java version) from it. It worked, but the node attributes I get are from
before Ant's variable substitution, ie. something like "${java.version}"
instead of "1.7".
Then I patched [1] to perform variable substitution on targets, but it's
like the patched JAR is not getting used. The JULI logging I added in [1]
isn't performed, and when I step into it with jdb, the line numbers are
wrong, and calling
TargetLister.class.getProtectionDomain().getCodeSource().getLocation() from
[2] definitely gives me the right path for [1] and disassembling that class
with javap shows the changes I made, yet it's like a completely different
class is getting used...