diff --git a/java.api.common/manifest.mf b/java.api.common/manifest.mf --- a/java.api.common/manifest.mf +++ b/java.api.common/manifest.mf @@ -1,4 +1,4 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.java.api.common/0 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.2 +OpenIDE-Module-Specification-Version: 1.3 diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/queries/CompiledSourceForBinaryQueryImpl.java b/java.api.common/src/org/netbeans/modules/java/api/common/queries/CompiledSourceForBinaryQueryImpl.java --- a/java.api.common/src/org/netbeans/modules/java/api/common/queries/CompiledSourceForBinaryQueryImpl.java +++ b/java.api.common/src/org/netbeans/modules/java/api/common/queries/CompiledSourceForBinaryQueryImpl.java @@ -69,18 +69,24 @@ private final SourceRoots sourceRoots; private final SourceRoots testRoots; private final Map cache = new HashMap(); + private final String binaryProperties[]; + private final String testBinaryProperties[]; public CompiledSourceForBinaryQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots srcRoots, - SourceRoots testRoots) { + SourceRoots testRoots, String binaryProperties[], String testBinaryProperties[]) { assert helper != null; assert evaluator != null; assert srcRoots != null; assert testRoots != null; + assert binaryProperties != null && binaryProperties.length > 0; + assert testBinaryProperties != null && testBinaryProperties.length > 0; this.helper = helper; this.evaluator = evaluator; this.sourceRoots = srcRoots; this.testRoots = testRoots; + this.binaryProperties = binaryProperties; + this.testBinaryProperties = testBinaryProperties; } public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot) { @@ -93,12 +99,19 @@ return res; } SourceRoots src = null; - if (hasSources(binaryRoot, "build.classes.dir")) { //NOI18N - src = sourceRoots; - } else if (hasSources(binaryRoot, "dist.jar")) { //NOI18N - src = sourceRoots; - } else if (hasSources(binaryRoot, "build.test.classes.dir")) { //NOI18N - src = testRoots; + for (String property : binaryProperties) { + if (hasSources(binaryRoot, property)) { + src = sourceRoots; + break; + } + } + if (src == null) { + for (String property : testBinaryProperties) { + if (hasSources(binaryRoot, property)) { + src = testRoots; + break; + } + } } if (src == null) { return null; diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/queries/JavadocForBinaryQueryImpl.java b/java.api.common/src/org/netbeans/modules/java/api/common/queries/JavadocForBinaryQueryImpl.java --- a/java.api.common/src/org/netbeans/modules/java/api/common/queries/JavadocForBinaryQueryImpl.java +++ b/java.api.common/src/org/netbeans/modules/java/api/common/queries/JavadocForBinaryQueryImpl.java @@ -65,13 +65,16 @@ private final AntProjectHelper helper; private final PropertyEvaluator evaluator; + private final String binaryProperties[]; - public JavadocForBinaryQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator) { + public JavadocForBinaryQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator, String binaryProperties[]) { assert helper != null; assert evaluator != null; + assert binaryProperties != null && binaryProperties.length > 0; this.helper = helper; this.evaluator = evaluator; + this.binaryProperties = binaryProperties; } public JavadocForBinaryQuery.Result findJavadoc(final URL binaryRoot) { @@ -142,8 +145,10 @@ } } } - if (isRootOwner(binaryRoot, "build.classes.dir") || isRootOwner(binaryRoot, "dist.jar")) { //NOI18N - return new Result(); + for (String property : binaryProperties) { + if (isRootOwner(binaryRoot, property)) { + return new Result(); + } } return null; } diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java b/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java --- a/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java +++ b/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java @@ -73,12 +73,30 @@ */ public static SourceForBinaryQueryImplementation createCompiledSourceForBinaryQuery(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots srcRoots, SourceRoots testRoots) { + return createCompiledSourceForBinaryQuery(helper, + evaluator, srcRoots, testRoots, new String[]{"build.classes.dir", "dist.jar"}, new String[]{"build.test.classes.dir"}); + } + + /** + * Create a new query to provide information about where Java sources + * corresponding to binaries (classfiles) can be found. + * @param helper {@link AntProjectHelper} used for resolving files, e.g. output directory. + * @param evaluator {@link PropertyEvaluator} used for obtaining project properties. + * @param srcRoots a list of source roots. + * @param testRoots a list of test roots. + * @param binaryProperties list of property names of binary artifacts produced by this project, e.g. dist.jar + * @return {@link SourceForBinaryQueryImplementation} to provide information about where Java sources can be found. + * @see SourceForBinaryQueryImplementation + */ + public static SourceForBinaryQueryImplementation createCompiledSourceForBinaryQuery(AntProjectHelper helper, + PropertyEvaluator evaluator, SourceRoots srcRoots, SourceRoots testRoots, String binaryProperties[], String testBinaryProperties[]) { Parameters.notNull("helper", helper); // NOI18N Parameters.notNull("evaluator", evaluator); // NOI18N Parameters.notNull("srcRoots", srcRoots); // NOI18N Parameters.notNull("testRoots", testRoots); // NOI18N + Parameters.notNull("binaryProperties", binaryProperties); // NOI18N - return new CompiledSourceForBinaryQueryImpl(helper, evaluator, srcRoots, testRoots); + return new CompiledSourceForBinaryQueryImpl(helper, evaluator, srcRoots, testRoots, binaryProperties, testBinaryProperties); } /** @@ -104,10 +122,24 @@ */ public static JavadocForBinaryQueryImplementation createJavadocForBinaryQuery(AntProjectHelper helper, PropertyEvaluator evaluator) { + + return createJavadocForBinaryQuery(helper, evaluator, new String[]{"build.classes.dir", "dist.jar"}); + } + + /** + * Create a new query to find Javadoc. The returned query listens on changes of the Javadoc directory. + * @param helper {@link AntProjectHelper} used for resolving files, e.g. output directory. + * @param evaluator {@link PropertyEvaluator} used for obtaining the Javadoc root. + * @param binaryProperties list of property names of binary artifacts produced by this project, e.g. dist.jar + * @return a {@link JavadocForBinaryQueryImplementation} to find Javadoc. + */ + public static JavadocForBinaryQueryImplementation createJavadocForBinaryQuery(AntProjectHelper helper, + PropertyEvaluator evaluator, String binaryProperties[]) { Parameters.notNull("helper", helper); // NOI18N Parameters.notNull("evaluator", evaluator); // NOI18N + Parameters.notNull("binaryProperties", binaryProperties); // NOI18N - return new JavadocForBinaryQueryImpl(helper, evaluator); + return new JavadocForBinaryQueryImpl(helper, evaluator, binaryProperties); } /** diff --git a/web.project/nbproject/project.xml b/web.project/nbproject/project.xml --- a/web.project/nbproject/project.xml +++ b/web.project/nbproject/project.xml @@ -226,7 +226,7 @@ 0-1 - 1.1 + 1.3 diff --git a/web.project/src/org/netbeans/modules/web/project/WebProject.java b/web.project/src/org/netbeans/modules/web/project/WebProject.java --- a/web.project/src/org/netbeans/modules/web/project/WebProject.java +++ b/web.project/src/org/netbeans/modules/web/project/WebProject.java @@ -439,8 +439,9 @@ new WebLogicalViewProvider(this, this.updateHelper, evaluator (), refHelper), new CustomizerProviderImpl(this, this.updateHelper, evaluator(), refHelper), new ClassPathProviderMerger(cpProvider), - QuerySupport.createCompiledSourceForBinaryQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), - QuerySupport.createJavadocForBinaryQuery(helper, evaluator()), + QuerySupport.createCompiledSourceForBinaryQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots(), + new String[]{"build.classes.dir", "dist.war"}, new String[]{"build.test.classes.dir"}), + QuerySupport.createJavadocForBinaryQuery(helper, evaluator(), new String[]{"build.classes.dir", "dist.war"}), new AntArtifactProviderImpl(), new ProjectXmlSavedHookImpl(), UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()),