Search in sources :

Example 1 with InitializerConfig

use of org.walkmod.conf.entities.InitializerConfig in project walkmod-core by walkmod.

the class ConfigurationImpl method prepareInitializers.

@Override
public void prepareInitializers() {
    InitializerConfig init = null;
    File pom = new File("pom.xml").getAbsoluteFile();
    if (pom.exists()) {
        init = new InitializerConfigImpl();
        init.setType("maven-initializer");
    } else {
        File gradle = new File("settings.gradle");
        if (gradle.exists()) {
            init = new InitializerConfigImpl();
            init.setType("gradle-initializer");
        } else {
            gradle = new File("build.gradle");
            if (gradle.exists()) {
                init = new InitializerConfigImpl();
                init.setType("gradle-initializer");
            }
        }
    }
    if (init != null) {
        List<InitializerConfig> list = getInitializers();
        if (list == null) {
            list = new LinkedList<InitializerConfig>();
        }
        list.add(init);
        setInitializers(list);
    }
}
Also used : InitializerConfig(org.walkmod.conf.entities.InitializerConfig) File(java.io.File)

Example 2 with InitializerConfig

use of org.walkmod.conf.entities.InitializerConfig in project walkmod-core by walkmod.

the class ConfigurationImpl method preparePlugins.

@Override
public void preparePlugins() {
    Collection<PluginConfig> pluginCfg = getPlugins();
    HashSet<String> plugins = new HashSet<String>();
    HashSet<String> previousPlugins = new HashSet<String>();
    if (pluginCfg == null || pluginCfg.isEmpty()) {
        pluginCfg = new LinkedList<PluginConfig>();
    } else {
        for (PluginConfig pc : pluginCfg) {
            previousPlugins.add(pc.getGroupId() + ":" + pc.getArtifactId());
        }
    }
    Collection<ChainConfig> chains = getChainConfigs();
    if (chains != null) {
        Iterator<ChainConfig> it = chains.iterator();
        while (it.hasNext()) {
            ChainConfig cc = it.next();
            composeName(cc.getReaderConfig().getType(), plugins);
            composeName(cc.getWalkerConfig().getParserConfig().getType(), plugins);
            List<TransformationConfig> trans = cc.getWalkerConfig().getTransformations();
            if (trans != null) {
                for (TransformationConfig transformation : trans) {
                    String type = transformation.getType();
                    if (!type.equals("script") && !type.equals("template")) {
                        composeName(type, plugins);
                    }
                }
            }
            composeName(cc.getWriterConfig().getType(), plugins);
        }
    }
    Collection<ProviderConfig> providers = getProviderConfigurations();
    if (providers != null) {
        for (ProviderConfig provider : providers) {
            String type = provider.getType();
            composeName(type, plugins);
        }
    }
    Collection<InitializerConfig> initializers = getInitializers();
    if (initializers != null) {
        for (InitializerConfig initializer : initializers) {
            plugins.add(initializer.getPluginGroupId() + ":walkmod-" + initializer.getPluginArtifactId() + "-plugin");
        }
    }
    for (String id : plugins) {
        if (!previousPlugins.contains(id)) {
            String[] parts = id.split(":");
            PluginConfig cfg = new PluginConfigImpl();
            cfg.setGroupId(parts[0].trim());
            cfg.setArtifactId(parts[1].trim());
            cfg.setVersion("latest.integration");
            pluginCfg.add(cfg);
        }
    }
    setPlugins(pluginCfg);
}
Also used : ProviderConfig(org.walkmod.conf.entities.ProviderConfig) InitializerConfig(org.walkmod.conf.entities.InitializerConfig) TransformationConfig(org.walkmod.conf.entities.TransformationConfig) ChainConfig(org.walkmod.conf.entities.ChainConfig) PluginConfig(org.walkmod.conf.entities.PluginConfig) HashSet(java.util.HashSet)

Aggregations

InitializerConfig (org.walkmod.conf.entities.InitializerConfig)2 File (java.io.File)1 HashSet (java.util.HashSet)1 ChainConfig (org.walkmod.conf.entities.ChainConfig)1 PluginConfig (org.walkmod.conf.entities.PluginConfig)1 ProviderConfig (org.walkmod.conf.entities.ProviderConfig)1 TransformationConfig (org.walkmod.conf.entities.TransformationConfig)1