Add jar to doclet classpath using maven-javadoc-plugin

I wrote a document that collects some data and passes it to a reporter. I want this reporter to be replaced. I tried to add a reporter implementation to the doclet class path using the addDependency and / or pluginDependency function. I cannot load the reporter implementation using the Java 6 service loader, and it also does not work to get the class using the doclets class loader or the thread context class loader.

How can I get test.TestReporterImpl in the class path of test-doclet?

In the doclet:

apiReporterServiceLoader = ServiceLoader.load(TestReporter.class); // test.TestReporter apiReporterServiceLoader.iterator().hasNext(); // false Thread.currentThread().getContextClassLoader().loadClass("test.TestReporterImpl"); // ClassNotFoundException getClass().getClassLoader().loadClass("test.TestReporterImpl"); // ClassNotFoundException 

in pom doing doclet

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.10.3</version> <executions> <execution> <id>run-my-doclet</id> <goals> <goal>javadoc</goal> </goals> <phase>generate-resources</phase> </execution> </executions> <dependencies> <dependency> <groupId>test</groupId> <artifactId>test-doclet-test-reporter</artifactId> <version>${project.version}</version> </dependency> </dependencies> <configuration> <doclet>test.TestDoclet</doclet> <docletArtifact> <groupId>test</groupId> <artifactId>test-doclet</artifactId> <version>${project.version}</version> </docletArtifact> <additionalDependencies> <additionalDependency> <groupId>test</groupId> <artifactId>test-doclet-test-reporter</artifactId> <version>${project.version}</version> </additionalDependency> </additionalDependencies> <useStandardDocletOptions>false</useStandardDocletOptions> </configuration> </plugin> 

test report test reporter / SRC / main / resources / META-INF / services / test.TestReporter

 test.TestReporterImpl 
+6
source share
1 answer

You will need to specify the directory that will be included in your class path by adding the following to your POM anywhere in the assembly. This is true for your classes under the meta-inf folder under the resource, in case of errors arising from the default implicit resources folder.

  <project> ... <build> ... <resources> <resource> <directory>[your folder containing the class or to be in the classpath here]</directory> </resource> </resources> ... </build> ... </project> 
+1
source

Source: https://habr.com/ru/post/986925/


All Articles