This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 42631 - Provide a way to modify j2seproject classpath programmatically
Summary: Provide a way to modify j2seproject classpath programmatically
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 4.x
Hardware: All All
: P1 blocker (vote)
Assignee: Tomas Zezula
URL:
Keywords: API
Depends on:
Blocks: 39581
  Show dependency tree
 
Reported: 2004-04-30 08:18 UTC by Tomas Pavek
Modified: 2007-09-26 09:14 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Pavek 2004-04-30 08:18:56 UTC
There is a requirement for form module to
automatically:

(1) Add a JAR to project classpath
(2) Add a library to project classpath
(3) Add a project (i.e. project output jar) to
project classpath

when the user adds a bean (from a JAR, library, or
project) to the form. For more UI details see
http://form.netbeans.org/proposals/BuildSysIntegration_user.html#ui_spec,
paragraph 3. The use cases were also discussed in
issue 39581.

To be able to implement this I need some API
(friend API for form module only?) to modify the
project's classpath by adding new entries as
specified above. The API can be quite simple, e.g.
as suggested by Jesse in issue 39581 using
ReferenceHelper; it's just important all three use
cases are supported. Thanks
Comment 1 Tomas Zezula 2004-05-06 15:27:17 UTC
I am going to implement this friend API.
There are 2 possible solutions:
1) Add ReferenceHelper to the J2SEProject lookup, quite dangerous
2) Create class with static methods allowing the form to add a
jar/library/project output into a ClassPath in the j2seproject module
and let the form depend on the j2seproject.
Comment 2 Jesse Glick 2004-05-06 18:46:56 UTC
Do *not* make form depend on j2seproject. If necessary, create an
(eager) submodule bridge between the two.

Or could add such an interface into the java/project module and add it
to lookup of J2SEProject. If we decide later we don't like the
interface, we can just deprecate it and remove it from the project's
lookup.
Comment 3 Tomas Zezula 2004-05-12 17:09:32 UTC
Checking in j2seproject/build.xml;
/cvs/java/j2seproject/build.xml,v  <--  build.xml
new revision: 1.3; previous revision: 1.2
done
Checking in j2seproject/manifest.mf;
/cvs/java/j2seproject/manifest.mf,v  <--  manifest.mf
new revision: 1.3; previous revision: 1.2
done
Processing log script arguments...
More commits to come...
Checking in
j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java;
/cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java,v
 <--  J2SEProject.java
new revision: 1.19; previous revision: 1.18
done
Processing log script arguments...
More commits to come...
RCS file:
/cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/classpath/J2SEProjectClassPathExtender.java,v
done
Checking in
j2seproject/src/org/netbeans/modules/java/j2seproject/classpath/J2SEProjectClassPathExtender.java;
/cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/classpath/J2SEProjectClassPathExtender.java,v
 <--  J2SEProjectClassPathExtender.java
initial revision: 1.1
done
Processing log script arguments...
More commits to come...
Checking in
j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java;
/cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java,v
 <--  J2SEProjectProperties.java
new revision: 1.11; previous revision: 1.10
done
Checking in
j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/VisualClassPathItem.java;
/cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/VisualClassPathItem.java,v
 <--  VisualClassPathItem.java
new revision: 1.4; previous revision: 1.3
done
Checking in
j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/VisualClasspathSupport.java;
/cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/VisualClasspathSupport.java,v
 <--  VisualClasspathSupport.java
new revision: 1.7; previous revision: 1.6
done
Processing log script arguments...
More commits to come...
Checking in project/build.xml;
/cvs/java/project/build.xml,v  <--  build.xml
new revision: 1.3; previous revision: 1.2
done
Checking in project/manifest.mf;
/cvs/java/project/manifest.mf,v  <--  manifest.mf
new revision: 1.5; previous revision: 1.4
done
RCS file: /cvs/java/project/spec-ver.properties,v
done
Checking in project/spec-ver.properties;
/cvs/java/project/spec-ver.properties,v  <--  spec-ver.properties
initial revision: 1.1
done
Processing log script arguments...
Mailing the commit message to cvs@java.netbeans.org (from
tzezula@netbeans.org)
RCS file:
/cvs/java/project/src/org/netbeans/modules/java/project/ProjectClassPathExtender.java,v
done
Checking in
project/src/org/netbeans/modules/java/project/ProjectClassPathExtender.java;
/cvs/java/project/src/org/netbeans/modules/java/project/ProjectClassPathExtender.java,v
 <--  ProjectClassPathExtender.java
initial revision: 1.1
done

Form module must declare implementation dependency on java/project.
J2SEProject has implementation of ProjectClassPathExtender in its
lookup. Form should use the addXXX methods.
Comment 4 Tomas Pavek 2004-05-14 11:33:24 UTC
I've just tried it and it works. Thans!

Just when adding a project output jar (i.e. AntArtifact), I see an
exception printed to console (only informational - the classpath is
modified).

java.lang.IllegalArgumentException: missing or extra data: [reference:
null]
 at
org.netbeans.spi.project.support.ant.ReferenceHelper$RawReference.create(ReferenceHelper.java:852)
 at
org.netbeans.spi.project.support.ant.ReferenceHelper.addRawReference(ReferenceHelper.java:299)
 at
org.netbeans.spi.project.support.ant.ReferenceHelper.access$300(ReferenceHelper.java:69)
[catch] at
org.netbeans.spi.project.support.ant.ReferenceHelper$1.run(ReferenceHelper.java:200)
 at org.openide.util.Mutex.writeAccess(Mutex.java:262)
 at
org.netbeans.spi.project.support.ant.ReferenceHelper.addReference(ReferenceHelper.java:180)
 at
org.netbeans.spi.project.support.ant.ReferenceHelper.createForeignFileReference(ReferenceHelper.java:711)
 at
org.netbeans.modules.java.j2seproject.ui.customizer.J2SEProjectProperties$PathParser.encode(J2SEProjectProperties.java:729)
 at
org.netbeans.modules.java.j2seproject.classpath.J2SEProjectClassPathExtender$3.run(J2SEProjectClassPathExtender.java:137)
 at org.openide.util.Mutex.writeAccess(Mutex.java:298)
 at
org.netbeans.modules.java.j2seproject.classpath.J2SEProjectClassPathExtender.addAntArtifact(J2SEProjectClassPathExtender.java:127)
 at
org.netbeans.modules.form.MetaComponentCreator.prepareClass(MetaComponentCreator.java:1103)
.. snip ...
Comment 5 David Konecny 2004-05-14 14:07:50 UTC
Re. exception: it is caused by my yesterday's incompatible change
(issue  42903). You need to recreate your project dependency on other
project.
Comment 6 Tomas Pavek 2004-05-14 15:06:32 UTC
> You need to recreate your project dependency on other project.
Sorry - but what does this mean? How am I supposed to do it?
Comment 7 Jesse Glick 2004-05-14 21:14:35 UTC
Shut down, delete the references section from your project.xml and
relevant properties from project.properties or private.properties, and
try again.