Maven-release-plugin 和 builder-helper 插件

发布于 2024-11-19 16:31:42 字数 1197 浏览 3 评论 0原文


我想我错过了一些东西..
我想发布我的项目。
我在我的 pom 中添加了 maven-release-plugin。另外,除了 java 之外,我还有另一个源代码目录(称为 gen-src)。当我在 Maven 版本中执行第一步(即准备)时,一切都正常,但是当我执行执行时,它不会考虑 gen-src 。

<plugin>
       <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <version>1.7</version>
       <executions>
          <execution>
               <id>add-source</id>
               <phase>generate-sources</phase>

               <goals>
                  <goal>add-source</goal>
               </goals>
               <configuration>
                   <sources>
                        <source>src/main/gen_src</source>
                   </sources>
               </configuration>
          </execution>
       </executions>
    </plugin>

我怀疑这可能与该阶段是生成源这一事实有关。我需要将添加源目标附加到另一个阶段吗?如果是,如何?
我还在此处阅读 - 这是类似的问题,尽管我我没有使用flex..没有答案。 有什么想法吗?
谢谢。

I guess i am missing something..
I want to make a release of my project.
I added maven-release-plugin to my pom. In addition, i have another source code dir aside from java(call it gen-src). When i make the first steps in the maven release (i.e prepare) everything is ok, but when i make perform it does not take the gen-src in account.

<plugin>
       <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <version>1.7</version>
       <executions>
          <execution>
               <id>add-source</id>
               <phase>generate-sources</phase>

               <goals>
                  <goal>add-source</goal>
               </goals>
               <configuration>
                   <sources>
                        <source>src/main/gen_src</source>
                   </sources>
               </configuration>
          </execution>
       </executions>
    </plugin>

I suspect that it may be connected to the fact that the phase is generated-sources. Do i need to attach the add-source goal to another phase? If yes, how?
I also read in here - this is similar problem though i am not using flex..no answer.
Any idea?
Thanks.

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

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

发布评论

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

评论(2

心病无药医 2024-11-26 16:31:42

我过去也遇到过同样的问题,我想我知道发生了什么。 release:perform 阶段检出要发布到“target/checkout”文件夹的标签副本,并分叉一个 Maven 进程来构建此检出。由于您仅在release:perform阶段遇到问题,因此它必须与maven在“target/checkout”文件夹上运行fork进程而不是在“./”文件夹中有关。

我最终解决了这个问题,删除了构建助手,但我不知道你是否可以做同样的事情,所以如果我是你,我会尝试避免配置上的相对路径。您可以这样配置构建帮助程序:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.7</version>
   <executions>
      <execution>
           <id>add-source</id>
           <phase>generate-sources</phase>

           <goals>
              <goal>add-source</goal>
           </goals>
           <configuration>
               <sources>
                    <source>${basedir}/src/main/gen_src</source>
               </sources>
           </configuration>
      </execution>
   </executions>
</plugin>

显式定义 ${basedir} 可以避免此问题,因为 ${basedir} 将解析为分叉路径 (your_workspace/project/target/checkout) 而不是当前路径 (your_workspace/project )。如果这不能解决问题,我相信我们应该针对 build-helper-maven-plugin 提交错误,因为仅在执行阶段不应该有错误。

I had the same problem in the past and I think I know what's happening. The release:perform phase checkouts a copy of the tag to be released to 'target/checkout' folder and fork a maven process to build this checkout. As you have a problem only in the release:perform phase, it must be related to the fact that maven in running a fork process on the 'target/checkout' folder, not in the './' folder.

I ended up fixing this problem removing build helper, but I don't know if you could do the same, so if I were you I would try avoiding relative paths on configurations. You can configure the build-helper like that:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.7</version>
   <executions>
      <execution>
           <id>add-source</id>
           <phase>generate-sources</phase>

           <goals>
              <goal>add-source</goal>
           </goals>
           <configuration>
               <sources>
                    <source>${basedir}/src/main/gen_src</source>
               </sources>
           </configuration>
      </execution>
   </executions>
</plugin>

Defining explicitly the ${basedir} could avoid this problem because ${basedir} will resolve to the fork path (your_workspace/project/target/checkout) instead of the current path (your_workspace/project). If this doesn't fix the problem, I believe we should file a bug against build-helper-maven-plugin because there should be no errors only in the perform phase.

昔梦 2024-11-26 16:31:42

生成的源类不会进入二进制 jar — 在那里您只能找到由常规源和生成源的编译产生的 .class 文件。不过,Maven 发布插件会将额外的源目录包含到源 jar 中。

不需要在任何其他阶段执行“add-source”目标;您可能会发现有用的是让 clean 插件知道它应该包含额外的目录:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
    <filesets>
        <fileset>
            <directory>${basedir}/src/main/gen_src</directory>
            <includes>
                <include>**/*</include>
            </includes>
        </fileset>
    </filesets>
</configuration>
</plugin>

The generated source classes won't make it into the binary jar — there you'll find only .class files resulting from compilation of both regular and generated sources. Maven release plug-in will, though, include the extra source directory into sources jar.

There is no need to execute "add-source" goal in any other phase; what you could find useful is letting the clean plug-in know that it should include the extra directory:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
    <filesets>
        <fileset>
            <directory>${basedir}/src/main/gen_src</directory>
            <includes>
                <include>**/*</include>
            </includes>
        </fileset>
    </filesets>
</configuration>
</plugin>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文