我有一个图书馆,它通过内联标签使用。其他库打算使用它将示例代码插入到它们的JavaDoc中。
图书馆已经建好了,哈利路亚,从昨天起,它就在Maven Central上了。
我现在第一次将这个库实现到另一个项目中。该项目用java.version 1.5编译其代码。但是taglet库需要1.7。不仅用于运行javadoc.exe,还用于编译可选的"taglet“类。
更新:这些定制类是由每个开发人员创建的--在他们的库中使用taglet库的人。定制器类(这些类完全是可选的--它们仅用于高级特征,您可以避免创建任何类)需要在执行javadoc.exe之前进行编译。
因此,它需要实现以下目标:
mvn compile)mvn compilecodelet?)javadoc.exe (Java1.7)(‘`mvn docs'?)因此,mvn install会按顺序将这三个目标命名为。
我是Maven的新手,希望能就如何做到这一点提供一些建议。到目前为止,我发现的是:
下面是该项目当前的compile目标:
<properties>
<java.version>1.5</java.version>
</properties>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>这个项目的JDK似乎应该升级到1.7,主类被编译为标志设置为1.5,标记定制器被编译,标记设置为1.7。
一些参考资料:
maven-compiler-plugin 概述我如何设置这个额外的compilecodelet目标,并设置整个项目,以便它能够处理这两个JDK版本?所以mvn install (和其他“主”目标)也按适当的顺序把这个新的子目标命名为?
正如我所说的,我是Maven的新手,虽然我已经开始了解一些零碎的东西,但是我还不知道如何把这些东西组合在一起。
谢谢你的帮助。
发布于 2014-07-25 21:46:42
我和其他人一样,对你的问题发表评论,做你要求的事对我来说很冒险,而且容易出错。最好将codelet扩展类放在单独的项目中,使用源代码&目标为1.7构建它们,并在库POM的javadoc插件配置中添加对codelet扩展jar的依赖。
然而,如果这是不可能的,我会尝试这样的东西。这是未经检验的,但应该给你的想法。
假设这个目录结构:
basedir
src
main
java
regularLibCodePackage
codeletExtensionPackage
<properties>
<java.version>1.5</java.version>
<!-- sets encoding for the whole Maven build -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> <!--consider using latest plugin version -->
<configuration>
<!-- applies to all executions unless overridden by an execution -->
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<excludes>
<!-- Not sure exactly what the path should be here, the docs aren't
clear. Maybe it should be an absolute path, e.g.
${project.basedir}/src/main/java/codeletExtensionPackage?
When you figure it out let me know and I'll edit the response. -->
<exclude>codeletExtensionPackage</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>codelet-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.7</source>
<target>1.7</target>
<excludes>
<!-- See note above about what to put here -->
<exclude>regularLibCodePackage</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>您是否需要将1.7类排除在最后的jar之外?换句话说,运行Javadoc插件需要额外的类吗?如果答案是“是”,那么您还需要调整默认的jar插件执行。(如果答案是肯定的,这也是将代码集类放在一个单独的项目中的另一个原因!)
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version> <!--consider using latest plugin version -->
<executions>
<execution>
<id>default-jar</id>
<configuration>
<excludes>
<exclude>codeletExtensionPackage</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>我在编译器和jar插件中使用了排除,还有一个配套的包含块。我让你自己找出工作配置,这样你就可以开始了。
https://stackoverflow.com/questions/24961307
复制相似问题