Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 39479 invoked from network); 21 Aug 2009 15:31:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Aug 2009 15:31:38 -0000 Received: (qmail 15175 invoked by uid 500); 21 Aug 2009 15:31:59 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 15114 invoked by uid 500); 21 Aug 2009 15:31:59 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 15104 invoked by uid 99); 21 Aug 2009 15:31:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Aug 2009 15:31:58 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ddevienne@gmail.com designates 209.85.212.198 as permitted sender) Received: from [209.85.212.198] (HELO mail-vw0-f198.google.com) (209.85.212.198) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Aug 2009 15:31:50 +0000 Received: by vws36 with SMTP id 36so760257vws.10 for ; Fri, 21 Aug 2009 08:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=7nO2NW8vY73kwo7RMcj/8jKYYyOqW2m+J59RS6UZ8q4=; b=GDLvDwh/FA9mKPHX5D5uvG4QZm4DYRJfBhLGbAHKnWpDtvUeihNxzygApcxMJTN2Mr z2uUUEQgoDgJ6xjNmJfRWAyouP3YLnTBmHA62uJfV+3ZiRWfe1gfZpWVabNQw8lAERI8 2YmU69BXpspX5QXzxES/ehsBBwWyapLHAk5Iw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=dAIN/bHb+HiRksw1xEkW9YD4nOHP9URneiuq7gf5++uu3qY3/uBMbmtde6OF0pbNOg 3Np6G9MXpwbNWTFWMWNnNUUd9o69m/dKo8ze1+Y3YBZLOBAzjqNcfcDraZOUQD+9bCCy c3DuDH7KEksqVtKTpHqTXPm6GD2DiyYuMqAYM= MIME-Version: 1.0 Received: by 10.220.69.211 with SMTP id a19mr953619vcj.20.1250868689742; Fri, 21 Aug 2009 08:31:29 -0700 (PDT) In-Reply-To: References: Date: Fri, 21 Aug 2009 10:31:29 -0500 Message-ID: <255d8d690908210831wbd0a993w565333898c7a9e4e@mail.gmail.com> Subject: Re: Selecting source files if they have been compiled From: Dominique Devienne To: Ant Users List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Aug 20, 2009 at 9:08 AM, Stefan Walter wrote: > is there a good/elegant recipe for selecting those source files that javac > chose to compile? Yes. Introspect the .class files to know which source files they came from. Assumes debug info in left in the .class, but you can tell javac that you only want to keep the SourceFile attribute I think, instead of the full debug info. I used this technique successfully to find "orphan" class file in my build tree to delete them, when doing incremental builds. My selector used a custom class file parser (single 600 line .java file, with comments) that a colleague wrote as a learning exercise, because it was easiest for me, but libraries like ASM, BCEL, Javassist can do the parsing for you. All you need is to read the "SourceFile" attribute, that's it. Using ASM's SAX-like parser should make that easy and fast. All .class files for inner or package-private classes from a given .java file will have the same "SourceFile" attribute. Make a selector or task or custom resource collection of that, that does the copy of those sources, you have an elegant solution. Requires coding though :) --DD /** * An Ant file selector that matches class file * which has no corresponding Java source file. *

* Note that class files compiled without debug information (specifically * the SourceFile attribute of the class file) will be ignored by this * selector. */ public class OrphanClassFileSelector extends BaseExtendSelector { ... } --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org