Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRRESOURCES-151] Deprecate includeProjectProperties parameter #71

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,17 @@ public abstract class AbstractProcessRemoteResourcesMojo extends AbstractMojo {
* javadoc for MavenProject</a> for information about the properties on the MavenProject.
*/
@Parameter
protected Map<String, Object> properties = new HashMap<>();
protected Map<String, String> properties = new HashMap<>();

/**
* Whether to include properties defined in the project when filtering resources.
*
* @deprecated as Maven Project is available in Velocity context we can simply use
* <code>$project.properties.propertyName</code>
*
* @since 1.2
*/
@Deprecated
@Parameter(defaultValue = "false")
protected boolean includeProjectProperties = false;

Expand Down Expand Up @@ -419,13 +423,6 @@ public void execute() throws MojoExecutionException {

configureLocator();

if (includeProjectProperties) {
final Properties projectProperties = project.getProperties();
for (Object key : projectProperties.keySet()) {
properties.put(key.toString(), projectProperties.get(key).toString());
}
}

ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
try {
validate();
Expand All @@ -442,7 +439,7 @@ public void execute() throws MojoExecutionException {
velocity.setProperty("resource.loader.classpath.class", ClasspathResourceLoader.class.getName());
velocity.init();

VelocityContext context = buildVelocityContext(properties);
VelocityContext context = buildVelocityContext();

processResourceBundles(classLoader, context);

Expand Down Expand Up @@ -745,9 +742,19 @@ protected void validate() throws MojoExecutionException {
private static final String KEY_PROJECTS = "projects";
private static final String KEY_PROJECTS_ORGS = "projectsSortedByOrganization";

protected VelocityContext buildVelocityContext(Map<String, Object> properties) {
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(properties) {
VelocityContext context = new VelocityContext(contextProperties) {
@Override
public Object internalGet(String key) {
Object result = super.internalGet(key);
Expand Down
Loading