【问题标题】:Removing generated resources from a jar file从 jar 文件中删除生成的资源
【发布时间】:2011-05-19 07:39:28
【问题描述】:

您好,我正在使用 maven2-xdoclet2-plugin 生成休眠映射

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 文件中包含“生成的资源”目录。

我该怎么做?我做了一些谷歌搜索,但运气不佳。

【问题讨论】:

    标签: maven-2 build-process xdoclet


    【解决方案1】:

    您将映射文件打包到 JAR 文件中,因为映射文件生成到错误的输出目录。你配置了:

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

    因此映射文件将在target/classes/ 文件夹中生成,该文件夹用于构建输出 JAR 文件。尝试其他一些目录,例如:

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

    【讨论】:

      【解决方案2】:

      我终于从 maven2-xdoclet2-plugin 转移到 xdoclet-maven-plugin 并且它按预期工作(我在休眠映射生成方面也遇到了一些问题)。

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

      【讨论】:

        猜你喜欢
        • 2011-05-06
        • 1970-01-01
        • 1970-01-01
        • 2011-01-22
        • 2019-05-18
        • 1970-01-01
        • 2015-01-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多