From 6325c26c2166e7b96beeaab7e342367192796955 Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Wed, 23 Feb 2022 13:49:14 -0500 Subject: [PATCH 1/6] Set version to 4.2.0-SNAPSHOT --- generate-domino-update-site/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate-domino-update-site/pom.xml b/generate-domino-update-site/pom.xml index 00d3cf4..10441dc 100644 --- a/generate-domino-update-site/pom.xml +++ b/generate-domino-update-site/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.openntf.p2 generate-domino-update-site - 4.1.0 + 4.2.0-SNAPSHOT maven-plugin generate-domino-update-site From 36fd02e4e6a900a7d6f361af84e93afbb9bcb3e3 Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Thu, 17 Nov 2022 12:08:24 -0500 Subject: [PATCH 2/6] Switch to non-blocked XML utilities for Java 9+ compatibility (Issue #11) --- generate-domino-update-site/pom.xml | 14 +- .../AbstractMavenizeBundlesMojo.java | 44 ++--- .../tasks/GenerateP2MetadataTask.java | 182 ++++++++++-------- 3 files changed, 133 insertions(+), 107 deletions(-) diff --git a/generate-domino-update-site/pom.xml b/generate-domino-update-site/pom.xml index 10441dc..6ee057f 100644 --- a/generate-domino-update-site/pom.xml +++ b/generate-domino-update-site/pom.xml @@ -35,6 +35,14 @@ https://artifactory.openntf.org/openntf + + + + artifactory.openntf.org + artifactory.openntf.org + https://artifactory.openntf.org/openntf + + @@ -77,9 +85,9 @@ 9.0.0 - com.ibm.sbt - com.ibm.commons.xml - 9.0.0 + org.openntf.nsfodp + org.openntf.nsfodp.commons + 3.9.0 org.eclipse.osgi diff --git a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/AbstractMavenizeBundlesMojo.java b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/AbstractMavenizeBundlesMojo.java index 1d1c62d..76e5eab 100644 --- a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/AbstractMavenizeBundlesMojo.java +++ b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/AbstractMavenizeBundlesMojo.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.StringReader; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -36,6 +37,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.eclipse.osgi.util.ManifestElement; +import org.openntf.nsfodp.commons.xml.NSFODPDomUtil; import org.openntf.p2.domino.updatesite.model.BundleEmbed; import org.openntf.p2.domino.updatesite.model.BundleInfo; import org.osgi.framework.Version; @@ -44,8 +46,6 @@ import com.ibm.commons.util.StringUtil; import com.ibm.commons.util.io.StreamUtil; -import com.ibm.commons.xml.DOMUtil; -import com.ibm.commons.xml.XMLException; import lombok.SneakyThrows; @@ -108,7 +108,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { Path tempPom; try { tempPom = generateBundlePom(bundle, basePom, bundlesByName); - } catch(XMLException | IOException e) { + } catch(IOException e) { throw new MojoExecutionException(Messages.getString("AbstractMavenizeBundlesMojo.exceptionGeneratingPom"), e); //$NON-NLS-1$ } @@ -118,42 +118,42 @@ public void execute() throws MojoExecutionException, MojoFailureException { protected abstract void processBundle(BundleInfo bundle, List bundles, Map bundlesByName, Path tempPom) throws MojoExecutionException; - protected Path generateBundlePom(BundleInfo bundle, String basePom, Map bundles) throws XMLException, IOException { - Document xml = DOMUtil.createDocument(basePom); + protected Path generateBundlePom(BundleInfo bundle, String basePom, Map bundles) throws IOException { + Document xml = NSFODPDomUtil.createDocument(new StringReader(basePom)); Element project = xml.getDocumentElement(); - Element groupIdEl = DOMUtil.createElement(xml, project, "groupId"); //$NON-NLS-1$ + Element groupIdEl = NSFODPDomUtil.createElement(project, "groupId"); //$NON-NLS-1$ groupIdEl.setTextContent(this.groupId); - Element artifactId = DOMUtil.createElement(xml, project, "artifactId"); //$NON-NLS-1$ + Element artifactId = NSFODPDomUtil.createElement(project, "artifactId"); //$NON-NLS-1$ artifactId.setTextContent(bundle.getArtifactId()); - Element version = DOMUtil.createElement(xml, project, "version"); //$NON-NLS-1$ + Element version = NSFODPDomUtil.createElement(project, "version"); //$NON-NLS-1$ version.setTextContent(bundle.getVersion()); if(StringUtil.isNotEmpty(bundle.getVendor())) { - Element organization = DOMUtil.createElement(xml, project, "organization"); //$NON-NLS-1$ - Element name = DOMUtil.createElement(xml, organization, "name"); //$NON-NLS-1$ + Element organization = NSFODPDomUtil.createElement(project, "organization"); //$NON-NLS-1$ + Element name = NSFODPDomUtil.createElement(organization, "name"); //$NON-NLS-1$ name.setTextContent(bundle.getVendor()); } - Element dependencies = DOMUtil.createElement(xml, project, "dependencies"); //$NON-NLS-1$ + Element dependencies = NSFODPDomUtil.createElement(project, "dependencies"); //$NON-NLS-1$ // Add dependencies based on Require-Bundle if(!bundle.getRequires().isEmpty()) { for(String require : bundle.getRequires()) { BundleInfo dep = bundles.get(require); if(dep != null) { - Element dependency = DOMUtil.createElement(xml, dependencies, "dependency"); //$NON-NLS-1$ - Element groupId = DOMUtil.createElement(xml, dependency, "groupId"); //$NON-NLS-1$ + Element dependency = NSFODPDomUtil.createElement(dependencies, "dependency"); //$NON-NLS-1$ + Element groupId = NSFODPDomUtil.createElement(dependency, "groupId"); //$NON-NLS-1$ groupId.setTextContent(this.groupId); - Element depArtifactId = DOMUtil.createElement(xml, dependency, "artifactId"); //$NON-NLS-1$ + Element depArtifactId = NSFODPDomUtil.createElement(dependency, "artifactId"); //$NON-NLS-1$ depArtifactId.setTextContent(dep.getArtifactId()); - Element depVersion = DOMUtil.createElement(xml, dependency, "version"); //$NON-NLS-1$ + Element depVersion = NSFODPDomUtil.createElement(dependency, "version"); //$NON-NLS-1$ depVersion.setTextContent(dep.getVersion()); if(optionalDependencies) { - DOMUtil.createElement(xml, dependency, "optional").setTextContent("true"); //$NON-NLS-1$ //$NON-NLS-2$ + NSFODPDomUtil.createElement(dependency, "optional").setTextContent("true"); //$NON-NLS-1$ //$NON-NLS-2$ } } } @@ -162,14 +162,14 @@ protected Path generateBundlePom(BundleInfo bundle, String basePom, Map { //$NON-NLS-1$ @@ -124,23 +124,23 @@ private Document createArtifactsXml() throws IOException, XMLException { Document featureXml = getFeatureXml(feature); Element rootElement = featureXml.getDocumentElement(); - Element artifact = DOMUtil.createElement(doc, artifacts, "artifact"); //$NON-NLS-1$ + Element artifact = NSFODPDomUtil.createElement(artifacts, "artifact"); //$NON-NLS-1$ artifact.setAttribute("classifier", "org.eclipse.update.feature"); //$NON-NLS-1$ //$NON-NLS-2$ artifact.setAttribute("id", rootElement.getAttribute("id")); //$NON-NLS-1$ //$NON-NLS-2$ artifact.setAttribute("version", rootElement.getAttribute("version")); //$NON-NLS-1$ //$NON-NLS-2$ - Element properties = DOMUtil.createElement(doc, artifact, "properties"); //$NON-NLS-1$ + Element properties = NSFODPDomUtil.createElement(artifact, "properties"); //$NON-NLS-1$ properties.setAttribute("size", "3"); //$NON-NLS-1$ //$NON-NLS-2$ - Element artifactSize = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element artifactSize = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ artifactSize.setAttribute("name", "artifact.size"); //$NON-NLS-1$ //$NON-NLS-2$ artifactSize.setAttribute("value", String.valueOf(Files.size(feature))); //$NON-NLS-1$ - Element downloadSize = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element downloadSize = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ downloadSize.setAttribute("name", "download.size"); //$NON-NLS-1$ //$NON-NLS-2$ downloadSize.setAttribute("value", String.valueOf(Files.size(feature))); //$NON-NLS-1$ - Element contentType = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element contentType = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ contentType.setAttribute("name", "download.contentType"); //$NON-NLS-1$ //$NON-NLS-2$ contentType.setAttribute("value", Files.probeContentType(feature)); //$NON-NLS-1$ } catch(Exception e) { @@ -152,20 +152,20 @@ private Document createArtifactsXml() throws IOException, XMLException { try { Manifest manifest = getPluginManifest(plugin); - Element artifact = DOMUtil.createElement(doc, artifacts, "artifact"); //$NON-NLS-1$ + Element artifact = NSFODPDomUtil.createElement(artifacts, "artifact"); //$NON-NLS-1$ artifact.setAttribute("classifier", "osgi.bundle"); //$NON-NLS-1$ //$NON-NLS-2$ String symbolicName = getPluginId(manifest); artifact.setAttribute("id", symbolicName); //$NON-NLS-1$ artifact.setAttribute("version", manifest.getMainAttributes().getValue("Bundle-Version")); //$NON-NLS-1$ //$NON-NLS-2$ - Element properties = DOMUtil.createElement(doc, artifact, "properties"); //$NON-NLS-1$ + Element properties = NSFODPDomUtil.createElement(artifact, "properties"); //$NON-NLS-1$ properties.setAttribute("size", "2"); //$NON-NLS-1$ //$NON-NLS-2$ - Element artifactSize = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element artifactSize = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ artifactSize.setAttribute("name", "artifact.size"); //$NON-NLS-1$ //$NON-NLS-2$ artifactSize.setAttribute("value", String.valueOf(Files.size(plugin))); //$NON-NLS-1$ - Element downloadSize = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element downloadSize = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ downloadSize.setAttribute("name", "download.size"); //$NON-NLS-1$ //$NON-NLS-2$ downloadSize.setAttribute("value", String.valueOf(Files.size(plugin))); //$NON-NLS-1$ } catch(Exception e) { @@ -178,33 +178,33 @@ private Document createArtifactsXml() throws IOException, XMLException { return doc; } - private Document createContentXml() throws XMLException, IOException, DOMException { - org.w3c.dom.Document doc = DOMUtil.createDocument(); + private Document createContentXml() throws IOException, DOMException { + org.w3c.dom.Document doc = NSFODPDomUtil.createDocument(); { ProcessingInstruction proc = doc.createProcessingInstruction("metadataRepository", "version='1.1.0'"); //$NON-NLS-1$ //$NON-NLS-2$ doc.appendChild(proc); } - Element repository = DOMUtil.createElement(doc, "repository"); //$NON-NLS-1$ + Element repository = NSFODPDomUtil.createElement(doc, "repository"); //$NON-NLS-1$ repository.setAttribute("name", "XPages Runtime"); //$NON-NLS-1$ //$NON-NLS-2$ repository.setAttribute("type", "org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository"); //$NON-NLS-1$ //$NON-NLS-2$ repository.setAttribute("version", "1"); //$NON-NLS-1$ //$NON-NLS-2$ { - Element properties = DOMUtil.createElement(doc, repository, "properties"); //$NON-NLS-1$ + Element properties = NSFODPDomUtil.createElement(repository, "properties"); //$NON-NLS-1$ properties.setAttribute("size", "2"); //$NON-NLS-1$ //$NON-NLS-2$ - Element timestamp = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element timestamp = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ timestamp.setAttribute("name", "p2.timestamp"); //$NON-NLS-1$ //$NON-NLS-2$ timestamp.setAttribute("value", String.valueOf(System.currentTimeMillis())); //$NON-NLS-1$ - Element compressed = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element compressed = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ compressed.setAttribute("name", "p2.compressed"); //$NON-NLS-1$ //$NON-NLS-2$ compressed.setAttribute("value", "false"); //$NON-NLS-1$ //$NON-NLS-2$ } - Element units = DOMUtil.createElement(doc, repository, "units"); //$NON-NLS-1$ + Element units = NSFODPDomUtil.createElement(repository, "units"); //$NON-NLS-1$ int size[] = new int[] { 0 }; Files.list(dest.resolve("features")).forEach(feature -> { //$NON-NLS-1$ @@ -217,58 +217,58 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti String version = rootElement.getAttribute("version"); //$NON-NLS-1$ String name = resolveWithProperties(rootElement.getAttribute("label"), props); //$NON-NLS-1$ - String description = DOMUtil.evaluateXPath(doc, "/feature/description/text()").getStringValue(); //$NON-NLS-1$ + String description = selectTextValue(featureXml, "/feature/description"); //$NON-NLS-1$ description = resolveWithProperties(description, props); - String descriptionUrl = DOMUtil.evaluateXPath(doc, "/feature/description/@url").getStringValue(); //$NON-NLS-1$ + String descriptionUrl = selectAttribute(featureXml, "/feature/description", "url"); //$NON-NLS-1$ //$NON-NLS-2$ descriptionUrl = resolveWithProperties(descriptionUrl, props); - String license = DOMUtil.evaluateXPath(doc, "/feature/license/text()").getStringValue(); //$NON-NLS-1$ + String license = selectTextValue(featureXml, "/feature/license"); //$NON-NLS-1$ license = resolveWithProperties(license, props); - String licenseUrl = DOMUtil.evaluateXPath(doc, "/feature/license/@url").getStringValue(); //$NON-NLS-1$ + String licenseUrl = selectAttribute(featureXml, "/feature/license", "url"); //$NON-NLS-1$ //$NON-NLS-2$ licenseUrl = resolveWithProperties(licenseUrl, props); - String copyright = DOMUtil.evaluateXPath(doc, "/feature/copyright/text()").getStringValue(); //$NON-NLS-1$ + String copyright = selectTextValue(featureXml, "/feature/copyright"); //$NON-NLS-1$ copyright = resolveWithProperties(copyright, props); - String copyrightUrl = DOMUtil.evaluateXPath(doc, "/feature/copyright/@url").getStringValue(); //$NON-NLS-1$ + String copyrightUrl = selectAttribute(featureXml, "/feature/copyright", "url"); //$NON-NLS-1$ //$NON-NLS-2$ copyrightUrl = resolveWithProperties(copyrightUrl, props); - Element unit = DOMUtil.createElement(doc, units, "unit"); //$NON-NLS-1$ + Element unit = NSFODPDomUtil.createElement(units, "unit"); //$NON-NLS-1$ unit.setAttribute("id", id + ".feature.group"); //$NON-NLS-1$ //$NON-NLS-2$ unit.setAttribute("version", version); //$NON-NLS-1$ { - Element update = DOMUtil.createElement(doc, unit, "update"); //$NON-NLS-1$ + Element update = NSFODPDomUtil.createElement(unit, "update"); //$NON-NLS-1$ update.setAttribute("id", rootElement.getAttribute("id") + ".feature.group"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ update.setAttribute("range", "[0.0.0," + rootElement.getAttribute("version") + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ update.setAttribute("severity", "0"); //$NON-NLS-1$ //$NON-NLS-2$ } { - Element properties = DOMUtil.createElement(doc, unit, "properties"); //$NON-NLS-1$ + Element properties = NSFODPDomUtil.createElement(unit, "properties"); //$NON-NLS-1$ properties.setAttribute("size", "4"); //$NON-NLS-1$ //$NON-NLS-2$ - Element propName = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element propName = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ propName.setAttribute("name", "org.eclipse.equinox.p2.name"); //$NON-NLS-1$ //$NON-NLS-2$ propName.setAttribute("value", name); //$NON-NLS-1$ - Element propDesc = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element propDesc = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ propDesc.setAttribute("name", "org.eclipse.equinox.p2.description"); //$NON-NLS-1$ //$NON-NLS-2$ propDesc.setAttribute("value", description); //$NON-NLS-1$ - Element propDescUrl = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element propDescUrl = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ propDescUrl.setAttribute("name", "org.eclipse.equinox.p2.description.url"); //$NON-NLS-1$ //$NON-NLS-2$ propDescUrl.setAttribute("value", descriptionUrl); //$NON-NLS-1$ - Element propTypeGroup = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element propTypeGroup = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ propTypeGroup.setAttribute("name", "org.eclipse.equinox.p2.type.group"); //$NON-NLS-1$ //$NON-NLS-2$ propTypeGroup.setAttribute("value", "true"); //$NON-NLS-1$ //$NON-NLS-2$ } { - Element provides = DOMUtil.createElement(doc, unit, "provides"); //$NON-NLS-1$ + Element provides = NSFODPDomUtil.createElement(unit, "provides"); //$NON-NLS-1$ provides.setAttribute("size", "1"); //$NON-NLS-1$ //$NON-NLS-2$ - Element provided = DOMUtil.createElement(doc, provides, "provided"); //$NON-NLS-1$ + Element provided = NSFODPDomUtil.createElement(provides, "provided"); //$NON-NLS-1$ provided.setAttribute("namespace", "org.eclipse.equinox.p2.iu"); //$NON-NLS-1$ //$NON-NLS-2$ provided.setAttribute("name", id + ".feature.group"); //$NON-NLS-1$ //$NON-NLS-2$ provided.setAttribute("version", version); //$NON-NLS-1$ @@ -276,14 +276,14 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti { int requiresSize = 0; - Element requires = DOMUtil.createElement(doc, unit, "requires"); //$NON-NLS-1$ + Element requires = NSFODPDomUtil.createElement(unit, "requires"); //$NON-NLS-1$ - Object[] plugins = DOMUtil.evaluateXPath(doc, "/feature/plugin").getNodes(); //$NON-NLS-1$ + NodeList plugins = NSFODPDomUtil.selectNodes(doc, "/feature/plugin"); //$NON-NLS-1$ - for(Object pluginObj : plugins) { - Element plugin = (Element)pluginObj; + for(int i = 0; i < plugins.getLength(); i++) { + Element plugin = (Element)plugins.item(i); - Element required = DOMUtil.createElement(doc, requires, "required"); //$NON-NLS-1$ + Element required = NSFODPDomUtil.createElement(requires, "required"); //$NON-NLS-1$ required.setAttribute("namespace", "org.eclipse.equinox.p2.iu"); //$NON-NLS-1$ //$NON-NLS-2$ required.setAttribute("name", plugin.getAttribute("id")); //$NON-NLS-1$ //$NON-NLS-2$ required.setAttribute("range", "[" + plugin.getAttribute("version") + "," + plugin.getAttribute("version") + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ @@ -292,12 +292,12 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti } { - Element required = DOMUtil.createElement(doc, requires, "required"); //$NON-NLS-1$ + Element required = NSFODPDomUtil.createElement(requires, "required"); //$NON-NLS-1$ required.setAttribute("namespace", "org.eclipse.equinox.p2.iu"); //$NON-NLS-1$ //$NON-NLS-2$ required.setAttribute("name", id + ".feature.jar"); //$NON-NLS-1$ //$NON-NLS-2$ required.setAttribute("range", "[" + version + "," + version + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - Element filter = DOMUtil.createElement(doc, required, "filter"); //$NON-NLS-1$ + Element filter = NSFODPDomUtil.createElement(required, "filter"); //$NON-NLS-1$ filter.setTextContent("(org.eclipse.update.install.features=true)"); //$NON-NLS-1$ requiresSize++; @@ -307,23 +307,23 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti } { - Element touchpoint = DOMUtil.createElement(doc, unit, "touchpoint"); //$NON-NLS-1$ + Element touchpoint = NSFODPDomUtil.createElement(unit, "touchpoint"); //$NON-NLS-1$ touchpoint.setAttribute("id", "null"); //$NON-NLS-1$ //$NON-NLS-2$ touchpoint.setAttribute("version", "0.0.0"); //$NON-NLS-1$ //$NON-NLS-2$ } { - Element licenses = DOMUtil.createElement(doc, unit, "licenses"); //$NON-NLS-1$ + Element licenses = NSFODPDomUtil.createElement(unit, "licenses"); //$NON-NLS-1$ licenses.setAttribute("size", "1"); //$NON-NLS-1$ //$NON-NLS-2$ - Element licenseNode = DOMUtil.createElement(doc, licenses, "license"); //$NON-NLS-1$ + Element licenseNode = NSFODPDomUtil.createElement(licenses, "license"); //$NON-NLS-1$ licenseNode.setAttribute("uri", licenseUrl); //$NON-NLS-1$ licenseNode.setAttribute("url", licenseUrl); //$NON-NLS-1$ licenseNode.setTextContent(license); } { - Element copyrightNode = DOMUtil.createElement(doc, unit, "copyright"); //$NON-NLS-1$ + Element copyrightNode = NSFODPDomUtil.createElement(unit, "copyright"); //$NON-NLS-1$ copyrightNode.setAttribute("uri", copyrightUrl); //$NON-NLS-1$ copyrightNode.setAttribute("url", copyrightUrl); //$NON-NLS-1$ copyrightNode.setTextContent(copyright); @@ -344,45 +344,45 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti provider = resolveWithProperties(provider, props); boolean fragment = StringUtil.isNotEmpty(manifest.getMainAttributes().getValue("Fragment-Host")); //$NON-NLS-1$ - Element unit = DOMUtil.createElement(doc, units, "unit"); //$NON-NLS-1$ + Element unit = NSFODPDomUtil.createElement(units, "unit"); //$NON-NLS-1$ unit.setAttribute("id", id); //$NON-NLS-1$ unit.setAttribute("version", version); //$NON-NLS-1$ { - Element update = DOMUtil.createElement(doc, unit, "update"); //$NON-NLS-1$ + Element update = NSFODPDomUtil.createElement(unit, "update"); //$NON-NLS-1$ update.setAttribute("id", id); //$NON-NLS-1$ update.setAttribute("range", "[0.0.0," + version + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ update.setAttribute("severity", "0"); //$NON-NLS-1$ //$NON-NLS-2$ } { - Element properties = DOMUtil.createElement(doc, unit, "properties"); //$NON-NLS-1$ + Element properties = NSFODPDomUtil.createElement(unit, "properties"); //$NON-NLS-1$ properties.setAttribute("size", "2"); //$NON-NLS-1$ //$NON-NLS-2$ - Element propName = DOMUtil.createElement(doc, properties, "property"); //$NON-NLS-1$ + Element propName = NSFODPDomUtil.createElement(properties, "property"); //$NON-NLS-1$ propName.setAttribute("name", "org.eclipse.equinox.p2.name"); //$NON-NLS-1$ //$NON-NLS-2$ propName.setAttribute("value", name); //$NON-NLS-1$ - Element propProvider = DOMUtil.createElement(doc, properties, "provider"); //$NON-NLS-1$ + Element propProvider = NSFODPDomUtil.createElement(properties, "provider"); //$NON-NLS-1$ propProvider.setAttribute("name", "org.eclipse.equinox.p2.provider"); //$NON-NLS-1$ //$NON-NLS-2$ propProvider.setAttribute("value", provider); //$NON-NLS-1$ } { int[] providedSize = new int[] { 0 }; - Element provides = DOMUtil.createElement(doc, unit, "provides"); //$NON-NLS-1$ + Element provides = NSFODPDomUtil.createElement(unit, "provides"); //$NON-NLS-1$ - Element providedIu = DOMUtil.createElement(doc, provides, "provided"); //$NON-NLS-1$ + Element providedIu = NSFODPDomUtil.createElement(provides, "provided"); //$NON-NLS-1$ providedIu.setAttribute("namespace", "org.eclipse.equinox.p2.iu"); //$NON-NLS-1$ //$NON-NLS-2$ providedIu.setAttribute("name", id); //$NON-NLS-1$ providedIu.setAttribute("version", version); //$NON-NLS-1$ - Element providedBundle = DOMUtil.createElement(doc, provides, "provided"); //$NON-NLS-1$ + Element providedBundle = NSFODPDomUtil.createElement(provides, "provided"); //$NON-NLS-1$ providedBundle.setAttribute("namespace", "osgi.bundle"); //$NON-NLS-1$ //$NON-NLS-2$ providedBundle.setAttribute("name", id); //$NON-NLS-1$ providedBundle.setAttribute("version", version); //$NON-NLS-1$ - Element providedType = DOMUtil.createElement(doc, provides, "provided"); //$NON-NLS-1$ + Element providedType = NSFODPDomUtil.createElement(provides, "provided"); //$NON-NLS-1$ providedType.setAttribute("namespace", "org.eclipse.equinox.p2.eclipse.type"); //$NON-NLS-1$ //$NON-NLS-2$ providedType.setAttribute("name", "bundle"); //$NON-NLS-1$ //$NON-NLS-2$ providedType.setAttribute("version", "1.0.0"); //$NON-NLS-1$ //$NON-NLS-2$ @@ -397,7 +397,7 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti if(StringUtil.isEmpty(packageVersion)) { packageVersion = "0.0.0"; //$NON-NLS-1$ } - Element exportElement = DOMUtil.createElement(doc, provides, "provided"); //$NON-NLS-1$ + Element exportElement = NSFODPDomUtil.createElement(provides, "provided"); //$NON-NLS-1$ exportElement.setAttribute("namespace", "java.package"); //$NON-NLS-1$ //$NON-NLS-2$ exportElement.setAttribute("name", el.getValue()); //$NON-NLS-1$ exportElement.setAttribute("version", packageVersion); //$NON-NLS-1$ @@ -432,7 +432,7 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti } } - Element providedFragment = DOMUtil.createElement(doc, provides, "provided"); //$NON-NLS-1$ + Element providedFragment = NSFODPDomUtil.createElement(provides, "provided"); //$NON-NLS-1$ providedFragment.setAttribute("namespace", "osgi.fragment"); //$NON-NLS-1$ //$NON-NLS-2$ providedFragment.setAttribute("name", host); //$NON-NLS-1$ providedFragment.setAttribute("version", hostVersion); //$NON-NLS-1$ @@ -441,14 +441,14 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti } { - Element requires = DOMUtil.createElement(doc, unit, "requires"); //$NON-NLS-1$ + Element requires = NSFODPDomUtil.createElement(unit, "requires"); //$NON-NLS-1$ int[] requiresCount = new int[] { 0 }; String requireBundle = manifest.getMainAttributes().getValue("Require-Bundle"); //$NON-NLS-1$ if(StringUtil.isNotEmpty(requireBundle)) { ManifestElement[] elements = ManifestElement.parseHeader("Require-Bundle", requireBundle); //$NON-NLS-1$ for(ManifestElement el : elements) { - Element required = DOMUtil.createElement(doc, requires, "required"); //$NON-NLS-1$ + Element required = NSFODPDomUtil.createElement(requires, "required"); //$NON-NLS-1$ required.setAttribute("namespace", "osgi.bundle"); //$NON-NLS-1$ //$NON-NLS-2$ String requireVersion = el.getAttribute("bundle-version"); //$NON-NLS-1$ @@ -467,7 +467,7 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti if(StringUtil.isNotEmpty(importPackages)) { ManifestElement[] elements = ManifestElement.parseHeader("Import-Package", importPackages); //$NON-NLS-1$ for(ManifestElement el : elements) { - Element required = DOMUtil.createElement(doc, requires, "required"); //$NON-NLS-1$ + Element required = NSFODPDomUtil.createElement(requires, "required"); //$NON-NLS-1$ required.setAttribute("namespace", "java.package"); //$NON-NLS-1$ //$NON-NLS-2$ String requireVersion = el.getAttribute("version"); //$NON-NLS-1$ @@ -486,32 +486,32 @@ private Document createContentXml() throws XMLException, IOException, DOMExcepti } { - Element artifacts = DOMUtil.createElement(doc, unit, "artifacts"); //$NON-NLS-1$ + Element artifacts = NSFODPDomUtil.createElement(unit, "artifacts"); //$NON-NLS-1$ artifacts.setAttribute("size", "1"); //$NON-NLS-1$ //$NON-NLS-2$ - Element artifact = DOMUtil.createElement(doc, artifacts, "artifact"); //$NON-NLS-1$ + Element artifact = NSFODPDomUtil.createElement(artifacts, "artifact"); //$NON-NLS-1$ artifact.setAttribute("classifier", "osgi.bundle"); //$NON-NLS-1$ //$NON-NLS-2$ artifact.setAttribute("id", id); //$NON-NLS-1$ artifact.setAttribute("version", version); //$NON-NLS-1$ } { - Element touchpoint = DOMUtil.createElement(doc, unit, "touchpoint"); //$NON-NLS-1$ + Element touchpoint = NSFODPDomUtil.createElement(unit, "touchpoint"); //$NON-NLS-1$ touchpoint.setAttribute("id", "org.eclipse.equinox.p2.osgi"); //$NON-NLS-1$ //$NON-NLS-2$ touchpoint.setAttribute("version", "1.0.0"); //$NON-NLS-1$ //$NON-NLS-2$ } { - Element touchpointData = DOMUtil.createElement(doc, unit, "touchpointData"); //$NON-NLS-1$ + Element touchpointData = NSFODPDomUtil.createElement(unit, "touchpointData"); //$NON-NLS-1$ touchpointData.setAttribute("size", "1"); //$NON-NLS-1$ //$NON-NLS-2$ - Element instructions = DOMUtil.createElement(doc, touchpointData, "instructions"); //$NON-NLS-1$ + Element instructions = NSFODPDomUtil.createElement(touchpointData, "instructions"); //$NON-NLS-1$ instructions.setAttribute("size", "2"); //$NON-NLS-1$ //$NON-NLS-2$ - Element instZipped = DOMUtil.createElement(doc, instructions, "instruction"); //$NON-NLS-1$ + Element instZipped = NSFODPDomUtil.createElement(instructions, "instruction"); //$NON-NLS-1$ instZipped.setAttribute("key", "zipped"); //$NON-NLS-1$ //$NON-NLS-2$ instZipped.setTextContent("false"); //$NON-NLS-1$ - Element instManifest = DOMUtil.createElement(doc, instructions, "manifest"); //$NON-NLS-1$ + Element instManifest = NSFODPDomUtil.createElement(instructions, "manifest"); //$NON-NLS-1$ instManifest.setAttribute("key", "manifest"); //$NON-NLS-1$ //$NON-NLS-2$ // TODO trim this down? try(JarFile jar = new JarFile(plugin.toFile())) { @@ -537,10 +537,10 @@ private Document getFeatureXml(Path feature) { try(JarFile featureJar = new JarFile(feature.toFile())) { ZipEntry xmlEntry = featureJar.getEntry("feature.xml"); //$NON-NLS-1$ try(InputStream is = featureJar.getInputStream(xmlEntry)) { - return DOMUtil.createDocument(is); + return NSFODPDomUtil.createDocument(is); } } - } catch(IOException | XMLException e) { + } catch(IOException e) { throw new RuntimeException(e); } } @@ -612,4 +612,22 @@ private String getPluginId(Manifest manifest) { } return symbolicName; } + + private String selectTextValue(Node node, String xpathString) { + Node result = NSFODPDomUtil.selectSingleNode(node, xpathString); + if(result != null) { + return result.getTextContent(); + } else { + return null; + } + } + + private String selectAttribute(Node node, String xpathString, String attr) { + Element el = (Element)NSFODPDomUtil.selectSingleNode(node, xpathString); + if(el != null) { + return el.getAttribute(attr); + } else { + return ""; //$NON-NLS-1$ + } + } } From 05ad1e8705b53d7b2e1b54cebef3d6feb54ca66d Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Thu, 17 Nov 2022 12:59:05 -0500 Subject: [PATCH 3/6] Embed NAPI JAR and improve path searching for macOS (Issue #13) (Issue #14) --- .../p2/domino/updatesite/Messages.java | 5 + .../tasks/GenerateUpdateSiteTask.java | 152 ++++++++++++++---- .../p2/domino/updatesite/messages.properties | 3 +- 3 files changed, 130 insertions(+), 30 deletions(-) diff --git a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/Messages.java b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/Messages.java index db976c8..d397912 100644 --- a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/Messages.java +++ b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/Messages.java @@ -1,5 +1,6 @@ package org.openntf.p2.domino.updatesite; +import java.text.MessageFormat; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -18,4 +19,8 @@ public static String getString(String key) { return '!' + key + '!'; } } + + public static String getString(String key, Object... params) { + return MessageFormat.format(getString(key), params); + } } diff --git a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java index 2cf3376..3f528c6 100644 --- a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java +++ b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.FileVisitResult; @@ -32,9 +33,12 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Properties; import java.util.jar.Attributes; +import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; import java.util.regex.Matcher; @@ -44,17 +48,17 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import org.openntf.nsfodp.commons.xml.NSFODPDomUtil; import org.openntf.p2.domino.updatesite.Messages; import org.openntf.p2.domino.updatesite.util.VersionUtil; import org.tukaani.xz.XZInputStream; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.NodeList; import com.ibm.commons.util.PathUtil; import com.ibm.commons.util.StringUtil; -import com.ibm.commons.xml.DOMUtil; -import com.ibm.commons.xml.XMLException; -import com.ibm.commons.xml.XResult; +import com.ibm.commons.util.io.StreamUtil; public class GenerateUpdateSiteTask implements Runnable { private static final Pattern FEATURE_FILENAME_PATTERN = Pattern.compile("^(.+)_(\\d.+)\\.jar$"); //$NON-NLS-1$ @@ -79,7 +83,8 @@ public void run() { Path domino = checkDirectory(dominoDir); List eclipsePaths = findEclipsePaths(domino); - Path notesJar = findNotesJar(domino); + Path notesJar = findNotesJar(domino) + .orElseThrow(() -> new IllegalArgumentException(Messages.getString("GenerateUpdateSiteTask.unableToLocateLibExtJar", "Notes.jar", domino))); //$NON-NLS-1$ //$NON-NLS-2$ try { Document eclipseArtifacts = fetchEclipseArtifacts(); @@ -98,6 +103,8 @@ public void run() { copyArtifacts(plugins, destPlugins, eclipseArtifacts); } } + + // Create a Notes.jar wrapper bundle pair String baseVersion = readNotesVersion(notesJar); String version = baseVersion + "-1500"; //$NON-NLS-1$ @@ -169,8 +176,8 @@ public void run() { // Create an XSP HTTP Bootstrap bundle, if possible { - Path xspBootstrap = findXspBootstrap(domino); - if(Files.isRegularFile(xspBootstrap)) { + Optional xspBootstrap = findXspBootstrap(domino); + if(xspBootstrap.isPresent()) { String bundleId = "com.ibm.xsp.http.bootstrap"; //$NON-NLS-1$ Path plugin = destPlugins.resolve(bundleId + "_" + version + ".jar"); //$NON-NLS-1$ //$NON-NLS-2$ try (OutputStream fos = Files.newOutputStream(plugin, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) { @@ -187,7 +194,7 @@ public void run() { attrs.putValue("Bundle-ManifestVersion", "2"); //$NON-NLS-1$ //$NON-NLS-2$ // Find the packages to export - try (JarFile notesJarFile = new JarFile(xspBootstrap.toFile())) { + try (JarFile notesJarFile = new JarFile(xspBootstrap.get().toFile())) { String exports = notesJarFile.stream() .filter(jarEntry -> StringUtil.toString(jarEntry.getName()).endsWith(".class")) //$NON-NLS-1$ .map(jarEntry -> Paths.get(jarEntry.getName()).getParent()) @@ -204,7 +211,7 @@ public void run() { jos.closeEntry(); jos.putNextEntry(new ZipEntry("xsp.http.bootstrap.jar")); //$NON-NLS-1$ - Files.copy(xspBootstrap, jos); + Files.copy(xspBootstrap.get(), jos); jos.closeEntry(); } } @@ -212,6 +219,80 @@ public void run() { System.out.println(Messages.getString("GenerateUpdateSiteTask.0")); //$NON-NLS-1$ } } + + // Build a NAPI fragment if on 12.0.2+ + findNapiJar(domino).ifPresent(napiJar -> { + try { + // Find the existing bundle to get its version number + Path napiBundle = Files.list(destPlugins) + .filter(p -> p.getFileName().toString().startsWith("com.ibm.domino.napi_")) //$NON-NLS-1$ + .findFirst() + .orElseThrow(() -> new IllegalStateException(Messages.getString("GenerateUpdateSiteTask.unableToFindNapiBundle", destPlugins))); //$NON-NLS-1$ + + // Rewrite the MANIFEST.MF to allow Eclipse to resolve fragment classes + { + Path tempBundle = Files.createTempFile("com.ibm.domino.napi", ".jar"); //$NON-NLS-1$ //$NON-NLS-2$ + + try( + InputStream is = Files.newInputStream(napiBundle); + JarInputStream jis = new JarInputStream(is); + OutputStream os = Files.newOutputStream(tempBundle, StandardOpenOption.TRUNCATE_EXISTING); + JarOutputStream jos = new JarOutputStream(os) + ) { + JarEntry sourceEntry; + while((sourceEntry = jis.getNextJarEntry()) != null) { + jos.putNextEntry(sourceEntry); + if("META-INF/MANIFEST.MF".equals(sourceEntry.getName())) { //$NON-NLS-1$ + // Modify the manifest + Manifest napiManifest = new Manifest(jis); + napiManifest.getMainAttributes().putValue("Eclipse-ExtensibleAPI", "true"); //$NON-NLS-1$ //$NON-NLS-2$ + napiManifest.write(jos); + } else { + // Otherwise, copy cleanly + StreamUtil.copyStream(jis, jos); + } + } + } + + Files.delete(napiBundle); + Files.move(tempBundle, napiBundle); + + } + + String napiVersion = napiBundle.getFileName().toString().substring("com.ibm.domino.napi_".length()); //$NON-NLS-1$ + napiVersion = napiVersion.substring(0, version.length()-".jar".length()); //$NON-NLS-1$ + + // Create the fragment to house the JAR + { + String fragmentId = "com.ibm.domino.napi.impl"; //$NON-NLS-1$ + Path plugin = destPlugins.resolve(fragmentId + "_" + version + ".jar"); //$NON-NLS-1$ //$NON-NLS-2$ + try (OutputStream fos = Files.newOutputStream(plugin, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) { + try (JarOutputStream jos = new JarOutputStream(fos)) { + jos.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF")); //$NON-NLS-1$ + Manifest manifest = new Manifest(); + Attributes attrs = manifest.getMainAttributes(); + attrs.putValue("Manifest-Version", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$ + attrs.putValue("Bundle-ClassPath", "lwpd.domino.napi.jar"); //$NON-NLS-1$ //$NON-NLS-2$ + attrs.putValue("Bundle-Vendor", "IBM"); //$NON-NLS-1$ //$NON-NLS-2$ + attrs.putValue("Fragment-Host", "com.ibm.domino.napi"); //$NON-NLS-1$ //$NON-NLS-2$ + attrs.putValue("Bundle-Name", "Api Plug-in Implementation JAR"); //$NON-NLS-1$ //$NON-NLS-2$ + attrs.putValue("Bundle-SymbolicName", fragmentId + ";singleton:=true"); //$NON-NLS-1$ //$NON-NLS-2$ + attrs.putValue("Bundle-Version", version); //$NON-NLS-1$ + attrs.putValue("Bundle-ManifestVersion", "2"); //$NON-NLS-1$ //$NON-NLS-2$ + manifest.write(jos); + jos.closeEntry(); + + jos.putNextEntry(new ZipEntry("lwpd.domino.napi.jar")); //$NON-NLS-1$ + Files.copy(napiJar, jos); + jos.closeEntry(); + } + } + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }); + // Create site.xml buildSiteXml(dest); @@ -332,13 +413,13 @@ private void buildSiteXml(Path baseDir) throws IOException { } try { - Document doc = DOMUtil.createDocument(); - Element root = DOMUtil.createElement(doc, "site"); //$NON-NLS-1$ + Document doc = NSFODPDomUtil.createDocument(); + Element root = NSFODPDomUtil.createElement(doc, "site"); //$NON-NLS-1$ // Create the category entry if applicable String category = "XPages Runtime"; //$NON-NLS-1$ if (StringUtil.isNotEmpty(category)) { - Element categoryDef = DOMUtil.createElement(doc, root, "category-def"); //$NON-NLS-1$ + Element categoryDef = NSFODPDomUtil.createElement(root, "category-def"); //$NON-NLS-1$ categoryDef.setAttribute("name", category); //$NON-NLS-1$ categoryDef.setAttribute("label", category); //$NON-NLS-1$ } @@ -354,19 +435,19 @@ private void buildSiteXml(Path baseDir) throws IOException { String featureName = matcher.group(1); String version = matcher.group(2); - Element featureElement = DOMUtil.createElement(doc, root, "feature"); //$NON-NLS-1$ + Element featureElement = NSFODPDomUtil.createElement(root, "feature"); //$NON-NLS-1$ String url = "features/" + featureFilename; //$NON-NLS-1$ featureElement.setAttribute("url", url); //$NON-NLS-1$ featureElement.setAttribute("id", featureName); //$NON-NLS-1$ featureElement.setAttribute("version", version); //$NON-NLS-1$ if (StringUtil.isNotEmpty(category)) { - Element categoryElement = DOMUtil.createElement(doc, featureElement, "category"); //$NON-NLS-1$ + Element categoryElement = NSFODPDomUtil.createElement(featureElement, "category"); //$NON-NLS-1$ categoryElement.setAttribute("name", category); //$NON-NLS-1$ } }); - String xml = DOMUtil.getXMLString(doc, false, true); + String xml = NSFODPDomUtil.getXmlString(doc, null); Path output = f.resolve("site.xml"); //$NON-NLS-1$ try (BufferedWriter w = Files.newBufferedWriter(output, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) { w.write(xml); @@ -375,7 +456,7 @@ private void buildSiteXml(Path baseDir) throws IOException { } System.out.println(StringUtil.format(Messages.getString("GenerateUpdateSiteTask.wroteSiteXmlTo"), output.toAbsolutePath())); //$NON-NLS-1$ - } catch (XMLException e) { + } catch (Exception e) { throw new RuntimeException(Messages.getString("GenerateUpdateSiteTask.exceptionBuildingSiteXml"), e); //$NON-NLS-1$ } } @@ -411,17 +492,31 @@ private List findEclipsePaths(Path domino) { /** * @since 3.1.0 */ - private Path findNotesJar(Path domino) { + private Optional findNotesJar(Path domino) { + return findLibExtJar(domino, "Notes.jar"); //$NON-NLS-1$ + } + + /** + * @since 4.2.0 + */ + private Optional findNapiJar(Path domino) { + return findLibExtJar(domino, "lwpd.domino.napi.jar"); //$NON-NLS-1$ + } + + private Optional findLibExtJar(Path domino, String jarName) { return Stream.of( - // macOS Notes client - domino.resolve("Contents").resolve("MacOS").resolve("jvm").resolve("lib").resolve("ext").resolve("Notes.jar"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - // All Notes and Domino, including macOS Notes client pointed at Contents/MacOS - domino.resolve("jvm").resolve("lib").resolve("ext").resolve("Notes.jar") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + // macOS Notes client < 12 + domino.resolve("Contents").resolve("MacOS").resolve("jvm").resolve("lib").resolve("ext").resolve(jarName), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + // macOS Notes client 12 + domino.resolve("Contents").resolve("Resources").resolve("jvm").resolve("lib").resolve("ext").resolve(jarName), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + // All Notes and Domino, including < 12 macOS Notes client pointed at Contents/MacOS + domino.resolve("jvm").resolve("lib").resolve("ext").resolve(jarName), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + // macOS Notes client pointed at Contents/MacOS + domino.getParent().resolve("jvm").resolve("lib").resolve("ext").resolve(jarName) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ ) .filter(Files::exists) .filter(Files::isRegularFile) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException(Messages.getString("GenerateUpdateSiteTask.unableToLocateNotesJar") + domino)); //$NON-NLS-1$ + .findFirst(); } /** @@ -429,9 +524,9 @@ private Path findNotesJar(Path domino) { * @return a {@link Path} to xsp.http.bootstrap.jar, which may not exist * @since 3.2.0 */ - private Path findXspBootstrap(Path domino) { + private Optional findXspBootstrap(Path domino) { // This only exists on servers and the Windows client for now, so no need to look through special Mac paths - return domino.resolve("jvm").resolve("lib").resolve("ext").resolve("xsp.http.bootstrap.jar"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + return findLibExtJar(domino, "xsp.http.bootstrap.jar"); //$NON-NLS-1$ } /** @@ -442,12 +537,12 @@ private Path findXspBootstrap(Path domino) { * * @since 3.3.0 */ - private Document fetchEclipseArtifacts() throws MalformedURLException, XMLException { + private Document fetchEclipseArtifacts() throws MalformedURLException { String urlString = PathUtil.concat(NEON_UPDATE_SITE, "artifacts.xml.xz", '/'); //$NON-NLS-1$ URL artifactsUrl = new URL(urlString); try(InputStream is = artifactsUrl.openStream()) { try(XZInputStream zis = new XZInputStream(is)) { - return DOMUtil.createDocument(zis); + return NSFODPDomUtil.createDocument(zis); } } catch (IOException e) { System.err.println(Messages.getString("GenerateUpdateSiteTask.unableToLoadNeon")); //$NON-NLS-1$ @@ -469,9 +564,8 @@ private void downloadSource(Path artifact, Path destDir, Document artifacts) thr String version = matcher.group(2); String query = StringUtil.format("/repository/artifacts/artifact[@classifier='osgi.bundle'][@id='{0}'][@version='{1}']", symbolicName, version); //$NON-NLS-1$ - XResult result = DOMUtil.evaluateXPath(artifacts, query); - Object[] artifactNodes = result.getNodes(); - if(artifactNodes != null && artifactNodes.length > 0) { + NodeList result = NSFODPDomUtil.selectNodes(artifacts, query); + if(result.getLength() > 0) { // Then we can be confident that it will exist at the expected URL String bundleName = StringUtil.format("{0}_{1}.jar", symbolicName, version); //$NON-NLS-1$ Path dest = destDir.resolve(bundleName); diff --git a/generate-domino-update-site/src/main/resources/org/openntf/p2/domino/updatesite/messages.properties b/generate-domino-update-site/src/main/resources/org/openntf/p2/domino/updatesite/messages.properties index 8bc822c..7c6b328 100644 --- a/generate-domino-update-site/src/main/resources/org/openntf/p2/domino/updatesite/messages.properties +++ b/generate-domino-update-site/src/main/resources/org/openntf/p2/domino/updatesite/messages.properties @@ -14,6 +14,7 @@ GenerateUpdateSiteTask.repoDirDoesNotExist=Repository directory does not exist. GenerateUpdateSiteTask.unableToDownloadSourceBundle=Unable to download source bundle GenerateUpdateSiteTask.unableToFindFeatures=Unable to find features directory: GenerateUpdateSiteTask.unableToLoadNeon=Unable to load Neon artifacts.xml.xz -GenerateUpdateSiteTask.unableToLocateNotesJar=Unable to locate Notes.jar within +GenerateUpdateSiteTask.unableToLocateLibExtJar=Unable to locate {0} within {1} GenerateUpdateSiteTask.unableToLocatePlugins=Unable to locate plugin directories within GenerateUpdateSiteTask.wroteSiteXmlTo=Wrote site.xml contents to {0} +GenerateUpdateSiteTask.unableToFindNapiBundle=Unable to find com.ibm.domino.napi bundle in {0} From c70154706df7320995c952b9d4af4f01d3cfa23a Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Thu, 17 Nov 2022 13:11:14 -0500 Subject: [PATCH 4/6] Expand path resolvers for Notes 12 on macOS (Issue #14) --- .../updatesite/tasks/GenerateUpdateSiteTask.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java index 3f528c6..ebcd020 100644 --- a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java +++ b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java @@ -468,12 +468,18 @@ private void buildSiteXml(Path baseDir) throws IOException { private List findEclipsePaths(Path domino) { // Account for various layouts List eclipsePaths = Stream.of( - // macOS Notes client + // macOS Notes client < 12 domino.resolve("Contents").resolve("MacOS").resolve("shared").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ domino.resolve("Contents").resolve("MacOS").resolve("rcp").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - // macOS Notes client pointed at Contents/MacOS + // macOS Notes client 12 + domino.resolve("Contents").resolve("Eclipse").resolve("shared").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + domino.resolve("Contents").resolve("Eclipse").resolve("rcp").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + // macOS Notes client < 12 pointed at Contents/MacOS domino.resolve("shared").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ domino.resolve("rcp").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ + // macOS Notes client 12 pointed at Contents/MacOS + domino.getParent().resolve("Eclipse").resolve("shared").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + domino.getParent().resolve("Eclipse").resolve("rcp").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // Domino and Windows Notes domino.resolve("osgi").resolve("shared").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ domino.resolve("osgi").resolve("rcp").resolve("eclipse"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -511,8 +517,8 @@ private Optional findLibExtJar(Path domino, String jarName) { domino.resolve("Contents").resolve("Resources").resolve("jvm").resolve("lib").resolve("ext").resolve(jarName), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ // All Notes and Domino, including < 12 macOS Notes client pointed at Contents/MacOS domino.resolve("jvm").resolve("lib").resolve("ext").resolve(jarName), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - // macOS Notes client pointed at Contents/MacOS - domino.getParent().resolve("jvm").resolve("lib").resolve("ext").resolve(jarName) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + // macOS Notes client 12 pointed at Contents/MacOS + domino.getParent().resolve("Resources").resolve("jvm").resolve("lib").resolve("ext").resolve(jarName) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ ) .filter(Files::exists) .filter(Files::isRegularFile) From 149cda673287986a10cee680cec2bbc8f5ac555c Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Thu, 17 Nov 2022 13:19:19 -0500 Subject: [PATCH 5/6] Set version to 4.2.0 --- generate-domino-update-site/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate-domino-update-site/pom.xml b/generate-domino-update-site/pom.xml index 6ee057f..3400f7a 100644 --- a/generate-domino-update-site/pom.xml +++ b/generate-domino-update-site/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.openntf.p2 generate-domino-update-site - 4.2.0-SNAPSHOT + 4.2.0 maven-plugin generate-domino-update-site From 340b8892a7b7b5e6d6f750012eac4b1d022d06ba Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Thu, 17 Nov 2022 13:23:17 -0500 Subject: [PATCH 6/6] Dependency update --- generate-domino-update-site/pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/generate-domino-update-site/pom.xml b/generate-domino-update-site/pom.xml index 3400f7a..807996b 100644 --- a/generate-domino-update-site/pom.xml +++ b/generate-domino-update-site/pom.xml @@ -13,7 +13,7 @@ 1.8 - 3.3.9 + 3.8.6 https://openntf.org/main.nsf/project.xsp?r=project/NSF%20ODP%20Tooling @@ -76,7 +76,7 @@ org.codehaus.plexus plexus-utils - 3.0.8 + 3.5.0 @@ -104,7 +104,7 @@ org.projectlombok lombok - 1.18.8 + 1.18.24 provided @@ -116,18 +116,18 @@ org.apache.commons commons-lang3 - 3.9 + 3.12.0 org.tukaani xz - 1.8 + 1.9 org.junit.jupiter junit-jupiter-engine - 5.5.2 + 5.9.1 test