mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 14:05:44 +01:00
implement plugin uninstall method
This commit is contained in:
@@ -73,6 +73,7 @@ import java.io.File;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
@@ -193,10 +194,7 @@ public class AetherPluginHandler
|
||||
localRepositoryDirectory.getAbsolutePath().length()));
|
||||
}
|
||||
|
||||
Marshaller marshaller = jaxbContext.createMarshaller();
|
||||
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
marshaller.marshal(classpath, classpathFile);
|
||||
storeClasspath();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -205,6 +203,54 @@ public class AetherPluginHandler
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: remove dependencies and remove files
|
||||
*
|
||||
*
|
||||
* @param pluginPath
|
||||
*/
|
||||
public void uninstall(String pluginPath)
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
logger.info("try to uninstall plugin: {}", pluginPath);
|
||||
}
|
||||
|
||||
if (classpath != null)
|
||||
{
|
||||
synchronized (Classpath.class)
|
||||
{
|
||||
Iterator<String> iterator = classpath.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
String path = iterator.next();
|
||||
|
||||
if (pluginPath.contains(path))
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
logger.info("remove {} from classpath", path);
|
||||
}
|
||||
|
||||
iterator.remove();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
storeClasspath();
|
||||
}
|
||||
catch (JAXBException ex)
|
||||
{
|
||||
throw new PluginLoadException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -257,6 +303,20 @@ public class AetherPluginHandler
|
||||
return locator.getService(RepositorySystem.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @throws JAXBException
|
||||
*/
|
||||
private void storeClasspath() throws JAXBException
|
||||
{
|
||||
Marshaller marshaller = jaxbContext.createMarshaller();
|
||||
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
marshaller.marshal(classpath, classpathFile);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
Reference in New Issue
Block a user