4

I have a multi module project with the following structure:

-parent
   -module1
   -module2
   -src
      -main
         -javadoc
             -stylesheet.css
   -pom.xml

I want to configure the javadoc plugin in the parent POM. But, I need to specify the path to the stylesheet.css file. So, I use the value ${basedir}\src\main\javadoc\stylesheet.css. But, when I look at the effective POM for the child modules, the ${basedir} is replaced by the absolute path of the child module base directory, but there is no src/main/javadoc/stylesheet.css file there. Copying the stylesheet.css file in the child modules is not a solution, I think.

Thanks

manash
  • 6,985
  • 12
  • 65
  • 125

2 Answers2

4

${basedir} (short for ${project.basedir}) is a directory where project's pom.xml file resides. Therefore, for child modules this property is going to contain paths to module1 and module2 directories correspondingly.

If you want to configure javadoc plugin in the parent pom.xml so it would be effective for child modules, you should use ../src/main/javadoc/stylesheet.css.

Andrew Logvinov
  • 21,181
  • 6
  • 52
  • 54
  • Ok for the child modules, they will locate the file in the parent src/main/javadoc directory. But what about the parent project? It would try to locate the file out of the parent directory? How can it work? – manash Feb 23 '12 at 09:26
  • @MickaelMarrache Parent project is usually a pom-packaging project, e.g. it doesn't contain any source files. If it's not your case, then you'll have to configure javadoc plugin both for parent project and for every child project. – Andrew Logvinov Feb 23 '12 at 09:33
  • What in the case I have a multi level hierarchy of projects? For example, Parent-->Module1-->Module1-2. – manash Feb 23 '12 at 13:32
  • 2
    See comments to [this](http://stackoverflow.com/questions/3084629/finding-the-root-directory-of-a-multi-module-maven-reactor-project) question. Maybe you'll find a suitable solution among the offered there. – Andrew Logvinov Feb 23 '12 at 13:48
2

The Maven Javadoc plugin allows you to include stylesheet resources that are stored in a JAR file, as described here: http://maven.apache.org/plugins/maven-javadoc-plugin/examples/stylesheet-configuration.html

This would allow you to create a resource-only JAR, add it to the dependencies list for your javadoc plugin, and load the resources from there. This would eliminate the need to either duplicate stylesheet files, or reference a shared set deployed in your parent POM.

Sean Kleinjung
  • 3,115
  • 2
  • 21
  • 15