ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Kost <s.k...@webmacher.de>
Subject Re: Task to remove a method from .java file
Date Wed, 07 Aug 2002 11:52:21 GMT
There is another possible solution, it's abit hackish too.
Even though java has no real preprocessor, the compiler can behave the
same way. Just have a static class

final class SourceConfig {
	final static boolean ejbVersion=true;
}

Then use in the source

if(SourceConfig.ejbConfig==true) {
...
}

Finally, the ant-script just need to patch the SourceConfig class. SUch
comparissions with final static vars get optimized and if it evalues to
fasle, the innercode can never be called, so it is dropped when
compiling(I verified this with jode). Unfortunately this leaves empty
method skelletons in there. I am not sure how we could persuade the
compiler to drop them too.
I've just used this approch to wrap debug-output statements, so that I
can 100% drop them.

Stefan


> Sounds like #ifdef. Actually, some preprocessor-like stuff would be 
> quite a nice thing in Java, and in Ant. Is there anything like that, or 
> a clever way to do it with Ant? I didn't notice it, if there is, 
> although it sounds like the regex stuff could do it. Never thought to 
> try!
> 
> -Ian
> 
> On Tuesday, August 6, 2002, at 01:40  PM, Luis N. Polasek wrote:
> 
> > Quoting Matt Benson <gudnabrsam@yahoo.com>:
> >
> >> What is your purpose in removing a method from a Java
> >> source file?
> >
> >         That´s becaus I have a two releases of the same project, one 
> > using EJB and the other using only Tomcat. The idea is to strip the 
> > EJB methods form the <ComponentName>Beam  source file. This methods 
> > are (ejbCreate, ejbPassivate, etc).
> >
> >         And I´m trying using ant to automate the construction of the 
> > Tomcat version out from the EJB version.
> >
> >
> >
> > --
> > To unsubscribe, e-mail:   
> > <mailto:ant-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: 
> > <mailto:ant-user-help@jakarta.apache.org>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
> 
-- 

 < W E B M A C H E R > 
EDV+INTERNETSERVICE GMBH

POST: August Bebel Str. 69
      04275 Leipzig

FON:  +49 341 30 34 833
FAX:  +49 341 30 34 840
WEB:  www.webmacher.de


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message