有什麼方法可以從maven內生成的groovydoc生成一個用於IDE(如IDEA,Eclipse,...)的jar文件?我目前正在使用這裏描述的maven antrun插件生成一個groovydoc項目:GroovyDoc as Maven Plugin從maven生成groovydoc的jar文件
我能夠通過手動將輸出文件打包到檔案中來獲得可用的jar文件,但我正在尋找集成的方式(也就是使用maven),也允許我將這些文件部署到存儲庫。
有什麼方法可以從maven內生成的groovydoc生成一個用於IDE(如IDEA,Eclipse,...)的jar文件?我目前正在使用這裏描述的maven antrun插件生成一個groovydoc項目:GroovyDoc as Maven Plugin從maven生成groovydoc的jar文件
我能夠通過手動將輸出文件打包到檔案中來獲得可用的jar文件,但我正在尋找集成的方式(也就是使用maven),也允許我將這些文件部署到存儲庫。
如果你按照你的帖子中的鏈接,那麼groovydoc將在site
階段生成。
爲了與生成的groovydoc組裝一個罐子,您可以使用maven-assembly-plugin
。
我創建了一個src/main/assembly
目錄,其中正在添加用於maven-assembly-plugin
的程序集描述符以供使用。
這是一個工作示例,用於在site
階段生成groovydoc,並且還打包一個groovydoc
jar。
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow.Q13343411</groupId>
<artifactId>groovy</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}-${project.version}</name>
<properties>
<gmavenVersion>1.4</gmavenVersion>
<gmavenProviderSelection>2.0</gmavenProviderSelection>
<groovyVersion>2.0.0</groovyVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovyVersion}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>${gmavenVersion}</version>
<configuration>
<providerSelection>${gmavenProviderSelection}</providerSelection>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<source/>
</configuration>
<executions>
<execution>
<goals>
<!-- Only used when doing java/groovy join builds
OR, add the dependency to groovy-all again here in the plugin
-->
<goal>generateStubs</goal>
<goal>compile</goal>
<!-- Only used when doing java/groovy join builds
OR, add the dependency to groovy-all again here in the plugin
-->
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovyVersion}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>groovydoc</id>
<phase>site</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef name="groovydoc"
classname="org.codehaus.groovy.ant.Groovydoc"
classpathref="maven.compile.classpath"
/>
<groovydoc destdir="${project.reporting.outputDirectory}/groovydoc"
sourcepath="${basedir}/src/main/groovy" use="true"
windowtitle="${project.name}"
doctitle="${project.name}"
>
<link packages="java.,org.xml.,javax.,org.xml."
href="http://download.oracle.com/javase/6/docs/api"/>
<link packages="org.apache.tools.ant."
href="http://evgeny-goldin.org/javadoc/ant/api"/>
<link packages="org.junit.,junit.framework."
href="http://kentbeck.github.com/junit/javadoc/latest"/>
<link packages="groovy.,org.codehaus.groovy."
href="http://groovy.codehaus.org/api/"/>
<link packages="org.codehaus.gmaven."
href="http://evgeny-goldin.org/javadoc/gmaven"/>
</groovydoc>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/groovydoc.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>groovydoc</id>
<phase>site</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
src/main/assembly/groovydoc.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>groovydoc</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.reporting.outputDirectory}/groovydoc</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
如果運行
mvn site
你必須在目標目錄中的GroovyDoc的jar文件。
如果您希望在Default Lifecycle期間創建此項,您可以將<phase>site</phase>
更改爲<phase>prepare-package</phase>
。您必須更改生成的groovydoc所在的目錄才能使其生效。