java - Filtering sources before compilation in NetBeans & Ant -
i need filter java files before compilation, leaving original sources unchanged , compiling filtered ones (basically, need set build date , such). i'm using netbeans great ant build-files.
so, 1 day discovered need pre-process source files before compilation, , ran big problem. no, did not run @ once, did research, failed. so, here comes sad story...
i found "filter" option of "copy" task, overrided macrodef "j2seproject3:javac" in build-impl.xml file , added filter in middle of it. got desired result, yes, tests not working, since use macrodef too.
next, tired overriding "-do-compile" target, copying&filtering files directory build/temp-src, , passing argument of new source directory "j2seproject3:javac":
<target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml, -compile-depend,-prepare-sources" if="have.sources" name="-do-compile"> <j2seproject3:javac gensrcdir="${build.generated.sources.dir}" srcdir="build/temp-src"/> <copy todir="${build.classes.dir}"> <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/> </copy> </target>
and ant says me, macrodef in question not exist!
the prefix "j2seproject3" element "j2seproject3:javac" not bound.
that's strange, since build-impl.xml contains macrodef, , build-impl.xml imported main build file.
and, way, cannot edit build-impl.xml directly, since netbeans rewrites on every other build.
so, question is: how can automatically filter sources before compiling in netbeans, , not break build process?
looking @ default build.xml, contains comment reads (in part):
there exist several targets default empty , can used execution of tasks. these targets executed before , after main targets. are: -pre-init: called before initialization of project properties -post-init: called after initialization of project properties -pre-compile: called before javac compilation -post-compile: called after javac compilation -pre-compile-single: called before javac compilation of single file -post-compile-single: called after javac compilation of single file -pre-compile-test: called before javac compilation of junit tests -post-compile-test: called after javac compilation of junit tests -pre-compile-test-single: called before javac compilation of single junit test -post-compile-test-single: called after javac compilation of single juunit test -pre-jar: called before jar building -post-jar: called after jar building -post-clean: called after cleaning build products
so, inject pre-compile processing, provide definition -pre-compile
.
fwiw, error got because j2seprojectx
prefix defined on project
tag of build-impl.xml, , code in build.xml outside of tag.
Comments
Post a Comment