1 package com.atlassian.maven.plugins.amps.product;
2
3 import com.atlassian.maven.plugins.amps.MavenGoals;
4 import com.atlassian.maven.plugins.amps.Product;
5 import com.atlassian.maven.plugins.amps.ProductArtifact;
6 import com.atlassian.maven.plugins.amps.util.ConfigFileUtils;
7 import org.apache.maven.plugin.MojoExecutionException;
8 import org.apache.maven.project.MavenProject;
9
10 import java.io.File;
11 import java.util.*;
12
13 public class BambooProductHandler extends AbstractWebappProductHandler
14 {
15 public BambooProductHandler(MavenProject project, MavenGoals goals)
16 {
17 super(project, goals, new BambooPluginProvider());
18 }
19
20 public String getId()
21 {
22 return "bamboo";
23 }
24
25 public ProductArtifact getArtifact()
26 {
27 return new ProductArtifact("com.atlassian.bamboo", "atlassian-bamboo-web-app", "RELEASE");
28 }
29
30 protected Collection<ProductArtifact> getSalArtifacts(String salVersion)
31 {
32 return Arrays.asList(
33 new ProductArtifact("com.atlassian.sal", "sal-api", salVersion),
34 new ProductArtifact("com.atlassian.sal", "sal-bamboo-plugin", salVersion));
35 }
36
37 public ProductArtifact getTestResourcesArtifact()
38 {
39 return new ProductArtifact("com.atlassian.bamboo.plugins", "bamboo-plugin-test-resources", "LATEST");
40 }
41
42 public int getDefaultHttpPort()
43 {
44 return 6990;
45 }
46
47 public Map<String, String> getSystemProperties(Product ctx)
48 {
49 return Collections.singletonMap("bamboo.home", getHomeDirectory(ctx).getPath());
50 }
51
52 @Override
53 public File getUserInstalledPluginsDirectory(final File webappDir, final File homeDir)
54 {
55 return new File(homeDir, "plugins");
56 }
57
58 public List<ProductArtifact> getExtraContainerDependencies()
59 {
60 return Collections.emptyList();
61 }
62
63 public String getBundledPluginPath(Product ctx)
64 {
65 return "WEB-INF/classes/atlassian-bundled-plugins.zip";
66 }
67
68 public void processHomeDirectory(final Product ctx, final File homeDir) throws MojoExecutionException
69 {
70 ConfigFileUtils.replace(new File(homeDir, "bamboo.cfg.xml"), "@project-dir@", homeDir.getParent());
71 ConfigFileUtils.replace(new File(homeDir, "bamboo.cfg.xml"), "/bamboo-home/", "/home/");
72 ConfigFileUtils.replace(new File(homeDir, "bamboo.cfg.xml"), "${bambooHome}", homeDir.getAbsolutePath());
73
74 ConfigFileUtils.replaceAll(new File(homeDir, "/xml-data/configuration/administration.xml"),
75 "http://(?:[^:]+|\\[.+]):8085", "http://" + ctx.getServer() + ":" + ctx.getHttpPort() + "/" + ctx.getContextPath().replaceAll("^/|/$", ""));
76 }
77
78 public List<ProductArtifact> getDefaultLibPlugins()
79 {
80 return Collections.emptyList();
81 }
82
83 public List<ProductArtifact> getDefaultBundledPlugins()
84 {
85 return Collections.emptyList();
86 }
87
88 private static class BambooPluginProvider extends AbstractPluginProvider
89 {
90
91 @Override
92 protected Collection<ProductArtifact> getSalArtifacts(String salVersion)
93 {
94 return Arrays.asList(
95 new ProductArtifact("com.atlassian.sal", "sal-api", salVersion),
96 new ProductArtifact("com.atlassian.sal", "sal-bamboo-plugin", salVersion));
97 }
98
99 }
100 }