使用maven-release-plugin部署组装包

发布于 2024-08-21 01:24:23 字数 1397 浏览 10 评论 0原文

我们使用 Hudson 和 maven-release-plugin 来进行发布构建。现在我有一个项目,其中包含一个 程序集,它将所有需要的组件组合在一起,并且然后将它们打包成具有所需目录结构的 .tar.gz 包。

现在,我尝试获取发布插件,以在发布期间将此包部署到我们的 Maven 存储库:执行目标,但仅部署标准内容(源、javadoc、POM)。

我已经将程序集目标绑定到 Maven 包阶段,并且 .tar.gz 在发布期间构建,但未上传到存储库。有任何提示我在这里做错了什么吗?

这是程序集插件配置:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-4</version>
    <configuration>
      <descriptors>
        <descriptor>src/main/assembly/distribution.xml</descriptor>
      </descriptors>
      <finalName>${pom.artifactId}-${pom.version}</finalName>
      <appendAssemblyId>false</appendAssemblyId>
      <tarLongFileMode>warn</tarLongFileMode>
    </configuration>
    <executions>
        <execution>
            <id>dist-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>assembly</goal>
            </goals>
        </execution>
    </executions>
</plugin>

我运行来构建版本的命令是

mvn release:prepare release:perform release:clean

We use Hudson and the maven-release-plugin to do the release builds. Now I have a project which contains an assembly that puts together all needed components and then packages them into a .tar.gz package with the desired directory structure.

Now I'm trying to get the release-plugin to deploy this package to our Maven repository during the release:perform goal, but only the standard stuff (sources, javadoc, POM) are deployed.

I've already bound the assembly goal to the maven package phase, and the .tar.gz gets build during the release, but not uploaded to the repository. Any hints what I'm doing wrong here ?

Here is the assembly-plugin configuration:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-4</version>
    <configuration>
      <descriptors>
        <descriptor>src/main/assembly/distribution.xml</descriptor>
      </descriptors>
      <finalName>${pom.artifactId}-${pom.version}</finalName>
      <appendAssemblyId>false</appendAssemblyId>
      <tarLongFileMode>warn</tarLongFileMode>
    </configuration>
    <executions>
        <execution>
            <id>dist-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>assembly</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The command I run to build a release is

mvn release:prepare release:perform release:clean

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

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

发布评论

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

评论(2

荭秂 2024-08-28 01:24:23

同时,我找到了两种方法来做我想做的事。

maven-build-helper-plugin 允许向应部署的工件列表添加其他条目:

    <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>build-helper-maven-plugin</artifactId>
         <version>1.3</version>
         <executions>
           <execution>
             <id>attach-distribution</id>
             <phase>package</phase>
             <goals>
               <goal>attach-artifact</goal>
             </goals>
             <configuration>
               <artifacts>
                 <artifact>
                   <file>target/${pom.artifactId}-${pom.version}.tar.gz</file>
                   <type>tar.gz</type>
                 </artifact>
               </artifacts>
             </configuration>
           </execution>
         </executions>
       </plugin>

另一个非常简单,maven-user 邮件列表上的某人指出了这一点。简单地使用 assembly:single 目标而不是 assembly: assembly 。这样,生成的工件就会在部署阶段上传到存储库。

    <execution>
        <id>dist-assembly</id>
        <phase>package</phase>
        <goals>
            <goal>single</goal> <!-- that's all :) -->
        </goals>
    </execution>

Meanwhile, I found 2 ways of doing what I wanted.

The maven-build-helper-plugin allows to add additional entries to the list of artifacts that should be deployed:

    <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>build-helper-maven-plugin</artifactId>
         <version>1.3</version>
         <executions>
           <execution>
             <id>attach-distribution</id>
             <phase>package</phase>
             <goals>
               <goal>attach-artifact</goal>
             </goals>
             <configuration>
               <artifacts>
                 <artifact>
                   <file>target/${pom.artifactId}-${pom.version}.tar.gz</file>
                   <type>tar.gz</type>
                 </artifact>
               </artifacts>
             </configuration>
           </execution>
         </executions>
       </plugin>

The other is as simple as it gets and someone on the maven-user mailinglist pointed this out. Simple use the assembly:single goal instead of asssembly:assembly. This way the generated artifact is uploaded to the repository during the deploy phase.

    <execution>
        <id>dist-assembly</id>
        <phase>package</phase>
        <goals>
            <goal>single</goal> <!-- that's all :) -->
        </goals>
    </execution>
追风人 2024-08-28 01:24:23

部署文件不是发布插件的一部分,而是部署插件的一部分(发布本身不会在任何地方部署内容,但您可以配置在发布期间调用的部署插件)。

通常,部署插件会将所有工件部署到远程存储库,但程序集不是工件; Maven 无法以任何方式使用其存储库中的 .tar.gz 存档,因此首先部署它们是没有意义的。

如果你坚持将无用的文件复制到存储库中,则必须使用 deploy:deploy-file (请参阅文档)手动部署文件并使用执行配置插件以在发布步骤中调用它。但我仍然建议不要这样做。

您可能正在寻找一种自动将程序集上传到某处的方法。我不知道有哪个插件可以做到这一点。

Deploying files is not part of the release plugin but of the deploy plugin (release doesn't deploy stuff anywhere by itself but you can configure the deploy plugin to be called during a release).

Normally, the deploy plugin will deploy all artifacts to the remote repository but assemblies aren't artifacts; Maven can't use .tar.gz archives in its repository in any way, so it doesn't make sense to deploy them in the first place.

If you insist to copy useless files into the repository, you must use deploy:deploy-file (see the docs) to deploy a file manually and configure the plugin with an execution to invoke it during the release step. But I still advise against it.

What you're probably looking for is a way to upload an assembly somewhere automatically. I'm not aware of a plugin that does this.

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