2010-12-02 33 views
0

你好我使用了maven2-xdoclet2-插件生成hibernate的映射從JAR文件中刪除生成的資源

的XDoclet的配置類似於這樣:

<plugin> 
    <groupId>org.codehaus.xdoclet</groupId> 
    <artifactId>maven2-xdoclet2-plugin</artifactId> 
    <version>2.0.7</version> 
    <executions> 
     <execution> 
      <id>xdoclet</id> 
      <phase>generate-sources</phase> 
      <goals> 
      <goal>xdoclet</goal> 
      </goals> 
     </execution> 
    </executions> 
    (... dependencies ...) 
    <configuration> 
     <configs> 
      <config> 
      <components> 
       <component> 
       <classname>org.xdoclet.plugin.hibernate.HibernateMappingPlugin</classname> 
       <params> 
        <version>3.0</version> 
       </params> 
       </component> 
      </components> 
      <params> 
       <destdir>${project.build.directory}/classes</destdir> 
      </params> 
      </config> 
      </configs> 
     </configuration> 

當我運行

mvn clean generate-resources 

它得到以下的事情:

tree -L 2 target/classes/ 
target/classes/ 
|-- com 
| `-- company 
|  `-- (the mappings generated) 
`-- generated-resources 
    `-- xdoclet 
     `-- com 
      `-- company 
       `-- (the mappings generated) 

所以我想避免的是在jar文件中有目錄「generated-resources」。

我該怎麼做?我做了幾次谷歌搜索沒有太多運氣。

回答

0

我終於從maven2的-xdoclet2-插件移到了XDoclet Maven的插件,併發揮預期的(我也有與Hibernate映射產生一些問題)。

 <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>xdoclet-maven-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>xdoclet</id> 
        <phase>generate-resources</phase> 
        <goals> 
         <goal>xdoclet</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <tasks> 
        <hibernatedoclet 
         destdir="${project.build.outputDirectory}" 
         mergeDir="${project.basedir}/src/main/resources/hibernate"> 
         <fileset dir="${project.basedir}/src/main/java" 
          includes="**/domain/**/*.java" /> 
         <hibernate version="3.0" /> 
        </hibernatedoclet> 
       </tasks> 
      </configuration> 
     </plugin> 
0

由於映射文件生成到錯誤的輸出目錄,因此您將映射文件打包到JAR文件中。您配置:

<destdir>${project.build.directory}/classes</destdir> 

所以映射文件將被用於構建輸出JAR文件的文件夾target/classes/內部產生。嘗試一些其他的目錄,如:

<destdir>${project.build.directory}/generated</destdir> 
+0

這並沒有像預期的那樣工作:( – feniix 2010-12-05 19:49:22