I wrote custom Doclet implementation and I run it with Maven javadoc:
<build>
<resources>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<filtering>false</filtering>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<optimize>true</optimize>
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<doclet>custom.doc.CustomDoclet</doclet>
<docletArtifact>
<groupId>custom.doc</groupId>
<artifactId>custom-doc</artifactId>
<version>1.0.0-SNAPSHOT</version>
</docletArtifact>
<useStandardDocletOptions>false</useStandardDocletOptions>
<destDir>custom-doc</destDir>
</configuration>
</plugin>
</plugins>
</build>
In customDoclet class I have following lines:
public class CustomDoclet extends Doclet {
public static boolean start(RootDoc root) {
(1) System.out.println(Thread.currentThread().getContextClassLoader().getResource(".")); // returns null
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.init();
(2) Template template = velocityEngine.getTemplate("template/html_template.vm"); // no such file exception thrown
return true;
}
}
(1) line returns null, and (2) throws execption during javadoc phase.
How can I use resource file?
In jar with CustomDoclet there is file 'template/hmtl_template.vm' in the root.