2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.maven
;
21 import java
.util
.Properties
;
22 import java
.util
.UUID
;
24 import org
.apache
.commons
.logging
.Log
;
25 import org
.apache
.commons
.logging
.LogFactory
;
26 import org
.argeo
.slc
.SlcException
;
27 import org
.argeo
.slc
.deploy
.DeployEnvironment
;
29 public abstract class MavenDeployEnvironment
implements DeployEnvironment
{
30 private static final Log log
= LogFactory
31 .getLog(MavenDeployEnvironment
.class);
32 private MavenManager mavenManager
;
34 public void unpackTo(Object packg
, File targetLocation
,
35 Map
<String
, String
> filter
) {
36 File packageLocation
=null;
38 String removeRootDir
= "enabled";
39 // if (packg instanceof MavenFile) {
40 // packageLocation = mavenManager
41 // .getPackageLocation((MavenFile) packg);
42 // type = ((MavenFile) packg).getType();
44 if (packg
instanceof File
) {
45 packageLocation
= (File
) packg
;
46 // TODO: type based on extension
48 throw new SlcException("Unrecognized package type "
51 if (log
.isDebugEnabled()) {
52 log
.debug("Unpack " + packageLocation
+ " of type " + type
+ " to "
57 File tempDir
= new File("/tmp/" + UUID
.randomUUID().toString());
59 targetLocation
.mkdirs();
60 Properties props
= new Properties();
61 props
.setProperty("dest", targetLocation
.getAbsolutePath());
62 props
.setProperty("src", packageLocation
.getAbsolutePath());
63 props
.setProperty("tempDir", tempDir
.getAbsolutePath());
64 props
.setProperty("removeRootDir", removeRootDir
);
66 URL antUrl
= getClass().getClassLoader().getResource(
67 "org/argeo/slc/support/deploy/ant/build.xml");
69 // if (type == null || type.equals("zip")) {
70 // new AntRunner(antUrl, "deployZip", props).run();
71 // } else if (type.equals("tar.gz")) {
72 // new AntRunner(antUrl, "deployTarGz", props).run();
74 // throw new SlcException("Unknow package type " + type);
76 throw new SlcException("Not implemented.");
77 } catch (SlcException e
) {
79 } catch (Exception e
) {
80 throw new SlcException("Cannot unpack package " + packg
+ " to "
85 public void setMavenManager(MavenManager mavenManager
) {
86 this.mavenManager
= mavenManager
;