1 package com.atlassian.plugins.codegen.modules.common;
2
3 import com.atlassian.plugins.codegen.PluginProjectChangeset;
4 import com.atlassian.plugins.codegen.annotations.ConfluencePluginModuleCreator;
5 import com.atlassian.plugins.codegen.annotations.FeCruPluginModuleCreator;
6 import com.atlassian.plugins.codegen.annotations.JiraPluginModuleCreator;
7 import com.atlassian.plugins.codegen.annotations.RefAppPluginModuleCreator;
8 import com.atlassian.plugins.codegen.modules.AbstractPluginModuleCreator;
9
10 import org.apache.commons.io.FilenameUtils;
11
12 import static com.atlassian.plugins.codegen.modules.Dependencies.MOCKITO_TEST;
13
14
15
16
17 @RefAppPluginModuleCreator
18 @JiraPluginModuleCreator
19 @ConfluencePluginModuleCreator
20 @FeCruPluginModuleCreator
21 public class GadgetModuleCreator extends AbstractPluginModuleCreator<GadgetProperties>
22 {
23
24 public static final String MODULE_NAME = "Gadget Plugin Module";
25 private static final String TEMPLATE_PREFIX = "templates/common/gadget/";
26
27
28 private static final String GADGET_TEMPLATE = TEMPLATE_PREFIX + "gadget.xml.vtl";
29
30 private static final String PLUGIN_MODULE_TEMPLATE = TEMPLATE_PREFIX + "gadget-plugin.xml.vtl";
31
32 @Override
33 public PluginProjectChangeset createModule(GadgetProperties props) throws Exception
34 {
35 String gadgetLocation = props.getLocation();
36 String gadgetFilename = FilenameUtils.getName(gadgetLocation);
37 String gadgetPath = FilenameUtils.getPath(gadgetLocation);
38
39 return new PluginProjectChangeset()
40 .withDependencies(MOCKITO_TEST)
41 .with(createModule(props, PLUGIN_MODULE_TEMPLATE))
42 .with(createResource(props, gadgetPath, gadgetFilename, GADGET_TEMPLATE));
43 }
44
45 @Override
46 public String getModuleName()
47 {
48 return MODULE_NAME;
49 }
50 }