【问题标题】:Backup folders in Jenkins maven repositoryJenkins Maven 存储库中的备份文件夹
【发布时间】:2015-12-29 13:18:15
【问题描述】:

我在 windows 系统上使用带有 gradle build 的 Jenkins。 詹金斯在内部使用 maven。我的文件夹结构很糟糕 C:\users\.m2\repository\\ 在 modulename 文件夹中,我有多个文件夹,其版本如下 1.0.1 1.0.2 ... 1.0.50。 谁能告诉我为什么我们每天都创建这些文件夹。 丢弃或减少文件夹是个好主意吗?如果是,我们如何实现这一点。

【问题讨论】:

    标签: maven jenkins gradle


    【解决方案1】:

    Maven 根据您所有项目 (pom.xml) 中的声明解析依赖项的版本。

    如果项目 A 有:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>
    

    项目 B 有:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8</version>
    </dependency>
    

    然后您将在 .m2 目录中同时拥有 4.8 和 4.12 版本。

    建议您创建一个 BOM(物料清单),而不是先删除“旧”版本。

    它就像一个技术模块,您可以在其中修复所有依赖项和插件版本。然后你必须在你的 Maven 项目中使用它。之后,您可以删除 .m2 中太旧的 jar。

    BOM 导入示例:

    <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>xxx</groupId>
      <artifactId>xyz</artifactId>
      <packaging>jar</packaging>
      <name>My project</name>
      <version>1.0</version>
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>maven</groupId>
            <artifactId>X</artifactId>
            <version>1.0</version>
            <type>pom</type>
           <scope>import</scope>
          </dependency>
          </dependencies>
      </dependencyManagement>
    </project>
    

    【讨论】:

      猜你喜欢
      • 2021-10-16
      • 2012-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-12
      • 1970-01-01
      • 1970-01-01
      • 2021-06-14
      相关资源
      最近更新 更多