kwin commented on code in PR #279:
URL: 
https://github.com/apache/jackrabbit-filevault/pull/279#discussion_r1116890344


##########
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AbstractExporter.java:
##########
@@ -201,6 +201,8 @@ public void export(VaultFile parent, boolean noClose)
             // update properties
             setProperty(MetaInf.CREATED, Calendar.getInstance());
             setProperty(MetaInf.CREATED_BY, mgr.getUserId());
+            String moduleName = "org.apache.jackrabbit.vault";
+            setProperty(MetaInf.GENERATOR, moduleName + ":" + 
getVersion(moduleName, this.getClass()));

Review Comment:
   Please also add a dedicated getter in 
`org.apache.jackrabbit.vault.packaging.PackageProperties`



##########
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AbstractExporter.java:
##########
@@ -398,6 +400,28 @@ private static PackageType 
detectPackageType(WorkspaceFilter filter)  {
         return PackageType.MIXED;
     }
 
+    /**
+     * Returns the version of an Oak module.
+     *
+     * @param moduleName the name of the module
+     * @param clazz a class of the module
+     * @return the version (or "SNAPSHOT" when unknown)
+     */
+    private String getVersion(String moduleName, Class<?> clazz) {

Review Comment:
   Can we have a test for this?



##########
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/config/MetaInf.java:
##########
@@ -63,7 +63,12 @@ public interface MetaInf {
      * Name of the 'created by' property
      */
     String CREATED_BY = "createdBy";
-    
+
+    /**
+     * Name of the 'created' property

Review Comment:
   copy&paste typo.



##########
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/AbstractExporter.java:
##########
@@ -398,6 +400,28 @@ private static PackageType 
detectPackageType(WorkspaceFilter filter)  {
         return PackageType.MIXED;
     }
 
+    /**
+     * Returns the version of an Oak module.
+     *
+     * @param moduleName the name of the module
+     * @param clazz a class of the module
+     * @return the version (or "SNAPSHOT" when unknown)
+     */
+    private String getVersion(String moduleName, Class<?> clazz) {
+        // borrowed from oak-commons
+        String version = "SNAPSHOT"; // fallback
+        try (InputStream stream = clazz
+                
.getResourceAsStream("/META-INF/maven/org.apache.jackrabbit.vault/" + 
moduleName + "/pom.properties")) {
+            if (stream != null) {
+                Properties properties = new Properties();
+                properties.load(stream);
+                return properties.getProperty("version", version);
+            }
+        } catch (IOException ignored) {

Review Comment:
   When is this supposed to happen? Why should we ignore that?



-- 
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]

Reply via email to