use of org.walkmod.conf.entities.impl.PluginConfigImpl in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testRemovePlugin.
@Test
public void testRemovePlugin() throws Exception {
List<String> list = new LinkedList<String>();
list.add("org.walkmod:javalang");
File file = new File("src/test/resources/yaml/removePlugin.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
String input = "plugins:\n";
input += "- \"org.walkmod:imports-cleaner:2.0\"";
FileUtils.write(file, input);
try {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
PluginConfig pc = new PluginConfigImpl();
pc.setGroupId("org.walkmod");
pc.setArtifactId("imports-cleaner");
provider.removePluginConfig(pc, false);
String output = FileUtils.readFileToString(file);
System.out.println(output);
Assert.assertTrue(!output.contains("imports-cleaner"));
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.conf.entities.impl.PluginConfigImpl in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddPlugin.
@Test
public void testAddPlugin() throws Exception {
File file = new File("src/test/resources/yaml/addplugin.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
FileUtils.write(file, "");
try {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
PluginConfig pluginCfg = new PluginConfigImpl();
pluginCfg.setGroupId("org.walkmod");
pluginCfg.setArtifactId("myplugin");
pluginCfg.setVersion("1.0");
provider.addPluginConfig(pluginCfg, false);
String output = FileUtils.readFileToString(file);
String desiredOutput = "plugins:\n";
desiredOutput += "- \"org.walkmod:myplugin:1.0\"";
Assert.assertEquals(desiredOutput, output);
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.conf.entities.impl.PluginConfigImpl in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddPluginRecursively.
@Test
public void testAddPluginRecursively() throws Exception {
File dir = new File("src/test/resources/multimoduleyaml");
dir.mkdirs();
File module0 = new File(dir, "module0");
module0.mkdir();
File moduleCfg = new File(module0, "walkmod.yml");
File file = new File(dir, "walkmod.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
try {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.addModules(Arrays.asList("module0"));
PluginConfig pluginCfg = new PluginConfigImpl();
pluginCfg.setGroupId("org.walkmod");
pluginCfg.setArtifactId("myplugin");
pluginCfg.setVersion("1.0");
provider.addPluginConfig(pluginCfg, true);
String output = FileUtils.readFileToString(moduleCfg);
String desiredOutput = "plugins:\n";
desiredOutput += "- \"org.walkmod:myplugin:1.0\"";
Assert.assertEquals(desiredOutput, output);
} finally {
if (dir.exists()) {
FileUtils.deleteDirectory(dir);
}
}
}
use of org.walkmod.conf.entities.impl.PluginConfigImpl in project walkmod-core by walkmod.
the class AddPluginCommand method build.
public List<PluginConfig> build() {
List<PluginConfig> result = new LinkedList<PluginConfig>();
for (String plugin : plugins) {
PluginConfig pluginConfig = new PluginConfigImpl(plugin);
result.add(pluginConfig);
}
return result;
}
use of org.walkmod.conf.entities.impl.PluginConfigImpl in project walkmod-core by walkmod.
the class PluginsConfigurationProvider method load.
@Override
public void load() throws ConfigurationException {
Collection<PluginConfig> plugins = configuration.getPlugins();
if (plugins == null) {
plugins = new LinkedList<PluginConfig>();
configuration.setPlugins(plugins);
}
Element rootElement = document.getDocumentElement();
NodeList childNodes = rootElement.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node childNode = childNodes.item(i);
if ((childNode.getNodeType() == Node.ELEMENT_NODE) && "plugin".equals(childNode.getNodeName())) {
Element paramElement = (Element) childNode;
String groupId = paramElement.getAttribute("groupId");
String artifactId = paramElement.getAttribute("artifactId");
String version = paramElement.getAttribute("version");
PluginConfig defaultPlugin = new PluginConfigImpl();
defaultPlugin.setGroupId(groupId);
defaultPlugin.setArtifactId(artifactId);
defaultPlugin.setVersion(version);
plugins.add(defaultPlugin);
}
}
}
Aggregations