1

I'm using the Apache Felix Maven Bundle Plugin to generate the OSGi metadata.

<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>

You can configure which packages are exported or you can use the default, which excludes packages such as *.impl.* and *.internal.*.

Is there a way to generate Javadoc only for the exported packages without having to duplicate this information?

Edit:

My current approach is that I set the excludePackageNames property (a Maven Javadoc Plugin property) manually and thus duplicate this information:

<excludePackageNames>*.internal.*:*.impl.*</excludePackageNames> <!-- used by Javadoc plugin --><!-- TODO: get this from OSGi meta data-->

http://sourceforge.net/p/drombler/drombler-oss-parent/ci/default/tree/pom.xml#l64

9
  • maybe you could run the javadoc with the content of the generated jar? Commented Jul 23, 2012 at 20:15
  • Could you explain this further? The Javadoc information is not included in the class files, AFAIK. Commented Jul 23, 2012 at 20:37
  • 1
    I was thinking of extracting the list of included files in the jar and passing this list to the javadoc binary. I am afraid this is the only way to generate the documentation that sticks to the jar content. I cannot see another way. Commented Jul 23, 2012 at 20:46
  • This is an interesting question. I'd imagine that one could create a maven plugin that read the generated Manifest.MF and fed that as configuration to the javadoc generator, as @ZNK-M suggested. Commented Jul 25, 2012 at 12:43
  • BTW, I thought of another solution yesterday. I was answering a question about ant on so.com. The guy was using the file mapper object. That allows you to transform a file name to another. For Instance convert *.class found in a jar to *.html. You can then pass the result of it to another task. You could generate the whole javadoc and copy only the files that matches the mapper. Commented Jul 25, 2012 at 12:54

2 Answers 2

0

The Apache Maven bundle plugin is based on bndlib, which has its own plugin model. If a maven plugin model has class visibility to other maven plugins then it is easy to get this information. In the instructions in the pom register a plugin:

<instructions>
  <_plugin>com.example.MyPlugin</_plugin>
</instruction>

In this bnd plugin, implement the AnalyzerPlugin interface

boolean analyzeJar(Analyzer analyzer) throws Exception {
   doJavadoc( analyzer.getExportedPackages().keySet() );
}

I am not that familiar with maven plugins, since bnd will do dynamic class loader (yuck), it must be able to see your code.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer, but I'm not sure I'm getting everything. Please see my update for my current approach. I think I have to set the excludePackageNames property with information retrieved from bnd in order to integrate with the Maven Javadoc Plugin. I guess your approach would mean not to use the Maven Javadoc Plugin?
yes, you would have too generate your own javadoc. I guess you could also use the information to set a property that is then used by the javadoc plugin. This answer just provides you with the package names that are actually exported.
0

I guess the best thing would be, if the Maven Bundle Plugin would provide a goal to generate the needed information.

I filed a new issue: https://issues.apache.org/jira/browse/FELIX-4181

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.