| View previous topic :: View next topic |
| Author |
Message |
vachi
Joined: 15 Aug 2008 Posts: 5 Location: Thailand
|
Posted: Mon Aug 18, 2008 11:21 am Post subject: Classpath customization for java free-form project |
|
|
Hello,
I am new to NB plugin development; this is my first try. Here is my problem.
I would like to write a plugin for java free-form project, that will add and remove classpath (especially ClassPath.COMPILE type, for IDE code completion, etc). The basic idea is here:
http://forums.netbeans.org/viewtopic.php?t=1201
I tried to use ProjectClassPathModifier.addRoots inside a ProjectOpenedHook subclass to do this (at the time projectOpened() is called). However, ProjectClassPathModifier.addRoots gives me UnsupportedOperationException. What am I doing wrong?
What I did is, creating a new LookupProvider, which looks up a Project, create an ProjectOpenedHook for that Project, and return it. Layer.xml specifies the Lookup in the following context:
| Code: |
<folder name="Projects">
<folder name="org-netbeans-modules-ant-freeform">
<folder name="Lookup">
<file name="mypkg.MyLookupProviderImpl.instance"/>
...
|
Is this the right approach? |
|
| Back to top |
|
 |
Jesse Glick Posted via mailing list.
|
Posted: Sat Aug 23, 2008 3:40 pm Post subject: Re: Classpath customization for java free-form project |
|
|
vachi wrote:
| Quote: | I would like to write a plugin for java free-form project, that will
add and remove classpath (especially ClassPath.COMPILE type, for IDE
code completion, etc). The basic idea is here:
http://forums.netbeans.org/viewtopic.php?t=1201
|
I think you're taking the wrong approach. You probably do not need any
special module, just a somewhat subtle use of config files. Try this
trick instead:
http://hg.openjdk.java.net/jdk7/jdk7/jdk/raw-file/tip/make/netbeans/common/properties.ent
| Quote: | I tried to use ProjectClassPathModifier.addRoots inside a
ProjectOpenedHook subclass to do this (at the time projectOpened()
is called). However, ProjectClassPathModifier.addRoots gives me
UnsupportedOperationException. What am I doing wrong?
|
Freeform projects do not support PCPM. |
|
| Back to top |
|
 |
Vadiraj Deshpande Posted via mailing list.
|
Posted: Sat Aug 23, 2008 5:54 pm Post subject: Re: Classpath customization for java free-form project |
|
|
Hi Jesse,
I have a follow up question on this :
If freeform projects do not support PCPM, what is the alternative ? I am trying to register Hibernate library to a freeform project.
-Vadiraj.
On Sat, Aug 23, 2008 at 9:09 PM, Jesse Glick <jesse.glick@sun.com (jesse.glick@sun.com)> wrote:
| Quote: | vachi wrote:
| Quote: | I would like to write a plugin for java free-form project, that will
add and remove classpath (especially ClassPath.COMPILE type, for IDE
code completion, etc). The basic idea is here:
http://forums.netbeans.org/viewtopic.php?t=1201
|
I think you're taking the wrong approach. You probably do not need any special module, just a somewhat subtle use of config files. Try this trick instead:
http://hg.openjdk.java.net/jdk7/jdk7/jdk/raw-file/tip/make/netbeans/common/properties.ent
| Quote: | I tried to use ProjectClassPathModifier.addRoots inside a
ProjectOpenedHook subclass to do this (at the time projectOpened()
is called). However, ProjectClassPathModifier.addRoots gives me
UnsupportedOperationException. What am I doing wrong?
|
Freeform projects do not support PCPM.
|
|
|
| Back to top |
|
 |
vachi
Joined: 15 Aug 2008 Posts: 5 Location: Thailand
|
Posted: Mon Aug 25, 2008 3:09 am Post subject: Re: Classpath customization for java free-form project |
|
|
Thank you. I also suspected that this should be doable without writing new module, but no-one replied me on the previous post, so I think might be easier to try my own idea this way. Of couse it was not as easy as I thought
How do I incorporate this properties file to project.xml? I don't even know which tags are available for use. Presumably there is a tag used for including a properties file? |
|
| Back to top |
|
 |
Jesse Glick Posted via mailing list.
|
Posted: Mon Aug 25, 2008 5:25 pm Post subject: Re: Classpath customization for java free-form project |
|
|
vachi wrote:
| Quote: | | Quote: | http://hg.openjdk.java.net/jdk7/jdk7/jdk/raw-file/tip/make/netbeans/common/properties.ent
|
How do I incorporate this properties file to project.xml?
|
See other files in make/netbeans/ for examples of usage.
| Quote: | I don't even know which tags are available for use. Presumably there
is a tag used for including a properties file?
|
<properties-file>. The documentation for the freeform project.xml file
can be found in the Freeform Project Extras module on the update center. |
|
| Back to top |
|
 |
