Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 48802 invoked from network); 21 Aug 2006 04:51:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Aug 2006 04:51:00 -0000 Received: (qmail 14857 invoked by uid 500); 21 Aug 2006 04:50:57 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 14803 invoked by uid 500); 21 Aug 2006 04:50:57 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 14792 invoked by uid 99); 21 Aug 2006 04:50:57 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Aug 2006 21:50:57 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of jason.dillon@gmail.com designates 64.233.166.180 as permitted sender) Received: from [64.233.166.180] (HELO py-out-1112.google.com) (64.233.166.180) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Aug 2006 21:50:56 -0700 Received: by py-out-1112.google.com with SMTP id x66so5210132pye for ; Sun, 20 Aug 2006 21:50:35 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer:sender; b=F8A8QTTpvnXi9zEm8Et9bhWP6ZPKnr80fBsGEwGDHtBoJaMIKx5ByMOKYe5t4X6Q2yRllcF7LMEA9DvTZ2fFxL8l7SBDIH8hxK3SJirY5LAaWGjbgLN64U1DgmpXJ3Lnl/nNRFRAFlG8PmIG/Vg2FTWCwcB6msVxS+EIr9IUrD8= Received: by 10.35.38.17 with SMTP id q17mr12447186pyj; Sun, 20 Aug 2006 21:50:35 -0700 (PDT) Received: from ?10.0.1.4? ( [24.7.69.241]) by mx.gmail.com with ESMTP id n77sm215242pye.2006.08.20.21.50.34; Sun, 20 Aug 2006 21:50:35 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.2) In-Reply-To: <4B4DFFAC-3ECE-49E0-B670-0759EA878E22@optusnet.com.au> References: <20060818231554.2D17A1A981A@eris.apache.org> <1EDAEDCE-A472-4862-9F86-561C9E86783C@optusnet.com.au> <2E4F9952-D500-4083-ADE8-0EA188BFAE7A@iq80.com> <4B4DFFAC-3ECE-49E0-B670-0759EA878E22@optusnet.com.au> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Jason Dillon Subject: Re: svn commit: r432773 - /geronimo/trunk/modules/geronimo-testsupport/src/main/java/org/apache/geronimo/testsupport/TestSupport.java Date: Sun, 20 Aug 2006 21:50:29 -0700 To: dev@geronimo.apache.org X-Mailer: Apple Mail (2.752.2) Sender: Jason Dillon X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N It should work fine in Eclipse too. I'll see if I can fix why the eclipse plugin is adding that lame entry for target/classes/META-INF... seems broke to me. --jason On Aug 20, 2006, at 9:43 PM, Gianny Damour wrote: > This is cool that this also works in IDEA. > > Regarding this proble, this is the script that I use to fix > the .classpath (from the geronimo dir): > ls */*/.classpath | while read file; do cat $file | grep -v classes/ > META-INF > ${file}_new; mv ${file}_new $file; done > > BTW, in Eclipse System.getProperty("basedir", System.getProperty > ("user.dir")) was working as by default Eclipse starts JUnit tests > in the project working directory, i.e. the module root. > > Thanks, > Gianny > > > On 21/08/2006, at 2:25 PM, Jason Dillon wrote: > >> This was more what I was thinking: >> >> >> protected final File getBaseDir() { >> File dir; >> >> // If ${basedir} is set, then honor it >> String tmp = System.getProperty("basedir"); >> if (tmp != null) { >> dir = new File(tmp); >> } >> else { >> // Find the directory which this class (or really the sub- >> class of TestSupport) is defined in. >> String path = getClass().getProtectionDomain >> ().getCodeSource().getLocation().getFile(); >> >> // We expect the file to be in target/test-classes, so go >> up 2 dirs >> dir = new File(path).getParentFile().getParentFile(); >> >> // Set ${basedir} which is needed by logging to initialize >> System.setProperty("basedir", dir.getPath()); >> } >> >> return dir; >> } >> >> >> Appears to work well too, in IDEA at least, probably works fine in >> Eclipse too... but I've got a ton of "Cannot nest output >> folder..." errors that prevent me from actually checking. >> >> --jason >> >> >> On Aug 19, 2006, at 8:11 AM, Dain Sundstrom wrote: >> >>> I don't think that trick will work for an IDE, as it will only >>> tell you which directory the IDE started in. In intellij you can >>> use something like this: >>> >>> public static String baseDir() { >>> Class myClass = null; // TestClass.class >>> >>> URL classUrl = myClass.getClassLoader().getResource >>> (myClass.getName().replace('.', '/') + ".class"); >>> if (classUrl == null) { >>> throw new RuntimeException("Could not find TestClass"); >>> } >>> >>> File targetDir = null; >>> try { >>> URLConnection urlConnection = classUrl.openConnection(); >>> >>> if (urlConnection instanceof JarURLConnection) { >>> JarURLConnection jarConnection = >>> (JarURLConnection) urlConnection; >>> classUrl = jarConnection.getJarFileURL(); >>> >>> targetDir = new File(new URI(classUrl.toString >>> ())).getParentFile(); >>> } else { >>> File classesDir = new File(new URI >>> (classUrl.toString())).getParentFile(); >>> for (char c : myClass.getName().toCharArray()) { >>> if (c == '.') { >>> classesDir = classesDir.getParentFile(); >>> } >>> } >>> } >>> } catch (Exception e) { >>> log.debug("Could not determine classes installation >>> directory", e); >>> } >>> >>> if (targetDir != null) { >>> File moduleDir = targetDir.getParentFile(); >>> return moduleDir.getAbsolutePath(); >>> } else { >>> return System.getProperty("basedir", >>> System.getProperty("user.dir")); >>> } >>> >>> } >>> >>> Make sure to test this code, because I didn't :) >>> >>> -dain >>> >>> >>> On Aug 18, 2006, at 4:47 PM, Jason Dillon wrote: >>> >>>> Ya, I will add that as soon as I can verify that it works in >>>> IDEA an Eclipse... probably sometime next week. >>>> >>>> --jason >>>> >>>> >>>> On Aug 18, 2006, at 4:31 PM, Gianny Damour wrote: >>>> >>>>> On 19/08/2006, at 9:15 AM, jdillon@apache.org wrote: >>>>> >>>>>> Author: jdillon >>>>>> Date: Fri Aug 18 16:15:53 2006 >>>>>> New Revision: 432773 >>>>>> >>>>>> URL: http://svn.apache.org/viewvc?rev=432773&view=rev >>>>>> Log: >>>>>> Comments about BASEDIR and IDE magic >>>>>> >>>>>> Modified: >>>>>> geronimo/trunk/modules/geronimo-testsupport/src/main/java/ >>>>>> org/apache/geronimo/testsupport/TestSupport.java >>>>>> >>>>>> Modified: geronimo/trunk/modules/geronimo-testsupport/src/main/ >>>>>> java/org/apache/geronimo/testsupport/TestSupport.java >>>>>> URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/ >>>>>> geronimo-testsupport/src/main/java/org/apache/geronimo/ >>>>>> testsupport/TestSupport.java? >>>>>> rev=432773&r1=432772&r2=432773&view=diff >>>>>> ================================================================= >>>>>> ============= >>>>>> --- geronimo/trunk/modules/geronimo-testsupport/src/main/java/ >>>>>> org/apache/geronimo/testsupport/TestSupport.java (original) >>>>>> +++ geronimo/trunk/modules/geronimo-testsupport/src/main/java/ >>>>>> org/apache/geronimo/testsupport/TestSupport.java Fri Aug 18 >>>>>> 16:15:53 2006 >>>>>> @@ -37,6 +37,12 @@ >>>>>> private static final File BASEDIR; >>>>>> >>>>>> static { >>>>>> + // >>>>>> + // TODO: Add some special magic here to figure this >>>>>> out when we are running from >>>>>> + // and IDE, like IDEA or Eclipse. user.dir/ >>>>>> target might work... but need >>>>>> + // to validate what env each IDE has this set to. >>>>>> + // >>>>>> + >>>>>> String tmp = System.getProperty("basedir"); >>>>> >>>>> Hi Jason, >>>>> >>>>> This is the trick that Dain has suggested: >>>>> >>>>> private static final tmp = System.getProperty("basedir", >>>>> System.getProperty("user.dir")); >>>>> >>>>> >>>>> Thanks, >>>>> Gianny >>>>> >>>>> >>>>> >>>>>> if (tmp == null) { >>>>>> throw new Error("Missing 'basedir' property; >>>>>> tests need this property set to run correctly"); >>>>>> >>>>>> >>>>> >>> >> >