diff --git a/0001-Fix-installer-plugin-loading.patch b/0001-Fix-installer-plugin-loading.patch index b246146..2acf3fd 100644 --- a/0001-Fix-installer-plugin-loading.patch +++ b/0001-Fix-installer-plugin-loading.patch @@ -1,19 +1,19 @@ -From 8174ce738f5a8f93c9541b42fc257d21c687dcb3 Mon Sep 17 00:00:00 2001 +From 0fd7b0d19bd96456292585e883e3ba2ebbaf579b Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Wed, 21 Jun 2017 10:21:10 +0200 Subject: [PATCH] Fix installer plugin loading --- - .../install/impl/ArtifactInstallerFactory.java | 87 ++++++-- + .../install/impl/ArtifactInstallerFactory.java | 97 ++++++-- .../tools/install/impl/IsolatedClassRealm.java | 245 +++++++++++++++++++++ - 2 files changed, 310 insertions(+), 22 deletions(-) + 2 files changed, 320 insertions(+), 22 deletions(-) create mode 100644 xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/IsolatedClassRealm.java diff --git a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/ArtifactInstallerFactory.java b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/ArtifactInstallerFactory.java -index 7a80571..5223ca2 100644 +index 7a80571..e6a9a2d 100644 --- a/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/ArtifactInstallerFactory.java +++ b/xmvn-tools/xmvn-install/src/main/java/org/fedoraproject/xmvn/tools/install/impl/ArtifactInstallerFactory.java -@@ -15,8 +15,15 @@ +@@ -15,8 +15,17 @@ */ package org.fedoraproject.xmvn.tools.install.impl; @@ -21,6 +21,8 @@ index 7a80571..5223ca2 100644 +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; ++import java.nio.file.Files; ++import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Arrays; -import java.util.Collection; @@ -30,7 +32,7 @@ index 7a80571..5223ca2 100644 import java.util.Properties; import org.slf4j.Logger; -@@ -35,49 +42,85 @@ class ArtifactInstallerFactory +@@ -35,49 +44,93 @@ class ArtifactInstallerFactory private final ArtifactInstaller defaultArtifactInstaller; @@ -51,7 +53,7 @@ index 7a80571..5223ca2 100644 { - return (ArtifactInstaller) ArtifactInstallerFactory.class.getClassLoader().loadClass( className ).newInstance(); + String resourceName = ArtifactInstaller.class.getCanonicalName() + "/" + type; -+ InputStream resourceStream = pluginRealm.getResourceAsStream( resourceName ); ++ InputStream resourceStream = pluginRealm != null ? pluginRealm.getResourceAsStream( resourceName ) : null; + if ( resourceStream == null ) + { + logger.debug( "No XMvn Installer plugin found for packaging type {}", type ); @@ -89,10 +91,18 @@ index 7a80571..5223ca2 100644 - // FIXME Don't hardcode plugin class name - eclipseArtifactInstaller = loadPlugin( "org.fedoraproject.p2.xmvn.EclipseArtifactInstaller" ); + -+ ClassLoader parentClassLoader = ArtifactInstallerFactory.class.getClassLoader(); -+ pluginRealm = new IsolatedClassRealm( parentClassLoader ); -+ pluginRealm.addJarDirectory( Paths.get( "/usr/share/xmvn/lib/installer" ) ); -+ PLUGIN_IMPORTS.forEach( pluginRealm::importPackage ); ++ Path pluginDir = Paths.get( "/usr/share/xmvn/lib/installer" ); ++ if ( Files.isDirectory( pluginDir ) ) ++ { ++ ClassLoader parentClassLoader = ArtifactInstallerFactory.class.getClassLoader(); ++ pluginRealm = new IsolatedClassRealm( parentClassLoader ); ++ pluginRealm.addJarDirectory( pluginDir ); ++ PLUGIN_IMPORTS.forEach( pluginRealm::importPackage ); ++ } ++ else ++ { ++ pluginRealm = null; ++ } } /** diff --git a/xmvn.spec b/xmvn.spec index 0a1a407..798b222 100644 --- a/xmvn.spec +++ b/xmvn.spec @@ -10,7 +10,7 @@ Name: xmvn Version: 3.0.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Local Extensions for Apache Maven License: ASL 2.0 URL: https://fedora-java.github.io/xmvn/ @@ -344,6 +344,9 @@ cp -P ${maven_home}/bin/m2.conf %{buildroot}%{_datadir}/%{name}/bin/ %doc LICENSE NOTICE %changelog +* Wed Jun 21 2017 Mikolaj Izdebski - 3.0.0-4 +- Fix installer crash when plugin directory is missing + * Wed Jun 21 2017 Michael Simacek - 3.0.0-3 - Include lib directories for now