简体   繁体   中英

How can I get the Javadoc class descriptions at compile time?

I'm trying to build up some documentation for my Wicket Web Application. I have created a page to grab all of my mounted pages and display them in /sitemap.xml. In the vein of documentation I've added a new tag to the file <siteMap:Description> now I want to fill that description with the javadoc entry that describes the class file.

I know there is know direct way to access them at runtime. So Instead I'm hoping to copy them at compile time into a List where they will then be accessible from runtime. How would I do that?

I'm using Maven for my build.

EDIT
I should probably Also mention that I do have an AntTask Already defined as part of my build process to save the compile Dates/times to a property file.
It seems to me an Task to scan my Class and then put the information into a file is probably the way to go. Problem is I'm not sure how to proceed.

My Ant-Task is defined like in my pom.xml so:

  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <dependencies>
       <dependency>
         <groupId>ant</groupId>
         <artifactId>ant-nodeps</artifactId>
         <version>1.6.5</version>
       </dependency>
     </dependencies>
    <executions>
       <execution>
         <id>set-build-time</id>
         <phase>process-sources</phase>
         <configuration>
           <tasks>
             <tstamp>
               <format property="build.timestamp" pattern="yyyy/MM/dd HH:mm:ss"/>
               <format property="build.time" pattern="HH:mm:ss" />
               <format property="build.date" pattern="MM/dd/yyyy" />
               <format property="build.year" pattern="yyyy"/>
             </tstamp>
             <replaceregexp byline="true">
               <regexp pattern="copyYear\=.*" />
               <!--suppress MavenModelInspection -->
               <substitution expression="copyYear=${build.year}" />
               <fileset dir="src/main/java/" includes="**/*.properties" />
             </replaceregexp>
             <replaceregexp byline="true">
               <regexp pattern="buildTime\=.*" />
               <!--suppress MavenModelInspection -->
               <substitution expression="buildTime=${build.date} ${build.time}" />
               <fileset dir="src/main/java/" includes="**/*.properties" />
             </replaceregexp>
           </tasks>
         </configuration>
         <goals>
           <goal>run</goal>
         </goals>
       </execution>
     </executions>
   </plugin>

After doing more research I determined I was barking up the wrong tree.

I since I was trying to get Javadoc comments A Doclet was the better answer. So I implemented a custom doclet and wired it up to run automatically as described in the follow up question and answer below.
How can I compile and run my Custom Doclet class in my project?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM