2012-11-12 2 views
0

maven에서 생성 된 groovydoc의 IDE (IDEA, Eclipse 등)에서 사용할 jar 파일을 생성하는 방법이 있습니까? 나는 현재 여기에 설명 된 받는다는 antrun 플러그인 꽤 큰 그루비 프로젝트에서 groovydoc 발생 해요 : GroovyDoc as Maven Pluginmaven으로 groovydoc에서 jar 파일 생성

내가 수동 아카이브로 출력 파일을 포장하여 사용할 수있는 jar 파일을 얻을 수있었습니다하지만 내가 찾고 있어요 (즉, maven과 함께) 통합 된 방식으로 파일을 저장소에 배치 할 수도 있습니다.

답변

0

게시물의 링크를 따라 간다면 site 단계에서 groovydoc가 생성됩니다.

생성 된 groovydoc으로 jar를 어셈블하려면 maven-assembly-plugin을 사용할 수 있습니다.

maven-assembly-plugin을 사용하기 위해 어셈블리 설명자가 추가되는 src/main/assembly 디렉토리를 만들었습니다.

이 예제는 site 단계에서 groovydoc을 생성하고 groovydoc jar도 패키지화 한 작업 예제입니다. 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> 

<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> 

pom.xml

당신은

mvn site 

당신은 대상 디렉토리에 groovydoc jar 파일이있을 것이다 실행하는 경우.

Default Lifecycle 동안이 값을 만들려면 <phase>site</phase><phase>prepare-package</phase>으로 변경할 수 있습니다. 생성 된 Groovydoc이 작동하도록 디렉토리를 변경해야합니다.