PageRenderTime 28ms CodeModel.GetById 16ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/maven-amps-plugin/src/main/java/com/atlassian/maven/plugins/amps/product/studio/StudioFeCruProductHandler.java

https://bitbucket.org/mmeinhold/amps
Java | 99 lines | 73 code | 18 blank | 8 comment | 0 complexity | 8ebcf9eada5c55997e763797c00e3821 MD5 | raw file
 1
 2package com.atlassian.maven.plugins.amps.product.studio;
 3
 4import static com.atlassian.maven.plugins.amps.product.ProductHandlerFactory.STUDIO_FECRU;
 5import static org.apache.commons.io.FileUtils.copyDirectory;
 6
 7import java.io.File;
 8import java.io.IOException;
 9import java.util.HashMap;
10import java.util.List;
11import java.util.Map;
12
13import org.apache.maven.plugin.MojoExecutionException;
14import org.apache.tools.ant.taskdefs.Java;
15
16import com.atlassian.maven.plugins.amps.MavenContext;
17import com.atlassian.maven.plugins.amps.MavenGoals;
18import com.atlassian.maven.plugins.amps.Product;
19import com.atlassian.maven.plugins.amps.ProductArtifact;
20import com.atlassian.maven.plugins.amps.product.FeCruProductHandler;
21import com.atlassian.maven.plugins.amps.util.ConfigFileUtils.Replacement;
22
23/**
24 * Handler for Studio-FeCru
25 * @since 3.6
26 */
27public class StudioFeCruProductHandler extends FeCruProductHandler implements StudioComponentProductHandler
28{
29
30    public StudioFeCruProductHandler(MavenContext context, MavenGoals goals)
31    {
32        super(context, goals);
33    }
34
35    @Override
36    public String getId()
37    {
38        return STUDIO_FECRU;
39    }
40
41    @Override
42    protected ProductArtifact getArtifact()
43    {
44        return new ProductArtifact("com.atlassian.studio", "studio-fisheye", "RELEASE");
45    }
46
47    @Override
48    public Map<String, String> getSystemProperties(Product product)
49    {
50        Map<String, String> properties = new HashMap<String, String>(super.getSystemProperties(product));
51
52        properties.put("fisheye.dev.mode", "true");
53
54        // We also add common studio system properties
55        properties.putAll(product.getStudioProperties().getSystemProperties());
56
57
58        return properties;
59    }
60
61    protected void extractProductHomeData(File productHomeData, File homeDir, Product ctx)
62            throws MojoExecutionException
63    {
64        try
65        {
66            copyDirectory(productHomeData, homeDir);
67        }
68        catch (IOException e)
69        {
70            throw new MojoExecutionException(String.format("Can't copy Fisheye's home directory from %s to %s", productHomeData.getAbsolutePath(),
71                    homeDir.getAbsolutePath()));
72        }
73    }
74
75    @Override
76    public List<Replacement> getReplacements(Product ctx)
77    {
78        List<Replacement> replacements = super.getReplacements(ctx);
79        replacements.add(new Replacement("%TEST-CONTROL-BIND%", String.valueOf(controlPort(ctx.getHttpPort()))));
80        replacements.add(new Replacement("%TEST-HTTP-BIND%", String.valueOf(this.getDefaultHttpPort())));
81        return replacements;
82    }
83
84    @Override
85    protected void customiseInstance(Product ctx, File homeDir, File explodedWarDir) throws MojoExecutionException
86    {
87        // Note: this config.xml is in the War.
88        StudioProductHandler.addProductHandlerOverrides(log, ctx, homeDir, explodedWarDir, "config.xml");
89    }
90
91    @Override
92    protected void addOverridesToJavaTask(final Product ctx, Java java)
93    {
94        // Note: FeCru doesn't support asynchronous startup, because setSpawn(true) returns an error
95        // (output and timeout are forbidden).
96        java.setFork(true);
97        java.setDir(getAppDirectory(ctx));
98    }
99}