Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 213683 - ProjectClassPathModifier.addAPI
ProjectClassPathModifier.addAPI
Status: NEW
Product: java
Classification: Unclassified
Component: Project
7.2
All All
: P3 (vote)
: TBD
Assigned To: Tomas Zezula
issues@java
: API
Depends on:
Blocks: 70944 196497
  Show dependency treegraph
 
Reported: 2012-06-06 16:14 UTC by Jesse Glick
Modified: 2015-05-01 17:18 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

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,
UnsupportedOperationException;

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).


[1] http://wiki.netbeans.org/MavenNBM4#Fix_repository_generation_and_usage
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.

See http://forums.netbeans.org/viewtopic.php?t=63367

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


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo