ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lev Serebryakov <>
Subject How to write <uptodate> for <javah> task (i.e. check several headers files by class files or java files)?
Date Sat, 04 May 2013 08:08:41 GMT
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,
  (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,

 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/" 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:

    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

[uptodate] The targetfile "<full-path>/<name-1>.h,<relative-path>/<name-2>.h"
does not exist.

    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 <>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message