1 package com.atlassian.maven.plugins.amps.product;
2
3 import com.atlassian.maven.plugins.amps.MavenContext;
4 import com.atlassian.maven.plugins.amps.MavenGoals;
5 import com.atlassian.maven.plugins.amps.Product;
6 import com.atlassian.maven.plugins.amps.ProductArtifact;
7 import com.atlassian.maven.plugins.amps.util.ConfigFileUtils.Replacement;
8 import org.apache.commons.io.FileUtils;
9 import org.apache.maven.plugin.MojoExecutionException;
10
11 import java.io.File;
12 import java.io.IOException;
13 import java.util.*;
14
15 public class StashProductHandler extends AbstractWebappProductHandler
16 {
17 public StashProductHandler(final MavenContext context, final MavenGoals goals)
18 {
19 super(context, goals, new StashPluginProvider());
20 }
21
22 public String getId()
23 {
24 return ProductHandlerFactory.STASH;
25 }
26
27 @Override
28 public ProductArtifact getArtifact()
29 {
30 return new ProductArtifact("com.atlassian.stash", "stash-webapp");
31 }
32
33 @Override
34 public ProductArtifact getTestResourcesArtifact()
35 {
36 return new ProductArtifact("com.atlassian.stash", "stash-plugin-test-resources");
37 }
38
39 public int getDefaultHttpPort()
40 {
41 return 7990;
42 }
43
44
45
46
47
48
49 @Override
50 public Map<String, String> getSystemProperties(final Product ctx)
51 {
52 return new HashMap<String, String>()
53 {
54 {
55 put("stash.home", fixSlashes(getHomeDirectory(ctx).getPath()));
56
57 String baseUrl = MavenGoals.getBaseUrl(ctx, ctx.getHttpPort());
58 put("baseurl", baseUrl);
59 put("baseurl.display", baseUrl);
60 }
61 };
62 }
63
64 private static String fixSlashes(final String path)
65 {
66 return path.replaceAll("\\\\", "/");
67 }
68
69 @Override
70 public File getUserInstalledPluginsDirectory(final File webappDir, final File homeDir)
71 {
72 return new File(new File(homeDir, "plugins"), "installed-plugins");
73 }
74
75 @Override
76 public List<ProductArtifact> getExtraContainerDependencies()
77 {
78 return Collections.emptyList();
79 }
80
81 @Override
82 public String getBundledPluginPath(Product ctx)
83 {
84 String bundledPluginPluginsPath = "WEB-INF/classes/stash-bundled-plugins.zip";
85 return bundledPluginPluginsPath;
86 }
87
88 @Override
89 public List<Replacement> getReplacements(Product ctx)
90 {
91 List<Replacement> replacements = super.getReplacements(ctx);
92 return replacements;
93 }
94
95 @Override
96 public List<File> getConfigFiles(Product product, File homeDir)
97 {
98 List<File> configFiles = super.getConfigFiles(product, homeDir);
99 configFiles.add(new File(homeDir, "data/db.log"));
100 configFiles.add(new File(homeDir, "data/db.script"));
101 configFiles.add(new File(homeDir, "data/db.properties"));
102 return configFiles;
103 }
104
105 @Override
106 public List<ProductArtifact> getDefaultLibPlugins()
107 {
108 return Collections.emptyList();
109 }
110
111 @Override
112 public List<ProductArtifact> getDefaultBundledPlugins()
113 {
114 return Collections.emptyList();
115 }
116
117 private static class StashPluginProvider extends AbstractPluginProvider
118 {
119
120 @Override
121 protected Collection<ProductArtifact> getSalArtifacts(String salVersion)
122 {
123 return Collections.emptyList();
124 }
125 }
126
127 @Override
128 public void cleanupProductHomeForZip(Product product, File snapshotDir) throws MojoExecutionException, IOException
129 {
130 super.cleanupProductHomeForZip(product, snapshotDir);
131 FileUtils.deleteQuietly(new File(snapshotDir, "log/atlassian-stash.log"));
132 FileUtils.deleteQuietly(new File(snapshotDir, ".osgi-cache"));
133 }
134
135
136 }