Examples of XMLProject


Examples of net.sourceforge.temply.xmlbinding.XMLProject

        File projectFile = new File(baseDir, "project.xml");

        log.info("Parsing project " + projectFile);
        FileReader reader = new FileReader(projectFile);
        XMLProject xmlProject = (XMLProject) unmarshaller.unmarshal(reader);

        if (xmlProject.getParent() != null) {
            File parentDir = new File(baseDir, xmlProject.getParent());
            _parent = new Project(parentDir);
        } else {
            _parent = null;
        }
               
        File scriptsFile = new File(baseDir, "scripts");

        _scripts = new ArrayList<String>();

        _scriptURLS = new ArrayList<URL>();
        if (scriptsFile.exists()) {
            String[] scripts = scriptsFile.list(new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".groovy");
                }
            });
           
            if (scripts != null) {
                _scripts.addAll(Arrays.asList(scripts));
                _scriptURLS.add(scriptsFile.toURI().toURL());
            }
        }
       
        if (_parent != null) {
            _scripts.addAll(_parent.getScripts());
            _scriptURLS.addAll(_parent.getScriptURLS());
        }
       
        _gse = new GroovyScriptEngine(_scriptURLS.toArray(new URL[0]),
                new ScriptClassLoader(Thread.currentThread()
                        .getContextClassLoader()));
       
        _properties = new Properties();
       
        File propertiesFile = new File(baseDir, "temply.properties");
       
        if (propertiesFile.exists()) {
            FileInputStream is = new FileInputStream(propertiesFile);
            try {
                _properties.load(is);
            } finally {
                is.close();
            }
        }
       
        if (_parent != null) {
            _properties.putAll(_parent.getProperties());
        }
       
        _repository = new Repository(baseDir);
        if (_parent != null) {
            _repository.addRules(_parent.getRepository().getRules());
            _repository.addFunctions(_parent.getRepository().getFunctions());
        }
       
        _templates = new ArrayList<Template>();

        for (XMLTemplate xmlTemplate : xmlProject.getXMLTemplate()) {
            Template template = new Template(xmlTemplate.getName(), new File(
                    baseDir, xmlTemplate.getFile()));
            for (XMLDestination xmlDestination : xmlTemplate.getXMLDestination()) {
                Destination destination = new Destination(xmlDestination);
                template.add(destination);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.