Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hint to m2e (Maven plugin for eclipse) to attach external javadoc website to artifact?

I need to use artifact X which does not have neither source nor javadoc artifacts available. I know, however, an external web server where the javadoc for X has been publicized.

In "plain" Eclipse I can attach an URL as the Javadoc Location for a jar in the build path, and then Shift-F2 opens a browser to that URL.

I would like to have m2e do the same automatically for artifact X without changing the artifacts from Maven Central.

Sample pom.xml showing this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>foo</groupId>
    <artifactId>m2e-javadoc</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>ASCII</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>net.sf.jt400</groupId>
            <artifactId>jt400-full</artifactId>
            <version>5.0</version>
        </dependency>
    </dependencies>

</project>

How do I hint this?


EDIT: Question has been asked on m2e mailing list at http://dev.eclipse.org/mhonarc/lists/m2e-users/msg02386.html


EDIT: After some experiments installing missing artifacts in local repository and giving up on having the project do a Maven release, I repackaged the latest version (7.10) to Maven Central.

like image 426
Thorbjørn Ravn Andersen Avatar asked Mar 14 '12 09:03

Thorbjørn Ravn Andersen


2 Answers

Unfortunately it won't work if the creator didn't create the appropriate artifacts (-sources and -javadoc) for the particular artifact. But you should be able to manually add the javadoc for an particular artifact. I would suggest to create a separate package (artifact-javadoc) and deploy it to your repository manager than it should work automaticially.

like image 123
khmarbaise Avatar answered Nov 15 '22 12:11

khmarbaise


You can use the Maven Javadoc Plugin for this scenario by augmenting your POM:

You could add cross reference links to external projects using the parameters. For instance:

<project>
  ...
  <reporting> (or <build>)
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.8.1</version>
        <configuration>
          <links>
            <link>http://commons.apache.org/dbcp/apidocs/</link>
            <link>http://commons.apache.org/fileupload/apidocs/</link>
          </links>
            ...
        </configuration>
      </plugin>
    </plugins>
  </reporting> (or </build>)
  ...
</project>

Important Note: according the Javadoc specifications, all given links should have a fetchable /package-list file.

This strategy can be further augmented by using the <offlineLinks/> parameter and the aggregate goal to consolidate your documentation into the same documentation tree as desired.

The documentation for Maven Javadoc Plugin provides additional scenarios and examples involving alternative Javadoc facilities, should you wish to pursue those as well.

like image 44
MrGomez Avatar answered Nov 15 '22 12:11

MrGomez