Skip to content
Open
Show file tree
Hide file tree
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 @@ -80,7 +80,6 @@
import org.apache.maven.shared.filtering.MavenFileFilterRequest;
import org.apache.maven.shared.filtering.MavenFilteringException;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
Expand Down Expand Up @@ -980,8 +979,7 @@ protected void processResourceBundles(ClassLoader classLoader, VelocityContext c
try (CachingOutputStream os = new CachingOutputStream(outputFile);
Reader reader = getReader(bundle.getSourceEncoding(), appendedVmResourceFile);
Writer writer = getWriter(bundle.getSourceEncoding(), os)) {
Velocity.init();
Velocity.evaluate(context, writer, "remote-resources", reader);
velocity.evaluate(context, writer, "remote-resources", reader);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,33 @@ public void testFilteredBundles() throws Exception {
assertTrue(data.contains("projectsSortedByOrganization: {"));
}

public void testFilteredAppendedResource() throws Exception {
final MavenProjectResourcesStub project = createTestProject("default-appended-filtered-resource");
final ProcessRemoteResourcesMojo mojo =
lookupProcessMojoWithSettings(project, new String[] {"test:test:1.1"});

setupDefaultProject(project);

String path = pathOf(new DefaultArtifact(
"test", "test", VersionRange.createFromVersion("1.1"), null, "jar", "", new DefaultArtifactHandler()));
File file = new File(path);
file.getParentFile().mkdirs();
buildResourceBundle("default-appended-filtered-resource-create", null, new String[] {"FILTER.txt.vm"}, file);

File appendedResourcesDirectory = new File(project.getBasedir(), "src/main/appended-resources");
appendedResourcesDirectory.mkdirs();
FileUtils.fileWrite(
new File(appendedResourcesDirectory, "FILTER.txt.vm").getAbsolutePath(),
"appended: $project.name");
Comment on lines +268 to +274
setVariableValueToObject(mojo, "appendedResourcesDirectory", appendedResourcesDirectory);

mojo.execute();

file = (File) getVariableValueFromObject(mojo, "outputDirectory");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't reuse local variables for different things

String data = FileUtils.fileRead(new File(file, "FILTER.txt"));
assertTrue(data.contains("appended: Test Project default-appended-filtered-resource"));
Comment on lines +280 to +281
}

public void testFilteredBundlesWithProjectProperties() throws Exception {
final MavenProjectResourcesStub project = createTestProject("default-filterbundles-two");
final ProcessRemoteResourcesMojo mojo =
Expand Down
Loading