代码之家  ›  专栏  ›  技术社区  ›  Pablojim

如何阻止maven/artifactory使用时间戳保存快照

  •  20
  • Pablojim  · 技术社区  · 15 年前

    由于磁盘空间的考虑,我只想在我的存储库中保留任何快照的一个版本。而不是使用时间戳后缀保留多个版本

    例如,电子商务-2.3-20090806.145007-1.EAR

    我怎么设置这个?这是生成设置还是存储库(人工制品)设置

    谢谢!

    6 回复  |  直到 7 年前
        1
  •  26
  •   Duncan Jones    12 年前

    最简单的 recommended )方法是使用非唯一快照。如果必须使用唯一快照,则可以在artifactory中通过在artifactory.config.xml中的<localrepository>定义上指定<maxuniquesnapshots>属性来执行此操作。

    例如:

    <localRepository>
      <key>snapshots</key>
      <blackedOut>false</blackedOut>
      <handleReleases>false</handleReleases>
      <handleSnapshots>true</handleSnapshots>
      <maxUniqueSnapshots>1</maxUniqueSnapshots>
      <includesPattern>**/*</includesPattern>
      <snapshotVersionBehavior>non-unique</snapshotVersionBehavior>
    </localRepository>
    

    作为参考,你可以在 Nexus (通过用户界面)通过设置 scheduled service ,它允许您指定要保留的最小数量、保留它们的最长时间,以及在部署发布版本时是否删除快照。

        2
  •  11
  •   pringi Syeda Uzma    8 年前

    请注意,Maven 3.0中已删除此功能/功能

    只需在我自己的问题中添加一些内容:

    添加

    <distributionManagement>
        ...
        <snapshotRepository>
            ...
            <uniqueVersion>false</uniqueVersion>
        </snapshotRepository>
        ...
    </distributionManagement>
    

    给我的父母 聚甲醛 也促成了这个问题的解决。

    见:

    http://i-proving.com/space/Jessamyn+Smith/blog/2008-06-16_1

    要更改Artifactory中存储库的唯一设置-以管理员身份登录-并在相关报告屏幕截图上选择编辑:

    http://wiki.jfrog.org/confluence/display/RTF/Understanding+Repositories

        3
  •  4
  •   user188269    15 年前

    人工制品可以清除旧的唯一快照。但是,我们发现,对于跟踪依赖关系或回滚到特定版本而言,独特的快照是不有用的。这样做有更好的选择,更清洁,更可靠。这就是为什么工件默认选择非唯一快照的原因,并且此策略可以 集中地 受控(人工制品独有)。 您可以阅读有关此的更多信息,以及自动清理功能 here .

        4
  •  1
  •   Cathy    13 年前
    <plugin>         
                        <groupId>org.codehaus.mojo</groupId>         
                        <artifactId>build-helper-maven-plugin</artifactId>         
                        <version>1.7</version>         
                        <executions>           
                            <execution>             
                                <id>remove-old-artifacts</id>             
                                <phase>package</phase>             
                                <goals>               
                                    <goal>remove-project-artifact</goal>             
                                </goals>            
                                <configuration>  
                                    <removeAll>true</removeAll><!-- When true, remove all built artifacts including all versions. When false, remove all built artifacts of this project version -->             
                                </configuration>          
                            </execution>         
                        </executions>       
                    </plugin>
    
        5
  •  0
  •   Brian Fox    15 年前

    使用非唯一快照不是一个好方法。相反,您可以使用一个存储库管理器来清理快照,并将其配置为减少磁盘空间。使用时间戳快照可以更容易地跟踪问题,因为您可以很容易地看到实际使用的是哪个版本。

        6
  •  0
  •   jprism    7 年前

    不会在Maven 3工作,正如下面Apache引用的那样

    It's not recommended to use non-unique snapshots since they lead to non-reproducible builds. The main use case for these was to save disk space in the repository, but this is best handled by scheduling a periodic snapshot removal task to keep the number of versions down