1 package com.atlassian.plugins.codegen.modules.common.moduletype;
2
3 import com.atlassian.plugins.codegen.PluginProjectChangeset;
4 import com.atlassian.plugins.codegen.annotations.BambooPluginModuleCreator;
5 import com.atlassian.plugins.codegen.annotations.ConfluencePluginModuleCreator;
6 import com.atlassian.plugins.codegen.annotations.CrowdPluginModuleCreator;
7 import com.atlassian.plugins.codegen.annotations.FeCruPluginModuleCreator;
8 import com.atlassian.plugins.codegen.annotations.JiraPluginModuleCreator;
9 import com.atlassian.plugins.codegen.annotations.RefAppPluginModuleCreator;
10 import com.atlassian.plugins.codegen.annotations.StashPluginModuleCreator;
11 import com.atlassian.plugins.codegen.modules.AbstractPluginModuleCreator;
12
13 import static com.atlassian.plugins.codegen.modules.Dependencies.MOCKITO_TEST;
14
15
16
17
18 @RefAppPluginModuleCreator
19 @JiraPluginModuleCreator
20 @ConfluencePluginModuleCreator
21 @BambooPluginModuleCreator
22 @FeCruPluginModuleCreator
23 @CrowdPluginModuleCreator
24 @StashPluginModuleCreator
25 public class ModuleTypeModuleCreator extends AbstractPluginModuleCreator<ModuleTypeProperties>
26 {
27 public static final String MODULE_NAME = "Module Type";
28 private static final String TEMPLATE_PREFIX = "templates/common/moduletype/";
29
30
31 private static final String CLASS_TEMPLATE = TEMPLATE_PREFIX + "ModuleType.java.vtl";
32 private static final String INTERFACE_TEMPLATE = TEMPLATE_PREFIX + "ModuleTypeInterface.java.vtl";
33
34
35 private static final String EXAMPLE_CLASS_TEMPLATE = TEMPLATE_PREFIX + "Example" + CLASS_TEMPLATE;
36
37 private static final String PLUGIN_MODULE_TEMPLATE = TEMPLATE_PREFIX + "module-type-plugin.xml.vtl";
38
39 @Override
40 public PluginProjectChangeset createModule(ModuleTypeProperties props) throws Exception
41 {
42 PluginProjectChangeset ret = new PluginProjectChangeset()
43 .with(MOCKITO_TEST)
44 .with(createModule(props, PLUGIN_MODULE_TEMPLATE));
45
46
47 if (props.includeExamples())
48 {
49 return ret.with(createClass(props, EXAMPLE_CLASS_TEMPLATE));
50 }
51 else
52 {
53 return ret.with(createClass(props, props.getInterfaceId(), INTERFACE_TEMPLATE))
54 .with(createClassAndTests(props, CLASS_TEMPLATE, GENERIC_TEST_TEMPLATE, GENERIC_TEST_TEMPLATE));
55 }
56 }
57
58 @Override
59 public String getModuleName()
60 {
61 return MODULE_NAME;
62 }
63 }