You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Lev Serebryakov <le...@serebryakov.spb.ru> on 2013/05/04 10:08:41 UTC
How to write for task (i.e. check several headers files by class files or java files)?
Hello, User.
I want to check do I need to run <javah> task or not to re-generate
header files for classes, which contains native methods. I want to use
pure Ant 1.8.x, cross-platform.
What I have as input:
(1) Property with path to Java source tree, "path.src"
(2) Property with path where <javac> task creates classes,
"path.classes"
(3) Property with path where header files live "path.native"
(4) List of classes with native methods, as comma-separated list in
one property "classes.native", like "my.package.impl.Class1,
my.packahe.impl.Class2".
What I want as output:
Property "native.skip" set to "true" if every header file with name
like "${path.native}/my_package_impl_Class1.h" is newer than java
file "${path.src}/my/package/impl/Class1.java" or, alternatively, it
is newer than "${path.classes}/my/package/impl/Class1.class".
Please note: I have SEVERAL classes in my list! With single class
task is relativetely easy!
What have I tried so far:
(1)
First transform class list to two file lists (as strings,
comma-separated, not <filelist>/<fileset>!), one with paths to
java sources, one with paths to headers. It works with some
<loadresource>/<propertysource>/<filterchain> magic (very, very
ugly, but it works).
Then I pass such "list" of sources to <srcfile includes=""> for
<uptodate> and it seems to work, but such "list" as
<uptodate targetfile> doesn't for for sure: Verbose/debug output
says:
[uptodate] The targetfile "<full-path>/<name-1>.h,<relative-path>/<name-2>.h" does not exist.
(2)
Then I tried to construct list of headers on-the-fly with <mapper>
inside <uptodate>. And failed completely, as I could use
<packagemapper> to convert from path to dotted-delimetered name of
file, but after that I could not convert dots to underscores, as
<regexpmapper> require FULL name in "to" attribute, not only
replacement. And, yes, what should I do if my paths contains dots!?
It will break everything!
What should I do?
And other question: is here any way to get list of needed classes
automagically? Search all files with "native" word is not a solution,
as this word could present in comments and JavaDocs of other classes,
without native methods!
--
// Black Lion AKA Lev Serebryakov <le...@serebryakov.spb.ru>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to write for task (i.e. check several headers files by class files or java files)?
Posted by Lev Serebryakov <le...@serebryakov.spb.ru>.
Hello, Ant.
You wrote 4 мая 2013 г., 12:08:41:
LS> (2)
LS> Then I tried to construct list of headers on-the-fly with <mapper>
LS> inside <uptodate>. And failed completely, as I could use
LS> <packagemapper> to convert from path to dotted-delimetered name of
LS> file, but after that I could not convert dots to underscores, as
LS> <regexpmapper> require FULL name in "to" attribute, not only
LS> replacement. And, yes, what should I do if my paths contains dots!?
LS> It will break everything!
Ok, this construction works:
<loadresource property="java.sources.with.native">
<propertyresource name="classes.native" />
<filterchain>
<tokenfilter>
<stringtokenizer delims=","/>
<replacestring from="." to="/"/>
<replaceregex pattern="$$" replace=".java" />
<tokenfilter>
<filterchain>
<loadresource>
<uptodate property="javah.skip">
<srcfiles dir="${path.src}/src" includes="${java.sources.with.native}" />
<chainedmapper>
<packagemapper from="*.java" to="${path.native}/*" />
<filtermapper>
<replacestring from="." to="_" />
<suffixlines suffix=".h" />
<filtermapper>
</chainedmapper>
</uptodate>
--
// Black Lion AKA Lev Serebryakov <le...@serebryakov.spb.ru>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org