1
16package org.tp23.antinstaller.runtime.exe;
17
18import java.io.File;
19import java.io.IOException;
20
21import org.tp23.antinstaller.DefaultPropertiesFileRenderer;
22import org.tp23.antinstaller.ExplicitPropertiesFileRenderer;
23import org.tp23.antinstaller.InstallException;
24import org.tp23.antinstaller.InstallerContext;
25import org.tp23.antinstaller.PropertiesFileRenderer;
26import org.tp23.antinstaller.input.ResultContainer;
27
28
29
33public class PropertyPrinterFilter implements ExecuteFilter {
34
35
38 public void exec(InstallerContext ctx) throws InstallException {
39 ResultContainer results = ctx.getInstaller().getResultContainer();
40 results.setProperty(PropertiesFileRenderer.FILE_ROOT_PROPERTY,
41 ctx.getFileRoot().getAbsolutePath());
42
43 printProperties(ctx);
44
45 if(ctx.getInstaller().isVerbose()){
46 ctx.log("Properties printed:" + ctx.getFileRoot().getAbsolutePath()
47 + File.separatorChar + PropertiesFileRenderer.PROPERTIES_FILE_NAME);
48 }
49 }
50
55 private void printProperties(InstallerContext ctx) {
56 PropertiesFileRenderer propRenderer;
57 if(ctx.getInstaller().isVerbose()){
58 propRenderer = new ExplicitPropertiesFileRenderer();
59 }
60 else{
61 propRenderer = new DefaultPropertiesFileRenderer();
62 }
63 File currentDir = new File(".");
65 ctx.log("auto build supported: " + ctx.getInstaller().supportsAutoBuild());
66 boolean alreadyWritten = false;
67 if(currentDir.canWrite() && ctx.getInstaller().supportsAutoBuild()){
68 if(ctx.getInstaller().isVerbose()){
69 try {
70 ctx.log("Rendering properties in the current directory: " + currentDir.getCanonicalPath());
71 } catch (IOException e) {
72 }
74 }
75 propRenderer.renderProperties(ctx, currentDir);
76 alreadyWritten = true;
77 }
78 if( ! currentDir.equals(ctx.getFileRoot()) || !alreadyWritten){
79 propRenderer.renderProperties(ctx, ctx.getFileRoot());
80 }
81 }
82
83}
84