0

我们在一个 SVN 存储库中有一堆较小的项目。存储库具有以下结构:

/trunk
   /artifactId1
   /artifactId2
   /groupId
      /artifactId3
      /artifactId4
/branches
  ... see above
/tags

所以它看起来有点像一个 Maven 存储库。

现在我希望 Maven 发布插件在标记时创建类似的结构。我将插件配置更改为:

<tagNameFormat>@{project.groupId}/@{project.artifactId}/@{project.version}</tagNameFormat>

maven 发布插件将创建正确的 SVN url:https://repo/tags/groupId/artifactId3/1.0.0

但是,存储库中尚不存在路径结构,因此 SVN“标记”操作失败。

我不想每次将新工件添加到需要标签支持的 SVN 存储库时都创建路径结构。有没有办法配置 maven 在标记之前先创建父结构?还是我需要为执行此操作的 Maven 创建一个插件?

4

3 回答 3

1

As you're finding nested tags and branches are not the path - no tooling is going to play well with them out of the box.

It sounds like ArtifactID1-4 are separate svn projects, which are not built and released together. Perhaps they should each be a project in svn with their own branches tags and trunk folders. You'd avoid the mess you mentioned as well as the mess of nested branches & tags.

于 2013-04-01T21:20:19.460 回答
0

我已经面临这种问题,但我不会给你一个直接的答案来解决你的问题。确实,您尝试做一些不是“专家方式”的事情......

据我了解,您尝试标记:

  • 只有一个工件,将其放入 groupId/artifactID/version
  • 或所有回购(例如所有在主干下)。

标记一个工件

在仅标记 artifact3 的情况下,您是对的。第一次尝试标记时,您无法执行此操作,因为无法在一个命令中创建完整结构(svn 标记确实是副本,并且复制命令不支持允许复制和创建目录的选项,例如“ Linux 上的 mkdir -p"。

但是,但是 Maven 约定(默认行为)是 tags/artifactId-version,您可以创建自己的结构和自己的模板来执行发布(通过您的 IDE 或在 svn 命令行中)。然后,根据需要更改 tagNameFormat (并且您似乎正在这样做):

<project>
  [...]
  <build>
    [...]
    <plugins>
      [...]
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.3.1</version>
        <configuration>
          <tagNameFormat>${groupId}/${artifactId}/@{project.version}</tagNameFormat>
        </configuration>
      </plugin>
      [...]
    </plugins>
    [...]
  </build>
  [...]
</project>

正如 khmarbaise 所说,您还可以使用 tagBase 和 tagFormat 混合修改 tagBase(以覆盖默认行为)。我从未尝试过,但它应该可以工作。请注意,版本使用 @ 而不是 $(在提交期间或之前不得替换,但在标记操作期间稍后使用)。

显然,您必须为要以这种方式标记的每个工件创建合适的结构。但你只需要做一次。

标记所有工件

如果您想一次性标记所有工件,这将更加困难。我不确定这是你想要的,所以我会简短,只提供一些线索:

  • 如果您的组件链接在一起,只需设想构建一个多模块项目(并在其上运行 mvn release),所有模块都嵌套在其中(这是正确的方法)
  • 如果不是,您不必将它们标记在一起;D

如果我误解了你的意图,请不要犹豫,回复我,提供更多信息。

祝你好运 :)

于 2012-06-07T21:38:12.153 回答
0

问题只是因为标签文件夹不包含 groupId 和 artifactid 文件夹。您需要使用发布插件的配置设置tagBase 。这可以在您的超级 pom.xml 中的 pluginManagement 部分中完成。

于 2012-03-14T19:13:46.983 回答