From e1e9307164934cbaee60a158dab5e6d12a64d8c2 Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Wed, 30 Dec 2020 14:23:09 -0500 Subject: [PATCH 1/7] NLS pass --- .../AbstractMavenizeBundlesMojo.java | 4 +-- .../DeployMavenizedBundlesMojo.java | 3 +- .../updatesite/GenerateUpdateSiteMojo.java | 2 +- .../p2/domino/updatesite/Messages.java | 21 +++++++++++++ .../tasks/GenerateUpdateSiteTask.java | 31 ++++++++++--------- .../p2/domino/updatesite/messages.properties | 19 ++++++++++++ 6 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/Messages.java create mode 100644 generate-domino-update-site/src/main/resources/org/openntf/p2/domino/updatesite/messages.properties 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 96b350c..364657c 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 @@ -101,7 +101,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { bundlesByName.put(b.getArtifactId(), b); }); } catch(IOException e) { - throw new MojoExecutionException("Exception while processing bundles"); + throw new MojoExecutionException(Messages.getString("AbstractMavenizeBundlesMojo.exceptionProcessingBundles")); //$NON-NLS-1$ } for(BundleInfo bundle : bundles) { @@ -109,7 +109,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { try { tempPom = generateBundlePom(bundle, basePom, bundlesByName); } catch(XMLException | IOException e) { - throw new MojoExecutionException("Exception while generating temporary pom", e); + throw new MojoExecutionException(Messages.getString("AbstractMavenizeBundlesMojo.exceptionGeneratingPom"), e); //$NON-NLS-1$ } processBundle(bundle, bundles, bundlesByName, tempPom); diff --git a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/DeployMavenizedBundlesMojo.java b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/DeployMavenizedBundlesMojo.java index 23ebbd2..efd803b 100644 --- a/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/DeployMavenizedBundlesMojo.java +++ b/generate-domino-update-site/src/main/java/org/openntf/p2/domino/updatesite/DeployMavenizedBundlesMojo.java @@ -11,6 +11,7 @@ import static org.twdata.maven.mojoexecutor.MojoExecutor.version; import java.nio.file.Path; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -45,7 +46,7 @@ protected void processBundle(BundleInfo bundle, List bundles, Map { - System.out.println("Copying " + artifact.getFileName().toString()); + System.out.println(Messages.getString("GenerateUpdateSiteTask.copying") + artifact.getFileName().toString()); //$NON-NLS-1$ try { Path destJar = copyOrPack(artifact, destDir); @@ -323,11 +324,11 @@ private void buildSiteXml(Path baseDir) throws IOException { Path f = baseDir; if (!Files.isDirectory(f)) { - throw new RuntimeException("Repository directory does not exist."); + throw new RuntimeException(Messages.getString("GenerateUpdateSiteTask.repoDirDoesNotExist")); //$NON-NLS-1$ } else { Path features = f.resolve("features"); //$NON-NLS-1$ if (!Files.isDirectory(features)) { - throw new RuntimeException("Unable to find features directory: " + features.toAbsolutePath()); + throw new RuntimeException(Messages.getString("GenerateUpdateSiteTask.unableToFindFeatures") + features.toAbsolutePath()); //$NON-NLS-1$ } try { @@ -348,7 +349,7 @@ private void buildSiteXml(Path baseDir) throws IOException { String featureFilename = feature.getFileName().toString(); Matcher matcher = FEATURE_FILENAME_PATTERN.matcher(featureFilename); if (!matcher.matches()) { - throw new IllegalStateException("Could not match filename pattern to " + featureFilename); + throw new IllegalStateException(Messages.getString("GenerateUpdateSiteTask.mismatchedFilename") + featureFilename); //$NON-NLS-1$ } String featureName = matcher.group(1); String version = matcher.group(2); @@ -370,12 +371,12 @@ private void buildSiteXml(Path baseDir) throws IOException { try (BufferedWriter w = Files.newBufferedWriter(output, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) { w.write(xml); } catch (IOException e) { - throw new RuntimeException("Error writing site.xml file", e); + throw new RuntimeException(Messages.getString("GenerateUpdateSiteTask.errorWritingSiteXml"), e); //$NON-NLS-1$ } - System.out.println(StringUtil.format("Wrote site.xml contents to {0}", output.toAbsolutePath())); + System.out.println(StringUtil.format(Messages.getString("GenerateUpdateSiteTask.wroteSiteXmlTo"), output.toAbsolutePath())); //$NON-NLS-1$ } catch (XMLException e) { - throw new RuntimeException("Exception while building site.xml document", e); + throw new RuntimeException(Messages.getString("GenerateUpdateSiteTask.exceptionBuildingSiteXml"), e); //$NON-NLS-1$ } } } @@ -402,7 +403,7 @@ private List findEclipsePaths(Path domino) { .filter(path -> Files.exists(path)) .collect(Collectors.toList()); if(eclipsePaths.isEmpty()) { - throw new IllegalArgumentException("Unable to locate plugin directories within " + domino); + throw new IllegalArgumentException(Messages.getString("GenerateUpdateSiteTask.unableToLocatePlugins") + domino); //$NON-NLS-1$ } return eclipsePaths; } @@ -420,7 +421,7 @@ private Path findNotesJar(Path domino) { .filter(Files::exists) .filter(Files::isRegularFile) .findFirst() - .orElseThrow(() -> new IllegalArgumentException("Unable to locate Notes.jar within " + domino)); + .orElseThrow(() -> new IllegalArgumentException(Messages.getString("GenerateUpdateSiteTask.unableToLocateNotesJar") + domino)); //$NON-NLS-1$ } /** @@ -449,7 +450,7 @@ private Document fetchEclipseArtifacts() throws MalformedURLException, XMLExcept return DOMUtil.createDocument(zis); } } catch (IOException e) { - System.err.println("Unable to load Neon artifacts.xml.xz"); + System.err.println(Messages.getString("GenerateUpdateSiteTask.unableToLoadNeon")); //$NON-NLS-1$ e.printStackTrace(); return null; } @@ -479,10 +480,10 @@ private void downloadSource(Path artifact, Path destDir, Document artifacts) thr urlString = PathUtil.concat(urlString, bundleName, '/'); URL bundleUrl = new URL(urlString); try(InputStream is = bundleUrl.openStream()) { - System.out.println("- Downloading source bundle " + artifact.getFileName().toString()); + System.out.println(Messages.getString("GenerateUpdateSiteTask.downloadingSourceBundle") + artifact.getFileName().toString()); //$NON-NLS-1$ Files.copy(is, dest, StandardCopyOption.REPLACE_EXISTING); } catch(IOException e) { - System.err.println("Unable to download source bundle " + urlString); + System.err.println(Messages.getString("GenerateUpdateSiteTask.unableToDownloadSourceBundle") + urlString); //$NON-NLS-1$ e.printStackTrace(); } } 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 new file mode 100644 index 0000000..8bc822c --- /dev/null +++ b/generate-domino-update-site/src/main/resources/org/openntf/p2/domino/updatesite/messages.properties @@ -0,0 +1,19 @@ +AbstractMavenizeBundlesMojo.exceptionGeneratingPom=Exception while generating temporary pom +AbstractMavenizeBundlesMojo.exceptionProcessingBundles=Exception while processing bundles +DeployMavenizedBundlesMojo.unexpectedRepositoryFormat=Unexpected repository format: {0} +GenerateUpdateSiteMojo.unableToLocateDomino=Unable to locate Domino directory; please specify using the `src` parameter +GenerateUpdateSiteTask.0=Unable to locate xsp.http.bootstrap.jar - skipping bundle creation +GenerateUpdateSiteTask.copying=Copying +GenerateUpdateSiteTask.directoryExistsAsFile=Planned directory exists as a file: +GenerateUpdateSiteTask.directoryNotExists=Directory does not exist: +GenerateUpdateSiteTask.downloadingSourceBundle=- Downloading source bundle +GenerateUpdateSiteTask.errorWritingSiteXml=Error writing site.xml file +GenerateUpdateSiteTask.exceptionBuildingSiteXml=Exception while building site.xml document +GenerateUpdateSiteTask.mismatchedFilename=Could not match filename pattern to +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.unableToLocatePlugins=Unable to locate plugin directories within +GenerateUpdateSiteTask.wroteSiteXmlTo=Wrote site.xml contents to {0} From 6a370704b4bcf875c8cd2d35930172b09873caf0 Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Mon, 5 Jul 2021 17:26:48 -0400 Subject: [PATCH 2/7] Set version to 4.1.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 9cc254e..acce094 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.0.0 + 4.1.0-SNAPSHOT maven-plugin generate-domino-update-site From 8b1663e1273c7682685d5965e7bc6a3c7376a13b Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Thu, 23 Sep 2021 12:48:23 -0400 Subject: [PATCH 3/7] Merge classifier name handling --- .../p2/domino/updatesite/AbstractMavenizeBundlesMojo.java | 5 ++++- .../p2/domino/updatesite/DeployMavenizedBundlesMojo.java | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) 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 364657c..1d1c62d 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 @@ -170,7 +170,7 @@ protected Path generateBundlePom(BundleInfo bundle, String basePom, Map bundles, Map embedFiles = new ArrayList<>(); List embedClassifiers = new ArrayList<>(); for(BundleEmbed embed : bundle.getEmbeds()) { - String baseName = embed.getName().substring(0, embed.getName().lastIndexOf('.')).replace('/', '$'); + String baseName = toEmbedClassifierName(embed.getName()); embedFiles.add(embed.getFile().toString()); embedClassifiers.add(baseName); } From a70faa15427dbbef59780d63d703bb03bcc34b5b Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Thu, 23 Sep 2021 12:48:31 -0400 Subject: [PATCH 4/7] Add check for potential NPE --- .../p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 35c38e8..457acc9 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 @@ -248,7 +248,7 @@ private void copyArtifacts(Path sourceDir, Path destDir, Document eclipseArtifac try { Path destJar = copyOrPack(artifact, destDir); - if(eclipseArtifacts != null) { + if(eclipseArtifacts != null && destJar != null) { downloadSource(destJar, destDir, eclipseArtifacts); } From 466a58a6e5a66f264502257bebafd5c23fd7ad37 Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Thu, 23 Sep 2021 12:49:07 -0400 Subject: [PATCH 5/7] Bump copyright year --- 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 acce094..e627911 100644 --- a/generate-domino-update-site/pom.xml +++ b/generate-domino-update-site/pom.xml @@ -180,7 +180,7 @@ Jesse Gallagher - 2020 + 2021 From 8e3290c8069fe7b3ee295fa24f5ed15c18e445be Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Thu, 3 Feb 2022 14:06:00 -0500 Subject: [PATCH 6/7] Account for an apparent case on Windows where ZIP path names use backslashes --- .../p2/domino/updatesite/tasks/GenerateUpdateSiteTask.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 457acc9..2cf3376 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 @@ -125,7 +125,7 @@ public void run() { String exports = notesJarFile.stream() .map(jarEntry -> Paths.get(jarEntry.getName()).getParent()) .filter(Objects::nonNull) - .map(path -> path.toString().replace('/', '.')) + .map(path -> path.toString().replace('/', '.').replace('\\', '.')) .distinct() .filter(Objects::nonNull) .filter(name -> !"META-INF".equals(name)) //$NON-NLS-1$ @@ -192,7 +192,7 @@ public void run() { .filter(jarEntry -> StringUtil.toString(jarEntry.getName()).endsWith(".class")) //$NON-NLS-1$ .map(jarEntry -> Paths.get(jarEntry.getName()).getParent()) .filter(Objects::nonNull) - .map(path -> path.toString().replace('/', '.')) + .map(path -> path.toString().replace('/', '.').replace('\\', '.')) .distinct() .filter(Objects::nonNull) .filter(name -> !"META-INF".equals(name)) //$NON-NLS-1$ From 2547b11a89f8341426f371572304f4147e373a88 Mon Sep 17 00:00:00 2001 From: Jesse Gallagher Date: Wed, 23 Feb 2022 13:48:35 -0500 Subject: [PATCH 7/7] Set version to 4.1.0 --- README.md | 2 +- generate-domino-update-site/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b0fb9cd..ea61fd5 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Add the OpenNTF Maven server to your ~/.m2/settings.xml file. For example: Execute the plugin with properties to point to the base of your Domino installation and the target folder. For example: ```sh -$ mvn org.openntf.p2:generate-domino-update-site:4.0.0:generateUpdateSite \ +$ mvn org.openntf.p2:generate-domino-update-site:4.1.0:generateUpdateSite \ -Dsrc="/Volumes/C/Program Files/IBM/Domino" \ -Ddest="/Users/someuser/Desktop/UpdateSite" ``` diff --git a/generate-domino-update-site/pom.xml b/generate-domino-update-site/pom.xml index e627911..00d3cf4 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-SNAPSHOT + 4.1.0 maven-plugin generate-domino-update-site