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 213683 - ProjectClassPathModifier.addAPI
Summary: ProjectClassPathModifier.addAPI
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.2
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Zezula
Keywords: API
Depends on:
Blocks: 70944 196497
  Show dependency tree
Reported: 2012-06-06 16:14 UTC by Jesse Glick
Modified: 2015-05-01 17:18 UTC (History)
2 users (show)

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2012-06-06 16:14:24 UTC
In various cases a tool working with project sources wishes to add a dependency on a well-known API without needing to specify a particular JAR or Library defining this API. Currently ProjectClassPathModifier does not make this possible - you need to point to a concrete location, which ties the caller too deeply to a particular build/repository system, and leads to hacks such as Maven's CPExtender.checkLibraryForPoms.

Better would be a more abstract variant such as

public static boolean add/removeAPI(String apiClass, FileObject
projectArtifact, String classPathType) throws IOException,

which would leave it up to the PCPMI to decide where such a dependency should come from. (apiClass should I guess be a "binary name", and I guess UOE should be thrown in case this class cannot be found anywhere.) Example impls:

1. java.j2seproject - search global & project libraries for such a class.

2. maven - search repo indices for an artifact defining a class of that name; pick a version matching dependencyManagement, else the newest version. (Currently NBM projects need to use ${netbeans.version}, but if [1] is implemented then dependencyManagement would work transparently here too.)

3. apisupport.ant - search for a ModuleEntry whose getPublicClassNames mentions apiClass.

API clients could include:

1. Form editor (see blocked issues).

2. JUnit/TestNG support, which currently use addLibraries for Ant projects and proprietary calls for Maven projects. (junit.framework.Test, org.junit.Test, org.testng.annotations.Test)

...and probably a lot more (review current PCPM usages).

Comment 1 arittner 2015-05-01 17:18:52 UTC
FYI: The other possible way to add dependencies via NbModuleProvider.addDependencies doesn't works well in maven projects.


The apisupport wizards are using NbModuleProvider.addDependencies to fix dependencies to netbeans core APIs. This works in this cases, but not for other dependencies.