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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]