implement plugin uninstall method

This commit is contained in:
Sebastian Sdorra
2010-12-18 16:25:57 +01:00
parent 9dd3b0a3d1
commit 3dedf31dda
3 changed files with 126 additions and 43 deletions

View File

@@ -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 */