最后回答标题问题:它是(项目,配置文件或设置)中的(客户端设置)
[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;
}
..with:
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