从 jar 文件中删除生成的资源

发布于 2024-10-05 15:47:53 字数 1672 浏览 10 评论 0原文

你好,我正在使用 maven2-xdoclet2-plugin 生成 hibernate 映射

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)

所以我想避免的是在里面包含目录“ generated-resources” jar 文件。

我怎样才能做到这一点?我做了一些谷歌搜索,但运气不佳。

Hello I am using maven2-xdoclet2-plugin to generate the hibernate mappings

The config of xdoclet is something similar to this:

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

When I run

mvn clean generate-resources

It get the following thing:

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

So what I want to avoid is to have the directory "generated-resources" inside the jar file.

How can I do that? I Did a few google searches without too much luck.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖心男生 2024-10-12 15:47:54

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

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

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

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

You get the mapping files packed into the JAR file because the mapping files are generated to the wrong output directory. You configured:

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

So the mapping files will be generated inside the target/classes/ folder which is used to build the output JAR file. Try some other directory like:

<destdir>${project.build.directory}/generated</destdir>
你是我的挚爱i 2024-10-12 15:47:54

我最终从 maven2-xdoclet2-plugin 迁移到 xdoclet-maven-plugin 并且它按预期工作(我在 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>

I finally moved from maven2-xdoclet2-plugin to xdoclet-maven-plugin and it worked as expected ( I was also having some issues with the hibernate mapping generation ).

        <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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文