Revision 40968 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.prov/org.gvsig.installer.prov.plugin/src/main/java/org/gvsig/installer/prov/plugin/execution/PluginInstallerExecutionProvider.java
PluginInstallerExecutionProvider.java | ||
---|---|---|
34 | 34 |
import java.io.IOException; |
35 | 35 |
import java.io.InputStream; |
36 | 36 |
|
37 |
import com.sardak.antform.AntForm; |
|
38 |
import com.sardak.antform.AntMenu; |
|
39 |
|
|
40 | 37 |
import org.apache.tools.ant.Project; |
41 | 38 |
import org.apache.tools.ant.ProjectHelper; |
42 | 39 |
import org.gvsig.installer.lib.api.PackageInfo; |
... | ... | |
50 | 47 |
import org.slf4j.Logger; |
51 | 48 |
import org.slf4j.LoggerFactory; |
52 | 49 |
|
50 |
import com.sardak.antform.AntForm; |
|
51 |
import com.sardak.antform.AntMenu; |
|
52 |
|
|
53 | 53 |
/** |
54 | 54 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
55 | 55 |
*/ |
... | ... | |
110 | 110 |
|
111 | 111 |
} catch (Exception e) { |
112 | 112 |
try { |
113 |
logger.warn("Can install package '"+packageInfo.getCode()+"'.", e); |
|
113 | 114 |
// if there is an exception, installLater is called |
114 | 115 |
installLater(applicationDirectory, inputStream, packageInfo); |
115 | 116 |
} catch (IOException e1) { |
... | ... | |
128 | 129 |
InputStream inputStream, PackageInfo packageInfo) |
129 | 130 |
throws InstallPackageServiceException, IOException { |
130 | 131 |
|
131 |
logger.info("putting off the installation of package '"+packageInfo.getCode()+"'.");
|
|
132 |
logger.info("Delayed the package installation ("+packageInfo.getCode()+").");
|
|
132 | 133 |
this.applicationDirectory = applicationDirectory; |
133 | 134 |
|
134 | 135 |
File updateDirectory = new File(applicationDirectory + File.separator |
135 | 136 |
+ "update"); |
136 | 137 |
|
137 | 138 |
if (!updateDirectory.exists()) { |
138 |
updateDirectory.mkdir();
|
|
139 |
forceMkdir(updateDirectory);
|
|
139 | 140 |
} |
140 | 141 |
|
141 | 142 |
File filesDirectory = new File(updateDirectory + File.separator |
142 | 143 |
+ "files"); |
143 | 144 |
if (!filesDirectory.exists()) { |
144 |
filesDirectory.mkdir();
|
|
145 |
forceMkdir(filesDirectory);
|
|
145 | 146 |
} |
146 | 147 |
|
147 | 148 |
File scriptsFile = new File(updateDirectory + File.separator |
... | ... | |
162 | 163 |
|
163 | 164 |
if (antFile.exists()) { |
164 | 165 |
if (!scriptsFile.exists()) { |
166 |
forceMkdir(scriptsFile); |
|
165 | 167 |
scriptsFile.createNewFile(); |
166 | 168 |
} |
167 | 169 |
FileWriter writer = new FileWriter(scriptsFile, true); |
... | ... | |
173 | 175 |
|
174 | 176 |
} |
175 | 177 |
|
178 |
private void forceMkdir(File file) throws IOException { |
|
179 |
if( file.isDirectory() ) { |
|
180 |
org.apache.commons.io.FileUtils.forceMkdir(file); |
|
181 |
} else { |
|
182 |
org.apache.commons.io.FileUtils.forceMkdir(file.getParentFile()); |
|
183 |
} |
|
184 |
} |
|
185 |
|
|
176 | 186 |
private void executeAntFile(File file) { |
177 |
Project p = new Project(); |
|
178 |
p.setUserProperty("ant.file", file.getAbsolutePath()); |
|
179 |
p.setUserProperty("gvsig_dir", applicationDirectory.getAbsolutePath()); |
|
180 |
p.setUserProperty("extensions_dir", pluginsDirectory.getAbsolutePath()); |
|
181 |
p.setBaseDir(file.getParentFile()); |
|
182 |
p.addTaskDefinition("antform", AntForm.class); |
|
183 |
p.addTaskDefinition("antmenu", AntMenu.class); |
|
184 |
p.init(); |
|
185 |
ProjectHelper helper = ProjectHelper.getProjectHelper(); |
|
186 |
p.addReference("ant.projectHelper", helper); |
|
187 |
helper.parse(p, file); |
|
188 |
p.executeTarget(p.getDefaultTarget()); |
|
187 |
logger.info("Running install script '"+file.getAbsolutePath()+"'."); |
|
188 |
try { |
|
189 |
Project p = new Project(); |
|
190 |
p.setUserProperty("ant.file", file.getAbsolutePath()); |
|
191 |
p.setUserProperty("gvsig_dir", applicationDirectory.getAbsolutePath()); |
|
192 |
p.setUserProperty("extensions_dir", pluginsDirectory.getAbsolutePath()); |
|
193 |
p.setBaseDir(file.getParentFile()); |
|
194 |
p.addTaskDefinition("antform", AntForm.class); |
|
195 |
p.addTaskDefinition("antmenu", AntMenu.class); |
|
196 |
p.init(); |
|
197 |
ProjectHelper helper = ProjectHelper.getProjectHelper(); |
|
198 |
p.addReference("ant.projectHelper", helper); |
|
199 |
helper.parse(p, file); |
|
200 |
p.executeTarget(p.getDefaultTarget()); |
|
201 |
} catch(Exception ex) { |
|
202 |
logger.warn("Problems executing installation script.", ex); |
|
203 |
} |
|
189 | 204 |
} |
190 | 205 |
|
191 | 206 |
private boolean deleteDir(File dir) { |
Also available in: Unified diff