最后回答标题问题:它是(项目,配置文件或设置)中的(客户端设置)
[plugin]?[r|R]epository/[releases|snapshots]/updatePolicy
... 标签。
(目前,maven:3.6.0,但我认为“向后”兼容)可能的值是:
/**
* Never update locally cached data.
*/
public static final String UPDATE_POLICY_NEVER = "never";
/**
* Always update locally cached data.
*/
public static final String UPDATE_POLICY_ALWAYS = "always";
/**
* Update locally cached data once a day.
*/
public static final String UPDATE_POLICY_DAILY = "daily";
/**
* Update locally cached data **every X minutes** as given by "interval:X".
*/
public static final String UPDATE_POLICY_INTERVAL = "interval";
此标签的当前(maven 3.6.0)评估实现如下:
public boolean isUpdatedRequired( RepositorySystemSession session, long lastModified, String policy )
{
boolean checkForUpdates;
if ( policy == null )
{
policy = "";
}
if ( RepositoryPolicy.UPDATE_POLICY_ALWAYS.equals( policy ) )
{
checkForUpdates = true;
}
else if ( RepositoryPolicy.UPDATE_POLICY_DAILY.equals( policy ) )
{
Calendar cal = Calendar.getInstance();
cal.set( Calendar.HOUR_OF_DAY, 0 );
cal.set( Calendar.MINUTE, 0 );
cal.set( Calendar.SECOND, 0 );
cal.set( Calendar.MILLISECOND, 0 );
checkForUpdates = cal.getTimeInMillis() > lastModified;
}
else if ( policy.startsWith( RepositoryPolicy.UPDATE_POLICY_INTERVAL ) )
{
int minutes = getMinutes( policy );
Calendar cal = Calendar.getInstance();
cal.add( Calendar.MINUTE, -minutes );
checkForUpdates = cal.getTimeInMillis() > lastModified;
}
else
{
// assume "never"
checkForUpdates = false;
if ( !RepositoryPolicy.UPDATE_POLICY_NEVER.equals( policy ) )
{
LOGGER.warn( "Unknown repository update policy '{}', assuming '{}'",
policy, RepositoryPolicy.UPDATE_POLICY_NEVER );
}
}
return checkForUpdates;
}
..和:
private int getMinutes( String policy )
{
int minutes;
try
{
String s = policy.substring( RepositoryPolicy.UPDATE_POLICY_INTERVAL.length() + 1 );
minutes = Integer.valueOf( s );
}
catch ( RuntimeException e )
{
minutes = 24 * 60;
LOGGER.warn( "Non-parseable repository update policy '{}', assuming '{}:1440'",
policy, RepositoryPolicy.UPDATE_POLICY_INTERVAL );
}
return minutes;
}
...lastModified
一个/每个底层工件的(本地文件)“修改时间戳”在哪里。
特别是对于interval:x
设置:
- 冒号
:
并不那么严格——任何“非空”字符都可以做到(=
,
, ...)。
- 负值
x < 0
应该屈服于“从不”。
interval:0
我会假设一个“分钟”(0-59秒或以上......)间隔。
- 数字格式异常以
24 * 60
分钟为单位(~“每天”)。
..参见:DefaultUpdatePolicyAnalyzer、DefaultMetadataResolver#resolveMetadata()和RepositoryPolicy