@Override
public void execute() throws BuildException {
if (name==null){
throw new BuildException("name not specified.");
}
if (output==null){
throw new BuildException("output directory is not specified.");
}
File fConfFile=null;
if (indexDir!=null){
File tempF=new File(indexDir,"bobo.spring");
if (tempF.exists() && tempF.isFile()){
fConfFile=tempF;
}
}
if (fConfFile==null && fieldConf!=null){
File tempF=new File(fieldConf);
if (tempF.exists() && tempF.isFile()){
fConfFile=tempF;
}
}
if (fConfFile==null){
throw new BuildException("Please provide field.xml location by either setting the indexDir or the fieldConf property.");
}
List<FacetHandler<?>> fConf=null;
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
ApplicationContext appCtx=null;
try{
appCtx=new FileSystemXmlApplicationContext("file:"+fConfFile.getAbsolutePath());
fConf = (List<FacetHandler<?>>)appCtx.getBean("handlers");
}
catch(Exception e){
throw new BuildException(e.getMessage(),e);
}
File baseDir=getProject().getBaseDir();
ArrayList<File> copyList=new ArrayList<File>(10);
copyList.add(new File(new File(baseDir,"webapp"),"bobobase.js"));
copyList.add(new File(new File(baseDir,"webapp"),"browse.js"));
copyList.add(new File(new File(baseDir,"webapp"),"style.css"));
copyList.add(new File(new File(baseDir,"webapp"),"json.js"));
copyList.add(new File(new File(baseDir,"webapp"),"widgets.js"));
copyList.add(new File(new File(baseDir,"webapp"),"remote.js"));
File outputDir=new File(new File(baseDir,output),name);
outputDir.mkdirs();
try{
Iterator<File> iter=copyList.iterator();
while(iter.hasNext()){
copyFile(iter.next(),outputDir);
}
}
catch(IOException e){
throw new BuildException(e.getMessage(),e);
}
try {
//writeWebXML(outputDir, indexDir);
writeApplicationJS(outputDir, fConf);
writeHTML(outputDir, fConf);
} catch (IOException e) {
throw new BuildException(e.getMessage(),e);
}
}