in src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java [758:814]
protected VelocityContext buildVelocityContext() {
Map<String, Object> contextProperties = new HashMap<>(properties);
if (includeProjectProperties) {
final Properties projectProperties = project.getProperties();
for (String key : projectProperties.stringPropertyNames()) {
contextProperties.put(key, projectProperties.getProperty(key));
}
}
// the following properties are expensive to calculate, so we provide them lazily
VelocityContext context = new VelocityContext(contextProperties) {
@Override
public Object internalGet(String key) {
Object result = super.internalGet(key);
if (result == null && key != null && key.startsWith(KEY_PROJECTS) && containsKey(key)) {
// calculate and put projects* properties
List<MavenProject> projects = getProjects();
put(KEY_PROJECTS, projects);
put(KEY_PROJECTS_ORGS, getProjectsSortedByOrganization(projects));
return super.internalGet(key);
}
return result;
}
};
// to have a consistent getKeys()/containsKey() behaviour, keys must be present from the start
context.put(KEY_PROJECTS, null);
context.put(KEY_PROJECTS_ORGS, null);
// the following properties are cheap to calculate, so we provide them eagerly
String inceptionYear = project.getInceptionYear();
// Reproducible Builds: try to use reproducible output timestamp
String year = MavenArchiver.parseBuildOutputTimestamp(outputTimestamp)
.orElseGet(Instant::now)
.atZone(ZoneId.of("UTC+10"))
.format(DateTimeFormatter.ofPattern("yyyy"));
if (inceptionYear == null || inceptionYear.isEmpty()) {
if (getLog().isDebugEnabled()) {
getLog().debug("inceptionYear not specified, defaulting to " + year);
}
inceptionYear = year;
}
context.put("project", project);
context.put("presentYear", year);
context.put("locator", locator);
if (inceptionYear.equals(year)) {
context.put("projectTimespan", year);
} else {
context.put("projectTimespan", inceptionYear + "-" + year);
}
return context;
}