tools maven引入 maven tools.jar

怎么用javadoc和Doclet配合解析自己想要的注释(链接)。既然是一个工具,自然就要生成可执行的jar包。这貌似是一个很合理的要求,然后坑就来了。
我上篇说的是直接复制的tool.jar到lib包下面,添加进资源包就可以了,但是maven项目肯定不能这样做的,这样不规范。我在网上去搜索了tools.jar的依赖教程。
<dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.8</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
  </dependency>
常规操作,pom.xml的

 

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.popcorn.gmtool.GMWrite</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
   </build>

 

posted @ 2024-06-08 19:57  atom_lxh  阅读(6)  评论(0编辑  收藏  举报