Jesse Glick Posted via mailing list.
|
Posted: Mon Aug 25, 2008 5:35 pm Post subject: Re: Classpath customization for java free-form project |
|
|
Vadiraj Deshpande wrote:
| Quote: | If freeform projects do not support PCPM, what is the alternative? I
am trying to register Hibernate library to a freeform project.
|
The only way to programmatically change the classpath for a freeform
project is to rewrite its project.xml. As I mentioned before, if all you
wanted to do was make the classpath sensitive to the OS, you do not need
a plugin at all, just better metadata. |
|
| Back to top |
|
 |
vachi
Joined: 15 Aug 2008 Posts: 5 Location: Thailand
|
Posted: Tue Aug 26, 2008 6:45 am Post subject: |
|
|
Thanks! It works!
Here is what I did, just in case someone want to do something like me:
Create a properties file like:
| Quote: | compile.classpath = /somepath/abc.jar:/otherpath/def.jar
run.classpath = ${compile.classpath}:/else/ghi.jar
test.classpath = ${run.classpath}:/junit/junit.jar |
Name it path.properties.
Look for something like this in project.xml in nbproject folder
| Quote: | <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
<!-- Do not use Project Properties customizer when editing this file manually. -->
<name>Your Project</name>
<properties />
...
|
Change the properties tag to
| Quote: | <properties>
<property-file>path.properties</property-file>
</properties> |
Look for source folder settings in project.xml, like | Quote: |
<compilation-unit>
<package-root>src</package-root>
<classpath mode="compile">somethings</classpath>
<built-to>build/src</built-to>
<source-level>1.5</source-level>
</compilation-unit>
|
change the classpath tags to something like
| Quote: | <classpath mode="compile">${compile.classpath}</classpath>
|
|
|
| Back to top |
|
 |
Vadiraj Deshpande Posted via mailing list.
|
Posted: Fri Aug 29, 2008 7:54 am Post subject: Classpath customization for java free-form project |
|
|
Hi Jesse,
I have one more question on this :
How to register predefined libraries such as MySQL db driver such that the freeform project can be transported to other systems ?
The freeform project properties dialog accepts only absolute jar and folder paths. So if say I register MySQL driver jar file on a system programmatically (in which case, the absolute path of the jar including the NetBeans installation path is registered) and transport to another system with another NetBeans installation setup, then would this freeform project be unusable ?
I am trying to register Hibernate Library (which is registered as part of 'hibernatelib' module) to a freeform project.
Thanks,
-Vadiraj.
On Tue, Aug 26, 2008 at 12:15 PM, vachi <setvac-main@yahoo.com (setvac-main@yahoo.com)> wrote:
| Quote: | Thanks! It works!
Here is what I did, just in case someone want to do something like me:
Create a properties file like:
| Quote: | compile.classpath = /somepath/abc.jar:/otherpath/def.jar
|
| Quote: | run.classpath = ${compile.classpath}:/else/ghi.jar
|
| Quote: | test.classpath = ${run.classpath}:/junit/junit.jar
|
Name it path.properties.
Look for something like this in project.xml in nbproject folder
| Quote: | <!-- Do not use Project Properties customizer when editing this file manually. -->
|
| Quote: | <name>Your Project</name>
|
Change the properties tag to
| Quote: | <property-file>path.properties</property-file>
|
Look for source folder settings in project.xml, like
| Quote: | <compilation-unit>
|
| Quote: | <package-root>src</package-root>
|
| Quote: | <classpath mode="compile">somethings</classpath>
|
| Quote: | <built-to>build/src</built-to>
|
| Quote: | <source-level>1.5</source-level>
|
| Quote: | </compilation-unit>
|
change the classpath tags to something like
| Quote: | <classpath mode="compile">${compile.classpath}</classpath>
|
|
|
|
| Back to top |
|
 |
Jesse Glick Posted via mailing list.
|
Posted: Fri Aug 29, 2008 3:40 pm Post subject: Re: Classpath customization for java free-form project |
|
|
Vadiraj Deshpande wrote:
| Quote: | The freeform project properties dialog
|
The Properties dialog is only for basic initial setup. For serious work
you should edit project.xml directly.
| Quote: | I am trying to register Hibernate Library (which is registered as part
of 'hibernatelib' module) to a freeform project.
|
So write
<properties>
<property-file>site.build.properties</>
<property-file>build.properties</>
</>
where
---%<--- build.properties
hibernate.cp=${netbeans.home}/../java2/modules/ext/hibernate/hibernate3.jar
---%<---
and add site.build.properties to .cvsignore or whatever. |
|
| Back to top |
|
 |
Vadiraj Deshpande Posted via mailing list.
|
Posted: Fri Aug 29, 2008 3:47 pm Post subject: Re: Classpath customization for java free-form project |
|
|
Hi Jesse Thanks for the reply. But why two properties file ?
And,
Can I add classpaths directly in the project.xml ?
In project.xml - >
<java-data>
...
<compilation-unit>
<package-root>
..
<classpath mode="compile">/work/home/netbeans6.5beta/java2/modules/ext/hibernate/hibernate3.jar</classpath>
And can I use JavaFreeformProjectGenerator for reading/writing project.xml to do this ?
Thanks,
-Vadiraj
On Fri, Aug 29, 2008 at 9:05 PM, Jesse Glick <jesse.glick@sun.com (jesse.glick@sun.com)> wrote:
| Quote: | Vadiraj Deshpande wrote:
| Quote: | The freeform project properties dialog
|
The Properties dialog is only for basic initial setup. For serious work you should edit project.xml directly.
| Quote: | I am trying to register Hibernate Library (which is registered as part of 'hibernatelib' module) to a freeform project.
|
So write
<properties>
<property-file>site.build.properties</>
<property-file>build.properties</>
</>
where
---%<--- build.properties
hibernate.cp=${netbeans.home}/../java2/modules/ext/hibernate/hibernate3.jar
---%<---
and add site.build.properties to .cvsignore or whatever.
|
|
|
| Back to top |
|
 |
Vadiraj Deshpande Posted via mailing list.
|
Posted: Fri Aug 29, 2008 3:48 pm Post subject: Re: Classpath customization for java free-form project |
|
|
Typo : read JavaProjectGenerator instead of JavaFreeformProjectGenerator
-Vadiraj
On Fri, Aug 29, 2008 at 9:17 PM, Vadiraj Deshpande <vadirajvd@gmail.com (vadirajvd@gmail.com)> wrote:
| Quote: | Hi Jesse Thanks for the reply. But why two properties file ?
And,
Can I add classpaths directly in the project.xml ?
In project.xml - >
<java-data>
...
<compilation-unit>
<package-root>
..
<classpath mode="compile">/work/home/netbeans6.5beta/java2/modules/ext/hibernate/hibernate3.jar</classpath>
And can I use JavaFreeformProjectGenerator for reading/writing project.xml to do this ?
Thanks,
-Vadiraj
On Fri, Aug 29, 2008 at 9:05 PM, Jesse Glick <jesse.glick@sun.com (jesse.glick@sun.com)> wrote:
| Quote: | Vadiraj Deshpande wrote:
| Quote: | The freeform project properties dialog
|
The Properties dialog is only for basic initial setup. For serious work you should edit project.xml directly.
| Quote: | I am trying to register Hibernate Library (which is registered as part of 'hibernatelib' module) to a freeform project.
|
So write
<properties>
<property-file>site.build.properties</>
<property-file>build.properties</>
</>
where
---%<--- build.properties
hibernate.cp=${netbeans.home}/../java2/modules/ext/hibernate/hibernate3.jar
---%<---
and add site.build.properties to .cvsignore or whatever.
|
|
|
|
| Back to top |
|
 |
Jesse Glick Posted via mailing list.
|
Posted: Fri Aug 29, 2008 5:48 pm Post subject: Re: Classpath customization for java free-form project |
|
|
Vadiraj Deshpande wrote:
| Quote: | But why two properties file?
|
site.build.properties you need separate because it would not be in
source control, just an optional place to put overrides. You do not need
to have build.properties, but it is handy because a build.xml can also
load it using <property file="build.properties"/>, letting you share
configuration.
| Quote: | Can I add classpaths directly in the project.xml?
|
Yes.
| Quote: | <classpath mode="compile">/work/home/netbeans6.5beta/java2/modules/ext/hibernate/hibernate3.jar</classpath>
|
That is possible, though of course poor style since then project.xml
cannot be versioned (shared). You can also define properties in the
<properties> section.
Get the Freeform Project Extras module from dev AU which documents all
of this. Anyway dev@openide.netbeans.org is not really the right forum
as this has nothing to do with module development.
| Quote: | Can I use JavaFreeformProjectGenerator for reading/writing
project.xml to do this?
|
No. |
|
| Back to top |
|
 |
ceimoirley
Joined: 14 Sep 2009 Posts: 3
|
Posted: Mon Sep 14, 2009 10:42 am Post subject: |
|
|
Thanks for your reply. That's pretty bad. I will file an RFE (I will also check the sources maybe I can implement it myself).
But is there any way to compare current working copy with revision n? (I know only how to compare it to the head revision).
Also thanks for your kind information. I like your blog very much because of its interesting topics. i'm student and preparing for my exam of testking 1Y0-A09 for attaining the certification. Although it is not hard to get certified but it keeps me busy. I've also attained certification of another course of testking 70-443 which I had passed last three months back. Also I am trying to complete my pending thesis project of testking 1z0-042 which I'm sure will be completed soon. I normally search on topics which you described on your blog these are great and really informative. Thanks for beneficial thread. |
|
| Back to top |
|
 |
sreyaxy
Joined: 12 Jun 2010 Posts: 2
|
Posted: Wed Jun 16, 2010 10:00 am Post subject: |
|
|
How old do turtles have to be to hibernate? It's almost winter and i have some turtles that are like 9 months old. Should they be allowed to hibernate? And what do i do with them?
____________________
market samurai ~ marketsamurai ~ marketsamurai.com |
|
| Back to top |
|
 |
markjay50
Joined: 22 Jul 2010 Posts: 2
|
Posted: Sat Jul 31, 2010 1:11 am Post subject: |
|
|
H...guys..!!!
I am trying to register Hibernate Library (which is registered as part of 'hibernatelib' module) to a freeform project but i don't know...!! |
|
| Back to top |
|
 |
|