XML Graphics can load FOP services
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 24 May 2022 11:43:34 +0000 (13:43 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 24 May 2022 11:43:34 +0000 (13:43 +0200)
org.argeo.slc.factory/src/org/argeo/slc/factory/A2Factory.java
tp/org.argeo.tp.apache/org.apache.xmlgraphics.bnd [deleted file]
tp/org.argeo.tp.apache/org.apache.xmlgraphics.bnd.retired [new file with mode: 0644]
tp/org.argeo.tp.apache/xmlgraphics/merge.bnd [new file with mode: 0644]
tp/org.argeo.tp.apache/xmlgraphics/services/org.apache.xmlgraphics.image.loader.spi.ImageConverter [new file with mode: 0644]
tp/org.argeo.tp.apache/xmlgraphics/services/org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory [new file with mode: 0644]
tp/org.argeo.tp.apache/xmlgraphics/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader [new file with mode: 0644]

index fab8db542b048dba50a686aabf989c053c418f66..8c5548ab94310a2eb25ca490d4c831d7a6cedfed 100644 (file)
@@ -324,6 +324,21 @@ public class A2Factory {
                        downloadAndProcessM2Sources(repoStr, artifact, targetBundleDir);
                }
 
+               // additional service files
+               Path servicesDir = duDir.resolve("services");
+               if (Files.exists(servicesDir)) {
+                       for (Path p : Files.newDirectoryStream(servicesDir)) {
+                               Path target = targetBundleDir.resolve("META-INF/services/").resolve(p.getFileName());
+                               try (InputStream in = Files.newInputStream(p);
+                                               OutputStream out = Files.newOutputStream(target, StandardOpenOption.APPEND);) {
+                                       out.write("\n".getBytes());
+                                       in.transferTo(out);
+                                       if (logger.isLoggable(DEBUG))
+                                               logger.log(DEBUG, "Appended " + p);
+                               }
+                       }
+               }
+
                Map<String, String> entries = new TreeMap<>();
                try (Analyzer bndAnalyzer = new Analyzer()) {
                        bndAnalyzer.setProperties(mergeProps);
@@ -344,7 +359,7 @@ public class A2Factory {
                                                && value.toString().equals("osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=1.1))\""))
                                        continue keys;// hack for very old classes
                                entries.put(key.toString(), value.toString());
-                               logger.log(DEBUG, () -> key + "=" + value);
+                               //logger.log(DEBUG, () -> key + "=" + value);
 
                        }
                } catch (Exception e) {
@@ -358,6 +373,13 @@ public class A2Factory {
                        String value = entries.get(key);
                        manifest.getMainAttributes().putValue(key, value);
                }
+
+               // Use Maven version as Bundle-Version
+               String bundleVersion = manifest.getMainAttributes().getValue(ManifestConstants.BUNDLE_VERSION.toString());
+               if (bundleVersion == null || bundleVersion.trim().equals("0")) {
+                       // TODO check why it is sometimes set to "0"
+                       manifest.getMainAttributes().putValue(ManifestConstants.BUNDLE_VERSION.toString(), m2Version);
+               }
                try (OutputStream out = Files.newOutputStream(manifestPath)) {
                        manifest.write(out);
                }
@@ -421,7 +443,7 @@ public class A2Factory {
                                                                && value.toString().equals("osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=1.1))\""))
                                                        continue keys;// hack for very old classes
                                                additionalEntries.put(key.toString(), value.toString());
-                                               logger.log(DEBUG, () -> key + "=" + value);
+                                               //logger.log(DEBUG, () -> key + "=" + value);
 
                                        }
                                }
diff --git a/tp/org.argeo.tp.apache/org.apache.xmlgraphics.bnd b/tp/org.argeo.tp.apache/org.apache.xmlgraphics.bnd
deleted file mode 100644 (file)
index 254a0af..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Bundle-License: Apache-2.0
-Bundle-SymbolicName: org.apache.xmlgraphics
-SLC-Origin-M2: org.apache.xmlgraphics:xmlgraphics-commons:2.7
diff --git a/tp/org.argeo.tp.apache/org.apache.xmlgraphics.bnd.retired b/tp/org.argeo.tp.apache/org.apache.xmlgraphics.bnd.retired
new file mode 100644 (file)
index 0000000..254a0af
--- /dev/null
@@ -0,0 +1,3 @@
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.xmlgraphics
+SLC-Origin-M2: org.apache.xmlgraphics:xmlgraphics-commons:2.7
diff --git a/tp/org.argeo.tp.apache/xmlgraphics/merge.bnd b/tp/org.argeo.tp.apache/xmlgraphics/merge.bnd
new file mode 100644 (file)
index 0000000..ec4b5b5
--- /dev/null
@@ -0,0 +1,10 @@
+Bundle-License: Apache-2.0
+Bundle-SymbolicName: org.apache.xmlgraphics
+SLC-Origin-M2: :2.7
+SLC-Origin-M2-Merge: \
+org.apache.xmlgraphics:xmlgraphics-commons
+Export-Package: org.apache.xmlgraphics.*
+Import-Package: \
+org.apache.fop.image.loader.batik;resolution:="optional", \
+*
+
diff --git a/tp/org.argeo.tp.apache/xmlgraphics/services/org.apache.xmlgraphics.image.loader.spi.ImageConverter b/tp/org.argeo.tp.apache/xmlgraphics/services/org.apache.xmlgraphics.image.loader.spi.ImageConverter
new file mode 100644 (file)
index 0000000..045f651
--- /dev/null
@@ -0,0 +1,3 @@
+org.apache.fop.image.loader.batik.ImageConverterSVG2G2D
+org.apache.fop.image.loader.batik.ImageConverterG2D2SVG
+org.apache.fop.image.loader.batik.ImageConverterWMF2G2D
diff --git a/tp/org.argeo.tp.apache/xmlgraphics/services/org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory b/tp/org.argeo.tp.apache/xmlgraphics/services/org.apache.xmlgraphics.image.loader.spi.ImageLoaderFactory
new file mode 100644 (file)
index 0000000..9e0bd60
--- /dev/null
@@ -0,0 +1,2 @@
+org.apache.fop.image.loader.batik.ImageLoaderFactorySVG
+org.apache.fop.image.loader.batik.ImageLoaderFactoryWMF
diff --git a/tp/org.argeo.tp.apache/xmlgraphics/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader b/tp/org.argeo.tp.apache/xmlgraphics/services/org.apache.xmlgraphics.image.loader.spi.ImagePreloader
new file mode 100644 (file)
index 0000000..5644f22
--- /dev/null
@@ -0,0 +1,2 @@
+org.apache.fop.image.loader.batik.PreloaderWMF
+org.apache.fop.image.loader.batik.PreloaderSVG