You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2023/08/18 14:13:55 UTC
[jackrabbit-filevault-package-maven-plugin] 01/01: JCRVLT-714 Support multiple source directories
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch feature/multiple-input-directories
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault-package-maven-plugin.git
commit 12e1249db40ed17d396c20b110f7d771da41e7ee
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri Aug 18 16:13:48 2023 +0200
JCRVLT-714 Support multiple source directories
WIP
---
.../filevault/maven/packaging/mojo/VaultMojo.java | 81 +++++++++++-----------
1 file changed, 41 insertions(+), 40 deletions(-)
diff --git a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/VaultMojo.java b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/VaultMojo.java
index 55d37e6..7c57a14 100644
--- a/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/VaultMojo.java
+++ b/src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/VaultMojo.java
@@ -516,48 +516,22 @@ public class VaultMojo extends AbstractSourceAndMetadataPackageMojo {
}
// find the source directory
final File jcrSourceDirectory = getJcrSourceDirectory();
- // include content from build only if it exists
- if (jcrSourceDirectory != null && jcrSourceDirectory.exists()) {
- if (jcrSourceDirectory.getAbsoluteFile().toPath().normalize().startsWith(workDirectory.getAbsoluteFile().toPath().normalize())) {
- throw new MojoFailureException("jcrSourceDirectory ("+jcrSourceDirectory+") must be outside of workDirectory ("+ workDirectory + ")!");
- }
- getLog().info("Packaging content from " + getProjectRelativeFilePath(jcrSourceDirectory));
- Map<File, File> overwrittenFiles = addSourceDirectory(mavenResourcesExecution, contentPackageArchiver, jcrSourceDirectory, filters, embeddedFiles);
- duplicateFiles.putAll(overwrittenFiles);
-
- if (!duplicateFiles.isEmpty()) {
- for (Entry<File, File> entry : duplicateFiles.entrySet()) {
- String message = "Found duplicate file '" + entry.getKey() + "' from sources " + getProjectRelativeFilePath(protectedFiles.get(entry.getKey()))
- + " and " + getProjectRelativeFilePath(entry.getValue()) + ".";
- if (failOnDuplicateEntries) {
- getLog().error(message);
- } else {
- getLog().warn(message);
- }
- }
+ addSourceDirectory(mavenResourcesExecution, contentPackageArchiver, jcrSourceDirectory, filters, embeddedFiles);
+
+
+ if (!duplicateFiles.isEmpty()) {
+ for (Entry<File, File> entry : duplicateFiles.entrySet()) {
+ String message = "Found duplicate file '" + entry.getKey() + "' from sources " + getProjectRelativeFilePath(protectedFiles.get(entry.getKey()))
+ + " and " + getProjectRelativeFilePath(entry.getValue()) + ".";
if (failOnDuplicateEntries) {
- throw new MojoFailureException(
- "Found " + duplicateFiles.size() + " duplicate file(s) in content package, see above errors for details.");
+ getLog().error(message);
+ } else {
+ getLog().warn(message);
}
}
-
- // check for uncovered files (i.e. files from the source which are not even added to the content package)
- Collection<File> uncoveredFiles = getUncoveredFiles(jcrSourceDirectory, excludes, prefix,
- contentPackageArchiver.getFiles().keySet());
- if (!uncoveredFiles.isEmpty()) {
- for (File uncoveredFile : uncoveredFiles) {
- String message = "File " + getProjectRelativeFilePath(uncoveredFile)
- + " not covered by a filter rule and therefore not contained in the resulting package";
- if (failOnUncoveredSourceFiles) {
- getLog().error(message);
- } else {
- getLog().warn(message);
- }
- }
- if (failOnUncoveredSourceFiles) {
- throw new MojoFailureException("The following files are not covered by a filter rule: \n"
- + StringUtils.join(uncoveredFiles.iterator(), ",\n"));
- }
+ if (failOnDuplicateEntries) {
+ throw new MojoFailureException(
+ "Found " + duplicateFiles.size() + " duplicate file(s) in content package, see above errors for details.");
}
}
@@ -602,8 +576,17 @@ public class VaultMojo extends AbstractSourceAndMetadataPackageMojo {
}
private Map<File, File> addSourceDirectory(MavenResourcesExecution mavenResourcesExecution, ContentPackageArchiver contentPackageArchiver, File jcrSourceDirectory, Filters filters,
- Map<String, File> embeddedFiles) throws MavenFilteringException {
+ Map<String, File> embeddedFiles) throws MavenFilteringException, MojoFailureException {
Map<File, File> duplicateFiles = new HashMap<>();
+
+ if (jcrSourceDirectory == null || !jcrSourceDirectory.exists()) {
+ return Collections.emptyMap();
+
+ }
+ if (jcrSourceDirectory.getAbsoluteFile().toPath().normalize().startsWith(getWorkDirectory(false).getAbsoluteFile().toPath().normalize())) {
+ throw new MojoFailureException("jcrSourceDirectory ("+jcrSourceDirectory+") must be outside of workDirectory ("+ workDirectory + ")!");
+ }
+ getLog().info("Packaging content from " + getProjectRelativeFilePath(jcrSourceDirectory));
// See GRANITE-16348
// we want to build a list of all the root directories in the order they were specified in the filter
// but ignore the roots that don't point to a directory
@@ -654,6 +637,24 @@ public class VaultMojo extends AbstractSourceAndMetadataPackageMojo {
}
}
+ // check for uncovered files (i.e. files from the source which are not even added to the content package)
+ Collection<File> uncoveredFiles = getUncoveredFiles(jcrSourceDirectory, excludes, prefix,
+ contentPackageArchiver.getFiles().keySet());
+ if (!uncoveredFiles.isEmpty()) {
+ for (File uncoveredFile : uncoveredFiles) {
+ String message = "File " + getProjectRelativeFilePath(uncoveredFile)
+ + " not covered by a filter rule and therefore not contained in the resulting package";
+ if (failOnUncoveredSourceFiles) {
+ getLog().error(message);
+ } else {
+ getLog().warn(message);
+ }
+ }
+ if (failOnUncoveredSourceFiles) {
+ throw new MojoFailureException("The following files are not covered by a filter rule: \n"
+ + StringUtils.join(uncoveredFiles.iterator(), ",\n"));
+ }
+ }
return duplicateFiles;
}