1 package org
.argeo
.slc
.maven
;
6 import java
.util
.Properties
;
9 import org
.apache
.commons
.logging
.Log
;
10 import org
.apache
.commons
.logging
.LogFactory
;
11 import org
.argeo
.slc
.SlcException
;
12 import org
.argeo
.slc
.deploy
.DeployEnvironment
;
14 public class MavenDeployEnvironment
implements DeployEnvironment
{
15 private static final Log log
= LogFactory
16 .getLog(MavenDeployEnvironment
.class);
17 private MavenManager mavenManager
;
19 public void unpackTo(Object packg
, File targetLocation
,
20 Map
<String
, String
> filter
) {
23 String removeRootDir
= "enabled";
24 if (packg
instanceof MavenFile
) {
25 packageLocation
= mavenManager
26 .getPackageLocation((MavenFile
) packg
);
27 type
= ((MavenFile
) packg
).getType();
28 } else if (packg
instanceof File
) {
29 packageLocation
= (File
) packg
;
30 // TODO: type based on extension
32 throw new SlcException("Unrecognized package type "
35 if (log
.isDebugEnabled()) {
36 log
.debug("Unpack " + packageLocation
+ " of type " + type
+ " to "
41 File tempDir
= new File("/tmp/" + UUID
.randomUUID().toString());
43 targetLocation
.mkdirs();
44 Properties props
= new Properties();
45 props
.setProperty("dest", targetLocation
.getAbsolutePath());
46 props
.setProperty("src", packageLocation
.getAbsolutePath());
47 props
.setProperty("tempDir", tempDir
.getAbsolutePath());
48 props
.setProperty("removeRootDir", removeRootDir
);
50 URL antUrl
= getClass().getClassLoader().getResource(
51 "org/argeo/slc/support/deploy/ant/build.xml");
53 // if (type == null || type.equals("zip")) {
54 // new AntRunner(antUrl, "deployZip", props).run();
55 // } else if (type.equals("tar.gz")) {
56 // new AntRunner(antUrl, "deployTarGz", props).run();
58 // throw new SlcException("Unknow package type " + type);
60 throw new SlcException("Not implemented.");
61 } catch (SlcException e
) {
63 } catch (Exception e
) {
64 throw new SlcException("Cannot unpack package " + packg
+ " to "
69 public void setMavenManager(MavenManager mavenManager
) {
70 this.mavenManager
= mavenManager
;