Skip to content

Commit

Permalink
Merge branch 'release/4.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jesse-gallagher committed Feb 23, 2022
2 parents d7d2db9 + 2547b11 commit a4d6091
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
```
Expand Down
4 changes: 2 additions & 2 deletions generate-domino-update-site/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.openntf.p2</groupId>
<artifactId>generate-domino-update-site</artifactId>
<version>4.0.0</version>
<version>4.1.0</version>
<packaging>maven-plugin</packaging>

<name>generate-domino-update-site</name>
Expand Down Expand Up @@ -180,7 +180,7 @@
</excludes>
<properties>
<owner>Jesse Gallagher</owner>
<copyrightYear>2020</copyrightYear>
<copyrightYear>2021</copyrightYear>
</properties>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ 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) {
Path tempPom;
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);
Expand Down Expand Up @@ -170,7 +170,7 @@ protected Path generateBundlePom(BundleInfo bundle, String basePom, Map<String,
Element depVersion = DOMUtil.createElement(xml, dependency, "version"); //$NON-NLS-1$
depVersion.setTextContent(bundle.getVersion());
Element depClassifier = DOMUtil.createElement(xml, dependency, "classifier"); //$NON-NLS-1$
depClassifier.setTextContent(embed.getName());
depClassifier.setTextContent(toEmbedClassifierName(embed.getName()));
}
}

Expand Down Expand Up @@ -365,4 +365,7 @@ protected BundleInfo toInfo(Path path) {
}
}

public static String toEmbedClassifierName(String embedName) {
return embedName.substring(0, embedName.lastIndexOf('.')).replace('/', '$');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,7 +46,7 @@ protected void processBundle(BundleInfo bundle, List<BundleInfo> bundles, Map<St
Path tempPom) throws MojoExecutionException {
String[] repoBits = deploymentRepository.split("::", 3); //$NON-NLS-1$
if(repoBits.length != 3) {
throw new IllegalArgumentException("Unexpected repository format: " + deploymentRepository);
throw new IllegalArgumentException(MessageFormat.format(Messages.getString("DeployMavenizedBundlesMojo.unexpectedRepositoryFormat"), deploymentRepository)); //$NON-NLS-1$
}
String repositoryId = repoBits[0];
String url = repoBits[2];
Expand All @@ -54,7 +55,7 @@ protected void processBundle(BundleInfo bundle, List<BundleInfo> bundles, Map<St
List<String> embedFiles = new ArrayList<>();
List<String> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
dominoDir = findDominoDir();
}
if(dominoDir == null || !Files.exists(dominoDir)) {
throw new MojoExecutionException("Unable to locate Domino directory; please specify using the `src` parameter");
throw new MojoExecutionException(Messages.getString("GenerateUpdateSiteMojo.unableToLocateDomino")); //$NON-NLS-1$
}
Path destDir = dest.toPath();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.openntf.p2.domino.updatesite;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class Messages {
private static final String BUNDLE_NAME = "org.openntf.p2.domino.updatesite.messages"; //$NON-NLS-1$

private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);

private Messages() {
}

public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

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;
Expand Down Expand Up @@ -124,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$
Expand Down Expand Up @@ -191,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$
Expand All @@ -208,7 +209,7 @@ public void run() {
}
}
} else {
System.out.println("Unable to locate xsp.http.bootstrap.jar - skipping bundle creation");
System.out.println(Messages.getString("GenerateUpdateSiteTask.0")); //$NON-NLS-1$
}
}

Expand All @@ -228,26 +229,26 @@ public void run() {
// *******************************************************************************
private Path checkDirectory(Path dir) {
if (!Files.exists(dir) || !Files.isDirectory(dir)) {
throw new RuntimeException("Directory does not exist: " + dir.toAbsolutePath());
throw new RuntimeException(Messages.getString("GenerateUpdateSiteTask.directoryNotExists") + dir.toAbsolutePath()); //$NON-NLS-1$
}
return dir;
}

private Path mkDir(Path dir) throws IOException {
if (Files.isRegularFile(dir)) {
throw new RuntimeException("Planned directory exists as a file: " + dir.toAbsolutePath());
throw new RuntimeException(Messages.getString("GenerateUpdateSiteTask.directoryExistsAsFile") + dir.toAbsolutePath()); //$NON-NLS-1$
}
Files.createDirectories(dir);
return dir;
}

private void copyArtifacts(Path sourceDir, Path destDir, Document eclipseArtifacts) throws Exception {
Files.list(sourceDir).forEach(artifact -> {
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);

if(eclipseArtifacts != null) {
if(eclipseArtifacts != null && destJar != null) {
downloadSource(destJar, destDir, eclipseArtifacts);
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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);
Expand All @@ -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$
}
}
}
Expand All @@ -402,7 +403,7 @@ private List<Path> 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;
}
Expand All @@ -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$
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit a4d6091

Please sign in to comment.