Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 75957 invoked from network); 20 Apr 2005 16:42:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Apr 2005 16:42:22 -0000 Received: (qmail 49544 invoked by uid 500); 20 Apr 2005 12:26:00 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 49510 invoked by uid 500); 20 Apr 2005 12:26:00 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 49488 invoked by uid 99); 20 Apr 2005 12:26:00 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mailgate.uni-paderborn.de (HELO mailgate.uni-paderborn.de) (131.234.22.32) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 20 Apr 2005 05:25:59 -0700 Received: from koto.cs.upb.de ([131.234.64.189]) by mailgate.uni-paderborn.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.43) id 1DOEHT-00078k-9k for user@ant.apache.org; Wed, 20 Apr 2005 14:26:11 +0200 Message-ID: <42664A4A.6000007@upb.de> Date: Wed, 20 Apr 2005 14:25:46 +0200 From: Karsten Klohs User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ant Users List Subject: Re: Extension of the Javah-Task References: <1113982261.69743.ezmlm@ant.apache.org> <42660ED7.2070906@upb.de> In-Reply-To: X-Enigmail-Version: 0.84.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-UNI-PB_FAK-EIM-MailScanner-Information: Please see http://imap.uni-paderborn.de for details X-UNI-PB_FAK-EIM-MailScanner: Found to be clean X-UNI-PB_FAK-EIM-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (score=-7.82, required 4, ALL_TRUSTED -2.82, AUTH_EIM_USER -5.00) X-MailScanner-From: taiko@upb.de X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi again, |>>3. I took a brief look at the development of Ant tasks and |>>implementation of the javah-task. I think that it should be quite |>>easy (famous last words ;-)) to extend the javah-task, so that it |>>can take a fileset, transform the filenames internally to classnames |>>and use the existing functionality to run javah for all classes |>>corresponding to the given filenames. | | | I agree. Native support for filesets would be the cleanest solution. | | |>>I appreciate any comments to this idea. | | | All it takes is somebody who does the coding and supplies a patch ;-) here you are ;-) Can any Ant developer comment on the code snippet at the end of the mail? Basically, I have extended the original Javah-task, added a new FileSet attribute and overwritten the execute method, so that it does the following: - - Iterate over the the files of the FileSet - - Transform a file name to a full qualified path name by stripping the ".class" suffix and replacing all "file.separtor" occurrences with the character "." - - simulate the insertion of a nested class attribute in the original implementation - - finally, call the original execute method. The good news: It works, though it is a crude hack ;-) However, some issues remain on the way to a robust solution: - - support of more than one FileSet (Consider it as done ;-) ) - - what shall the task do, if the file given file is not a class file i.e. it is not ending with ".class"? Acutally, it throws a BuildException (yes, I am paranoid ;-) ) - - The implicit convention, is that the full file name exactly corresponds to the full class name. How can this restriction be relaxed? One idea is to investigate the files' contents to find the class names (using BCEL?!) the other is to at least allow a "class name construction" root relative to the root of the FileSet. Can anybody tell me how such issues are usually discussed because I am not sure that implementation and integration details belong in this user list. Best regards Karsten Klohs - ----------- BEGIN CODE SNIPPET ----------- public class JavahExt ~ extends org.apache.tools.ant.taskdefs.optional.Javah { ~ public void execute() ~ { ~ log("investigating FileSet " + fs); ~ // retrieve the file of the FileList by the DirectoryScanner ~ DirectoryScanner ds = fs.getDirectoryScanner(getProject()); // 3 ~ String[] includedFiles = ds.getIncludedFiles(); ~ for (int i = 0; i < includedFiles.length; i++) { ~ String filename = includedFiles[i]; ~ log("Transforming file name " + filename + " to class name"); ~ // transform the file name to a full qualified class name ~ String className = fileName2ClassName(filename); ~ // insert the class as if it was given by a nested class attribute ~ log("Including Class: " + className); // 4 ~ ClassArgument newClass = createClass(); ~ newClass.setName(className); ~ } ~ // launch the existing implementation ~ log("Launching Javah.execute()"); ~ super.execute(); ~ } - ------------ END CODE SNIPPET ------------ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCZkpKBPAmVXbC2rERAjQ4AJ9VbwLT99rkHavIjPDCP6gRnTxL4gCcD3k5 SHXvJVSXrhda0ksm0SMfrXI= =FM7N -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org