[
https://issues.apache.org/jira/browse/MRRESOURCES-155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17907615#comment-17907615
]
ASF GitHub Bot commented on MRRESOURCES-155:
--------------------------------------------
slawekjaranowski commented on code in PR #79:
URL:
https://github.com/apache/maven-remote-resources-plugin/pull/79#discussion_r1894649205
##########
src/main/java/org/apache/maven/plugin/resources/remote/AbstractProcessRemoteResourcesMojo.java:
##########
@@ -906,46 +932,53 @@ protected void processResourceBundles(ClassLoader
classLoader, VelocityContext c
// Don't overwrite resource that are already being provided.
- File f = new File(outputDirectory, projectResource);
+ File outputFile = new File(outputDirectory, projectResource);
+
+ FileUtils.mkdir(outputFile.getParentFile().getAbsolutePath());
+
+ // resource exists in project resources
+ if (copyResourceIfExists(outputFile, projectResource,
context)) {
+ continue;
+ }
- FileUtils.mkdir(f.getParentFile().getAbsolutePath());
+ if (copyProjectRootIfExists(outputFile, projectResource)) {
+ continue;
+ }
- if (!copyResourceIfExists(f, projectResource, context)) {
- if (doVelocity) {
- try (CachingOutputStream os = new
CachingOutputStream(f)) {
- String bundleEncoding = bundle.getSourceEncoding();
- if (bundleEncoding == null) {
- bundleEncoding = encoding;
- }
- try (Writer writer = new OutputStreamWriter(os,
bundleEncoding)) {
- velocity.mergeTemplate(bundleResource,
bundleEncoding, context, writer);
- }
+ if (doVelocity) {
+ try (CachingOutputStream os = new
CachingOutputStream(outputFile)) {
+ String bundleEncoding = bundle.getSourceEncoding();
+ if (bundleEncoding == null) {
+ bundleEncoding = encoding;
}
- } else {
- URL resUrl = classLoader.getResource(bundleResource);
- if (resUrl != null) {
- FileUtils.copyURLToFile(resUrl, f);
+ try (Writer writer = new OutputStreamWriter(os,
bundleEncoding)) {
+ velocity.mergeTemplate(bundleResource,
bundleEncoding, context, writer);
}
}
+ } else {
+ URL resUrl = classLoader.getResource(bundleResource);
+ if (resUrl != null) {
+ FileUtils.copyURLToFile(resUrl, outputFile);
+ }
+ }
- File appendedResourceFile = new
File(appendedResourcesDirectory, projectResource);
- File appendedVmResourceFile = new
File(appendedResourcesDirectory, projectResource + ".vm");
+ File appendedResourceFile = new
File(appendedResourcesDirectory, projectResource);
+ File appendedVmResourceFile = new
File(appendedResourcesDirectory, projectResource + ".vm");
- if (appendedResourceFile.exists()) {
- getLog().info("Copying appended resource: " +
projectResource);
- try (InputStream in =
Files.newInputStream(appendedResourceFile.toPath());
- OutputStream out = new FileOutputStream(f,
true)) {
- IOUtil.copy(in, out);
- }
+ if (appendedResourceFile.exists()) {
+ getLog().info("Copying appended resource: " +
projectResource);
+ try (InputStream in =
Files.newInputStream(appendedResourceFile.toPath());
+ OutputStream out = new
FileOutputStream(outputFile, true)) {
+ IOUtil.copy(in, out);
+ }
- } else if (appendedVmResourceFile.exists()) {
- getLog().info("Filtering appended resource: " +
projectResource + ".vm");
+ } else if (appendedVmResourceFile.exists()) {
+ getLog().info("Filtering appended resource: " +
projectResource + ".vm");
- try (Reader reader = new
FileReader(appendedVmResourceFile);
- Writer writer = getWriter(bundle, f)) {
- Velocity.init();
- Velocity.evaluate(context, writer,
"remote-resources", reader);
- }
+ try (Reader reader = new
FileReader(appendedVmResourceFile);
Review Comment:
done and fix encoding in other places
> Allow to override bundle resources by project workspace files
> -------------------------------------------------------------
>
> Key: MRRESOURCES-155
> URL: https://issues.apache.org/jira/browse/MRRESOURCES-155
> Project: Maven Remote Resources Plugin
> Issue Type: New Feature
> Reporter: Slawomir Jaranowski
> Assignee: Slawomir Jaranowski
> Priority: Major
> Fix For: 3.3.0
>
>
> Make same named project files take precedence over ones from the remote
> resource bundle.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)