NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
bdschubert
Joined: 01 Oct 2009 Posts: 66 Location: Ventura, CA
|
Posted: Mon Jan 16, 2012 1:25 pm Post subject: [platform-dev] Re: Where in "NBP's Ant hell" add trigger calling bytecode instrumentation? |
|
|
Maybe the netbeans-extra hook target will work for you. See the harness/README file for more info.
Regards,
--Bruce
| Quote: | -------- Original Message --------In non-NBP Java project it's easy to find in build-impl.xml that I need to override "-post-compile" target and that's it...
...
Where is similar equivalent for -post-compile in NBP's Ant hell?
...
PS: Sorry for term "ant hell" but IMHO it is - this area is poor/chaotic documented at least to me
|
|
|
| Back to top |
|
 |
PETR SOMOL Posted via mailing list.
|
Posted: Mon Jan 16, 2012 1:47 pm Post subject: [platform-dev] Re: Where in "NBP's Ant hell" add trigger calling bytecode instrumentation? |
|
|
In standard NB Java projects build-impl.xml targets can be overridden manually in build.xml.
The commentary that appears in each NB J2SE project's build.xml suggests:
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They 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
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="JavaFXApplication5-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
Petr
On 16.1.2012 13:54, Libor Jelinek wrote: | Quote: | Hello, I would like to use ActiveJDBC library (http://code.google.com/p/activejdbc/, implementation of Active Record pattern in Java. Inspired by Ruby on Rails ActiveRecord). Library needs to modify compiled bytecode to add all "magic" that makes this library easy to use.
In non-NBP Java project it's easy to find in build-impl.xml that I need to override "-post-compile" target and that's it...
<target name="-post-compile">
<java classname="org.javalite.instrumentation.Main" failonerror="true">
<sysproperty key="outputDirectory" value="${build.classes.dir}"/>
<classpath>
<pathelement path="${build.classes.dir}" />
<pathelement path="${javac.classpath}" />
<pathelement path="${javac.processorpath}" />
</classpath>
</java>
</target>
ActiveJDBC has also how-to page for NetBeans: http://code.google.com/p/activejdbc/wiki/NetbeansIntegration. In another words: Where is similar equivalent for -post-compile in NBP's Ant hell?
PS: Sorry for term "ant hell" but IMHO it is - this area is poor/chaotic documented at least to me
Thanks!
Libor
|
|
|
| Back to top |
|
 |
libor
Joined: 03 Jun 2011 Posts: 60
|
Posted: Mon Jan 16, 2012 2:23 pm Post subject: [platform-dev] Re: Where in "NBP's Ant hell" add trigger calling bytecode instrumentation? |
|
|
Hi Petr,you re-post very descriptive and intuitive help from non-NBP (Java SE) project. But for NBP module it's not such easy.
Continuing Bruce's suggestment I wrote this:
<target name="netbeans-extra">
<java classname="org.javalite.instrumentation.Main" failonerror="true">
<sysproperty key="outputDirectory" value="${build.classes.dir}"/>
<classpath>
<pathelement path="${module.processor.classpath}" />
</classpath>
</java>
</target>
This time class responsible instrumentation is called but this ugly exception saying that my model class is not found....
IMHO because netbeans-extra is not same as -post-compile target.
*************************** START INSTRUMENTATION ****************************
Directory: /home/libor/NetBeansProjects/AJonNBP/module1/build/classes
Exception in thread "main" java.lang.RuntimeException: org.javalite.instrumentation.InstrumentationException: javassist.NotFoundException: pokusy.Employee
at org.javalite.instrumentation.Instrumentation.instrument(Instrumentation.java:59)
at org.javalite.instrumentation.Main.main(Main.java:29)
Caused by: org.javalite.instrumentation.InstrumentationException: javassist.NotFoundException: pokusy.Employee
at org.javalite.instrumentation.InstrumentationModelFinder.classFound(InstrumentationModelFinder.java:60)
at org.javalite.activejdbc.ModelFinder.findFiles(ModelFinder.java:173)
at org.javalite.activejdbc.ModelFinder.processDirectory(ModelFinder.java:142)
at org.javalite.activejdbc.ModelFinder.processDirectory(ModelFinder.java:147)
at org.javalite.activejdbc.ModelFinder.processDirectoryPath(ModelFinder.java:131)
at org.javalite.instrumentation.Instrumentation.instrument(Instrumentation.java:49)
... 1 more
Caused by: javassist.NotFoundException: pokusy.Employee
at javassist.ClassPool.get(ClassPool.java:436)
at org.javalite.instrumentation.InstrumentationModelFinder.classFound(InstrumentationModelFinder.java:52)
... 6 more
Libor
2012/1/16 PETR SOMOL <address-removed ([email]address-removed[/email])>
| Quote: | In standard NB Java projects build-impl.xml targets can be overridden manually in build.xml.
The commentary that appears in each NB J2SE project's build.xml suggests:
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They 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
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="JavaFXApplication5-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
Petr
On 16.1.2012 13:54, Libor Jelinek wrote: | Quote: | Hello, I would like to use ActiveJDBC library (http://code.google.com/p/activejdbc/, implementation of Active Record pattern in Java. Inspired by Ruby on Rails ActiveRecord). Library needs to modify compiled bytecode to add all "magic" that makes this library easy to use.
In non-NBP Java project it's easy to find in build-impl.xml that I need to override "-post-compile" target and that's it...
<target name="-post-compile">
<java classname="org.javalite.instrumentation.Main" failonerror="true">
<sysproperty key="outputDirectory" value="${build.classes.dir}"/>
<classpath>
<pathelement path="${build.classes.dir}" />
<pathelement path="${javac.classpath}" />
<pathelement path="${javac.processorpath}" />
</classpath>
</java>
</target>
ActiveJDBC has also how-to page for NetBeans: http://code.google.com/p/activejdbc/wiki/NetbeansIntegration. In another words: Where is similar equivalent for -post-compile in NBP's Ant hell?
PS: Sorry for term "ant hell" but IMHO it is - this area is poor/chaotic documented at least to me
Thanks!
Libor
|
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|