diff --git a/x4o-core/src/main/java/org/x4o/xml/eld/xsd/X4OSchemaWriterExecutor.java b/x4o-core/src/main/java/org/x4o/xml/eld/xsd/X4OWriteLanguageSchemaExecutor.java similarity index 93% rename from x4o-core/src/main/java/org/x4o/xml/eld/xsd/X4OSchemaWriterExecutor.java rename to x4o-core/src/main/java/org/x4o/xml/eld/xsd/X4OWriteLanguageSchemaExecutor.java index 41ffcb5..4da0df0 100644 --- a/x4o-core/src/main/java/org/x4o/xml/eld/xsd/X4OSchemaWriterExecutor.java +++ b/x4o-core/src/main/java/org/x4o/xml/eld/xsd/X4OWriteLanguageSchemaExecutor.java @@ -39,14 +39,14 @@ import org.x4o.xml.io.X4OSchemaWriter; * @author Willem Cazander * @version 1.0 Aug 22, 2012 */ -public class X4OSchemaWriterExecutor { +public class X4OWriteLanguageSchemaExecutor { private String language = null; private String languageNamespaceUri = null; private File basePath; static public void main(String argu[]) { - X4OSchemaWriterExecutor languageSchema = new X4OSchemaWriterExecutor(); + X4OWriteLanguageSchemaExecutor languageSchema = new X4OWriteLanguageSchemaExecutor(); List arguList = Arrays.asList(argu); Iterator arguIterator = arguList.iterator(); boolean printStack = false; @@ -85,11 +85,7 @@ public class X4OSchemaWriterExecutor { languageSchema.execute(); } catch (ElementException e1) { e = e1; - } catch (InstantiationException e2) { - e = e2; - } catch (IllegalAccessException e3) { - e = e3; - } + } if (e!=null) { System.err.println("Error while schema writing: "+e.getMessage()); if (printStack) { @@ -102,7 +98,7 @@ public class X4OSchemaWriterExecutor { } } - public void execute() throws ElementException, InstantiationException, IllegalAccessException { + public void execute() throws ElementException { // Start xsd generator X4ODriver driver = X4ODriverManager.getX4ODriver(getLanguage()); X4OSchemaWriter xsd = driver.createSchemaWriter(driver.getLanguageVersionDefault()); diff --git a/x4o-core/src/test/java/org/x4o/xml/eld/EldSchemaTest.java b/x4o-core/src/test/java/org/x4o/xml/eld/xsd/X4OWriteLanguageSchemaExecutorTest.java similarity index 81% rename from x4o-core/src/test/java/org/x4o/xml/eld/EldSchemaTest.java rename to x4o-core/src/test/java/org/x4o/xml/eld/xsd/X4OWriteLanguageSchemaExecutorTest.java index aa59b3e..39be25a 100644 --- a/x4o-core/src/test/java/org/x4o/xml/eld/EldSchemaTest.java +++ b/x4o-core/src/test/java/org/x4o/xml/eld/xsd/X4OWriteLanguageSchemaExecutorTest.java @@ -21,11 +21,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.x4o.xml.eld; +package org.x4o.xml.eld.xsd; import java.io.File; -import org.x4o.xml.eld.xsd.X4OSchemaWriterExecutor; +import org.x4o.xml.eld.CelDriver; +import org.x4o.xml.eld.EldDriver; +import org.x4o.xml.eld.xsd.X4OWriteLanguageSchemaExecutor; import org.x4o.xml.test.swixml.SwiXmlDriver; import junit.framework.TestCase; @@ -36,7 +38,7 @@ import junit.framework.TestCase; * @author Willem Cazander * @version 1.0 Auh 16, 2012 */ -public class EldSchemaTest extends TestCase { +public class X4OWriteLanguageSchemaExecutorTest extends TestCase { private File getTempPath(String dir) throws Exception { File tempFile = File.createTempFile("test-path", ".tmp"); @@ -51,27 +53,27 @@ public class EldSchemaTest extends TestCase { } public void testEldSchema() throws Exception { - X4OSchemaWriterExecutor writer = new X4OSchemaWriterExecutor(); + X4OWriteLanguageSchemaExecutor writer = new X4OWriteLanguageSchemaExecutor(); writer.setBasePath(getTempPath("junit-xsd-eld")); writer.setLanguage(EldDriver.LANGUAGE_NAME); writer.execute(); } public void testEldCoreSchema() throws Exception { - X4OSchemaWriterExecutor writer = new X4OSchemaWriterExecutor(); + X4OWriteLanguageSchemaExecutor writer = new X4OWriteLanguageSchemaExecutor(); writer.setBasePath(getTempPath("junit-xsd-cel")); writer.setLanguage(CelDriver.LANGUAGE_NAME); writer.execute(); } public void testSwiXmlSchema() throws Exception { - X4OSchemaWriterExecutor writer = new X4OSchemaWriterExecutor(); + X4OWriteLanguageSchemaExecutor writer = new X4OWriteLanguageSchemaExecutor(); writer.setBasePath(getTempPath("junit-xsd-swixml2")); writer.setLanguage(SwiXmlDriver.LANGUAGE_NAME); writer.execute(); } public void testEldDocMain() throws Exception { - X4OSchemaWriterExecutor.main(new String[] {"-p",getTempPath("junit-xsd-main").getAbsolutePath(),"-l",EldDriver.LANGUAGE_NAME}); + X4OWriteLanguageSchemaExecutor.main(new String[] {"-p",getTempPath("junit-xsd-main").getAbsolutePath(),"-l",EldDriver.LANGUAGE_NAME}); } } diff --git a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/X4ODocWriterExecutor.java b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java similarity index 95% rename from x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/X4ODocWriterExecutor.java rename to x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java index b4c59ba..4c24659 100644 --- a/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/X4ODocWriterExecutor.java +++ b/x4o-elddoc/src/main/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutor.java @@ -34,19 +34,19 @@ import org.x4o.xml.element.ElementException; import org.x4o.xml.lang.X4OLanguageContext; /** - * X4OLanguageHtmlWriter is support class to write html documentation from the eld. + * X4OWriteLanguageDoc is support class to write html documentation from the eld. * * @author Willem Cazander * @version 1.0 Aug 22, 2012 */ -public class X4ODocWriterExecutor { +public class X4OWriteLanguageDocExecutor { private String language = null; private String languageVersion = null; private File basePath; static public void main(String argu[]) { - X4ODocWriterExecutor languageSchema = new X4ODocWriterExecutor(); + X4OWriteLanguageDocExecutor languageSchema = new X4OWriteLanguageDocExecutor(); List arguList = Arrays.asList(argu); Iterator arguIterator = arguList.iterator(); while (arguIterator.hasNext()) { diff --git a/x4o-elddoc/src/test/java/org/x4o/xml/eld/doc/EldDocTest.java b/x4o-elddoc/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java similarity index 84% rename from x4o-elddoc/src/test/java/org/x4o/xml/eld/doc/EldDocTest.java rename to x4o-elddoc/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java index 7332276..c9e9727 100644 --- a/x4o-elddoc/src/test/java/org/x4o/xml/eld/doc/EldDocTest.java +++ b/x4o-elddoc/src/test/java/org/x4o/xml/eld/doc/X4OWriteLanguageDocExecutorTest.java @@ -39,7 +39,7 @@ import junit.framework.TestCase; * @author Willem Cazander * @version 1.0 Aug 26, 2010 */ -public class EldDocTest extends TestCase { +public class X4OWriteLanguageDocExecutorTest extends TestCase { private File getTempPath(String dir) throws Exception { File tempFile = File.createTempFile("test-path", ".tmp"); @@ -54,28 +54,28 @@ public class EldDocTest extends TestCase { } public void testCelDoc() throws Exception { - X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); + X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor(); writer.setBasePath(getTempPath("junit-cel")); writer.setLanguage(CelDriver.LANGUAGE_NAME); writer.execute(); } public void testEldDoc() throws Exception { - X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); + X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor(); writer.setBasePath(getTempPath("junit-eld")); writer.setLanguage(EldDriver.LANGUAGE_NAME); writer.execute(); } public void testUnitDoc() throws Exception { - X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); + X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor(); writer.setBasePath(getTempPath("junit-test")); writer.setLanguage(TestDriver.LANGUAGE_NAME); writer.execute(); } public void testSwiXml2Doc() throws Exception { - X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); + X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor(); writer.setBasePath(getTempPath("junit-swixml2")); writer.setLanguage(SwiXmlDriver.LANGUAGE_NAME); writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2); @@ -83,7 +83,7 @@ public class EldDocTest extends TestCase { } public void testSwiXml3Doc() throws Exception { - X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); + X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor(); writer.setBasePath(getTempPath("junit-swixml3")); writer.setLanguage(SwiXmlDriver.LANGUAGE_NAME); writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3); @@ -92,6 +92,6 @@ public class EldDocTest extends TestCase { public void testEldDocMain() throws Exception { - X4ODocWriterExecutor.main(new String[] {"-p",getTempPath("junit-test-main").getAbsolutePath(),"-l",EldDriver.LANGUAGE_NAME}); + X4OWriteLanguageDocExecutor.main(new String[] {"-p",getTempPath("junit-test-main").getAbsolutePath(),"-l",EldDriver.LANGUAGE_NAME}); } } diff --git a/x4o-plugin/pom.xml b/x4o-plugin/pom.xml index d9e1bba..bd2085a 100644 --- a/x4o-plugin/pom.xml +++ b/x4o-plugin/pom.xml @@ -12,8 +12,7 @@ x4o-plugin x4o plugins for other applications - x4o-plugin-ant-schema - x4o-plugin-ant-elddoc + x4o-plugin-ant diff --git a/x4o-plugin/x4o-plugin-ant-schema/.project b/x4o-plugin/x4o-plugin-ant-schema/.project deleted file mode 100644 index b490cb1..0000000 --- a/x4o-plugin/x4o-plugin-ant-schema/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - x4o-plugin-ant-schema - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/x4o-plugin/x4o-plugin-ant-schema/pom.xml b/x4o-plugin/x4o-plugin-ant-schema/pom.xml deleted file mode 100644 index 3071bce..0000000 --- a/x4o-plugin/x4o-plugin-ant-schema/pom.xml +++ /dev/null @@ -1,141 +0,0 @@ - - 4.0.0 - - x4o-plugin - org.x4o.plugin - 0.8.5-SNAPSHOT - .. - - x4o-plugin-ant-schema - jar - x4o-plugin-ant-schema - Creates schema for languauge - - - org.x4o - x4o-core - ${project.version} - - - org.apache.ant - ant - ${ant.version} - - - org.apache.ant - ant-testutil - ${ant-testutil.version} - test - - - junit - junit - ${junit.version} - test - - - de.odysseus.juel - juel - ${juel.version} - - - org.x4o - x4o-core - ${project.version} - test-jar - test - - - xerces - xercesImpl - ${xerces.version} - test - - - - - - - org.apache.maven.plugins - maven-site-plugin - ${maven-site-plugin.version} - - ${project.basedir}/../../src/site-child - - - - - - - - update-schema-cel - - - - org.apache.maven.plugins - maven-antrun-plugin - ${maven-antrun-plugin.version} - - - update-schema-cel-ant - generate-resources - - - - - - - - - run - - - - - - org.x4o.plugin - x4o-plugin-ant-schema - ${project.version} - - - - - - - - update-schema-eld - - - - org.apache.maven.plugins - maven-antrun-plugin - ${maven-antrun-plugin.version} - - - update-schema-eld-ant - generate-resources - - - - - - - - - run - - - - - - org.x4o.plugin - x4o-plugin-ant-schema - ${project.version} - - - - - - - - \ No newline at end of file diff --git a/x4o-plugin/x4o-plugin-ant-schema/src/main/java/org/x4o/plugin/ant/eld/xsd/EldXsdWriterTask.java b/x4o-plugin/x4o-plugin-ant-schema/src/main/java/org/x4o/plugin/ant/eld/xsd/EldXsdWriterTask.java deleted file mode 100644 index addcafa..0000000 --- a/x4o-plugin/x4o-plugin-ant-schema/src/main/java/org/x4o/plugin/ant/eld/xsd/EldXsdWriterTask.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2004-2012, Willem Cazander - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.x4o.plugin.ant.eld.xsd; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.x4o.xml.eld.xsd.X4OSchemaWriterExecutor; -import org.x4o.xml.element.ElementException; - -/** - * SchemaWriterTask creates schema for language. - * - * @author Willem Cazander - * @version 1.0 Aug 23, 2012 - */ -public class EldXsdWriterTask extends Task { - - private String language = null; - private String nsuri = null; - private String destdir = null; - private boolean verbose = false; - private boolean failonerror = true; - - /** - * Executes the x4o eld schema task. - * @see org.apache.tools.ant.Task#execute() - */ - @Override - public void execute() throws BuildException { - try { - executeTask(); - } catch (BuildException e) { - if (isFailonerror()) { - throw e; - } else { - log(e.getMessage(), Project.MSG_WARN); - } - } - } - - private void executeTask() throws BuildException { - if (getLanguage()==null) { - throw new BuildException("langauge attribute is not set."); - } - if (getDestdir()==null) { - throw new BuildException("destdir attribute is not set."); - } - if (isVerbose()) { - log("Execute task from: "+getLocation()); - log("language: "+getLanguage()); - log("destdir: "+getDestdir()); - log("nsuri: "+getNsuri()); - log("verbose: "+isVerbose()); - log("failonerror: "+isFailonerror()); - } - File basePathFile = new File(getDestdir()); - if (basePathFile.exists()==false) { - throw new BuildException("destdir does not exists: "+basePathFile); - } - - // Config and start schema writer - X4OSchemaWriterExecutor writer = new X4OSchemaWriterExecutor(); - writer.setBasePath(basePathFile); - writer.setLanguage(getLanguage()); - writer.setLanguageNamespaceUri(getNsuri()); - try { - if (isVerbose()) { - log("Starting writing."); - } - long startTime = System.currentTimeMillis(); - writer.execute(); - long stopTime = System.currentTimeMillis(); - log("Done writing schema in "+(stopTime-startTime)+" ms."); - } catch (ElementException e) { - throw new BuildException(e); - } catch (InstantiationException e) { - throw new BuildException(e); - } catch (IllegalAccessException e) { - throw new BuildException(e); - } - } - - /** - * @return the nsuri - */ - public String getNsuri() { - return nsuri; - } - - /** - * @param nsuri the nsuri to set - */ - public void setNsuri(String nsuri) { - this.nsuri = nsuri; - } - - /** - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * @param language the language to set - */ - public void setLanguage(String language) { - this.language = language; - } - - /** - * @return the destdir - */ - public String getDestdir() { - return destdir; - } - - /** - * @param destdir the destdir to set - */ - public void setDestdir(String destdir) { - this.destdir = destdir; - } - - /** - * @return the verbose - */ - public boolean isVerbose() { - return verbose; - } - - /** - * @param verbose the verbose to set - */ - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - /** - * @return the failonerror - */ - public boolean isFailonerror() { - return failonerror; - } - - /** - * @param failonerror the failonerror to set - */ - public void setFailonerror(boolean failonerror) { - this.failonerror = failonerror; - } -} diff --git a/x4o-plugin/x4o-plugin-ant-elddoc/.project b/x4o-plugin/x4o-plugin-ant/.project similarity index 93% rename from x4o-plugin/x4o-plugin-ant-elddoc/.project rename to x4o-plugin/x4o-plugin-ant/.project index bf67702..c4fb813 100644 --- a/x4o-plugin/x4o-plugin-ant-elddoc/.project +++ b/x4o-plugin/x4o-plugin-ant/.project @@ -1,6 +1,6 @@ - x4o-plugin-ant-elddoc + x4o-plugin-ant diff --git a/x4o-plugin/x4o-plugin-ant-elddoc/pom.xml b/x4o-plugin/x4o-plugin-ant/pom.xml similarity index 55% rename from x4o-plugin/x4o-plugin-ant-elddoc/pom.xml rename to x4o-plugin/x4o-plugin-ant/pom.xml index ba35af5..69647e9 100644 --- a/x4o-plugin/x4o-plugin-ant-elddoc/pom.xml +++ b/x4o-plugin/x4o-plugin-ant/pom.xml @@ -1,15 +1,13 @@ 4.0.0 - x4o-plugin org.x4o.plugin + x4o-plugin 0.8.5-SNAPSHOT - .. - x4o-plugin-ant-elddoc - jar - x4o-plugin-ant-elddoc - Creates elddoc for languauge + x4o-plugin-ant + x4o-plugin-ant + x4o-plugin-ant org.x4o @@ -37,12 +35,11 @@ junit ${junit.version} test - + de.odysseus.juel juel ${juel.version} - test org.x4o @@ -73,6 +70,76 @@ + + update-schema-cel + + + + org.apache.maven.plugins + maven-antrun-plugin + ${maven-antrun-plugin.version} + + + update-schema-cel-ant + generate-resources + + + + + + + + + run + + + + + + org.x4o.plugin + x4o-plugin-ant-schema + ${project.version} + + + + + + + + update-schema-eld + + + + org.apache.maven.plugins + maven-antrun-plugin + ${maven-antrun-plugin.version} + + + update-schema-eld-ant + generate-resources + + + + + + + + + run + + + + + + org.x4o.plugin + x4o-plugin-ant-schema + ${project.version} + + + + + + site-elddoc @@ -93,12 +160,12 @@ - - - - - - + + + + + + @@ -109,7 +176,7 @@ org.x4o.plugin - x4o-plugin-ant-elddoc + x4o-plugin-ant ${project.version} diff --git a/x4o-plugin/x4o-plugin-ant-elddoc/src/main/java/org/x4o/plugin/ant/eld/doc/EldDocWriterTask.java b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/AbstractX4OLanguageTask.java similarity index 76% rename from x4o-plugin/x4o-plugin-ant-elddoc/src/main/java/org/x4o/plugin/ant/eld/doc/EldDocWriterTask.java rename to x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/AbstractX4OLanguageTask.java index de90733..68c2dff 100644 --- a/x4o-plugin/x4o-plugin-ant-elddoc/src/main/java/org/x4o/plugin/ant/eld/doc/EldDocWriterTask.java +++ b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/AbstractX4OLanguageTask.java @@ -21,7 +21,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.x4o.plugin.ant.eld.doc; +package org.x4o.plugin.ant; import java.io.File; @@ -29,16 +29,14 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; -import org.x4o.xml.eld.doc.X4ODocWriterExecutor; -import org.x4o.xml.element.ElementException; /** - * EldDocWriterTask creates schema for language. + * AbstractX4OLanguageTask is base ant x4o language task executor. * * @author Willem Cazander - * @version 1.0 Aug 24, 2012 + * @version 1.0 Apr 8, 2013 */ -public class EldDocWriterTask extends Task { +abstract public class AbstractX4OLanguageTask extends Task { private String language = null; private String destdir = null; @@ -52,7 +50,14 @@ public class EldDocWriterTask extends Task { @Override public void execute() throws BuildException { try { - executeTask(); + if (isVerbose()) { + log("Task Location: "+getLocation()); + log("X4O Language:"+getLanguage()); + log("Destination Dir:"+getDestdir()); + log("Verbose:"+isVerbose()); + log("Fail on error:"+isFailonerror()); + } + executeLanguageTask(); } catch (BuildException e) { if (isFailonerror()) { throw e; @@ -62,42 +67,36 @@ public class EldDocWriterTask extends Task { } } - private void executeTask() throws BuildException { + private void executeLanguageTask() throws BuildException { if (getLanguage()==null) { throw new BuildException("language attribute is not set."); } if (getDestdir()==null) { throw new BuildException("basePath attribute is not set."); } - if (isVerbose()) { - log("Execute task from: "+getLocation()); - log("language:"+getLanguage()); - log("destdir:"+getDestdir()); - log("verbose:"+isVerbose()); - log("failonerror:"+isFailonerror()); + if (getLanguage().length()==0) { + throw new BuildException("language attribute is empty."); + } + if (getDestdir().length()==0) { + throw new BuildException("basePath attribute is empty."); } File basePathFile = new File(getDestdir()); if (basePathFile.exists()==false) { throw new BuildException("destdir does not exists: "+basePathFile); } - - // Config and start schema writer - X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); - writer.setBasePath(basePathFile); - writer.setLanguage(getLanguage()); - try { - if (isVerbose()) { - log("Starting writing."); - } - long startTime = System.currentTimeMillis(); - writer.execute(); - long stopTime = System.currentTimeMillis(); - log("Done writing elddoc in "+(stopTime-startTime)+" ms."); - } catch (ElementException e) { - throw new BuildException(e); + if (isVerbose()) { + log("Starting "+getLanguageTaskName()); } + long startTime = System.currentTimeMillis(); + executeLanguageTask(basePathFile); + long stopTime = System.currentTimeMillis(); + log("Done "+getLanguageTaskName()+" in "+(stopTime-startTime)+" ms."); } + abstract String getLanguageTaskName(); + + abstract void executeLanguageTask(File basePath) throws BuildException; + /** * @return the language */ diff --git a/x4o-plugin/x4o-plugin-ant-schema/src/main/java/org/x4o/plugin/ant/eld/xsd/package-info.java b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/X4OWriteLanguageDocTask.java similarity index 57% rename from x4o-plugin/x4o-plugin-ant-schema/src/main/java/org/x4o/plugin/ant/eld/xsd/package-info.java rename to x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/X4OWriteLanguageDocTask.java index fbb5dc0..bfa9022 100644 --- a/x4o-plugin/x4o-plugin-ant-schema/src/main/java/org/x4o/plugin/ant/eld/xsd/package-info.java +++ b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/X4OWriteLanguageDocTask.java @@ -21,10 +21,44 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** - * The ant x4o schema plugin. - * - * @since 1.0 - */ +package org.x4o.plugin.ant; -package org.x4o.plugin.ant.eld.xsd; +import java.io.File; + +import org.apache.tools.ant.BuildException; + +import org.x4o.xml.eld.doc.X4OWriteLanguageDocExecutor; +import org.x4o.xml.element.ElementException; + +/** + * X4OWriteDocTask creates schema for language. + * + * @author Willem Cazander + * @version 1.0 Aug 24, 2012 + */ +public class X4OWriteLanguageDocTask extends AbstractX4OLanguageTask { + + /** + * @see org.x4o.plugin.ant.AbstractX4OLanguageTask#getLanguageTaskName() + */ + @Override + String getLanguageTaskName() { + return "X4O Write language documentation"; + } + + /** + * Config and start eld writer + * @see org.x4o.plugin.ant.AbstractX4OLanguageTask#executeLanguageTask(java.io.File) + */ + @Override + void executeLanguageTask(File basePath) throws BuildException { + X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor(); + writer.setBasePath(basePath); + writer.setLanguage(getLanguage()); + try { + writer.execute(); + } catch (ElementException e) { + throw new BuildException(e); + } + } +} diff --git a/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/X4OWriteLanguageSchemaTask.java b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/X4OWriteLanguageSchemaTask.java new file mode 100644 index 0000000..e6a3bfe --- /dev/null +++ b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/X4OWriteLanguageSchemaTask.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2004-2012, Willem Cazander + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package org.x4o.plugin.ant; + +import java.io.File; + +import org.apache.tools.ant.BuildException; +import org.x4o.xml.eld.xsd.X4OWriteLanguageSchemaExecutor; +import org.x4o.xml.element.ElementException; + +/** + * X4OWriteSchemaTask creates schema for language. + * + * @author Willem Cazander + * @version 1.0 Aug 23, 2012 + */ +public class X4OWriteLanguageSchemaTask extends AbstractX4OLanguageTask { + + private String nsuri = null; + + /** + * @see org.x4o.plugin.ant.AbstractX4OLanguageTask#getLanguageTaskName() + */ + @Override + String getLanguageTaskName() { + return "X4O Write language schema"; + } + + /** + * Config and start schema writer + * @see org.x4o.plugin.ant.AbstractX4OLanguageTask#executeLanguageTask(java.io.File) + */ + @Override + void executeLanguageTask(File basePath) throws BuildException { + if (isVerbose() && getNsuri()!=null) { + log("Namespace uri: "+getNsuri()); + } + X4OWriteLanguageSchemaExecutor writer = new X4OWriteLanguageSchemaExecutor(); + writer.setBasePath(basePath); + writer.setLanguage(getLanguage()); + writer.setLanguageNamespaceUri(getNsuri()); // null is all namespaces + try { + writer.execute(); + } catch (ElementException e) { + throw new BuildException(e); + } + } + + /** + * @return the nsuri + */ + public String getNsuri() { + return nsuri; + } + + /** + * @param nsuri the nsuri to set + */ + public void setNsuri(String nsuri) { + this.nsuri = nsuri; + } +} diff --git a/x4o-plugin/x4o-plugin-ant-elddoc/src/main/java/org/x4o/plugin/ant/eld/doc/package-info.java b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/package-info.java similarity index 95% rename from x4o-plugin/x4o-plugin-ant-elddoc/src/main/java/org/x4o/plugin/ant/eld/doc/package-info.java rename to x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/package-info.java index 5ff2622..570579d 100644 --- a/x4o-plugin/x4o-plugin-ant-elddoc/src/main/java/org/x4o/plugin/ant/eld/doc/package-info.java +++ b/x4o-plugin/x4o-plugin-ant/src/main/java/org/x4o/plugin/ant/package-info.java @@ -22,9 +22,9 @@ */ /** - * The ant elddoc plugin. + * The ant plugin tasks. * * @since 1.0 */ -package org.x4o.plugin.ant.eld.doc; +package org.x4o.plugin.ant; \ No newline at end of file diff --git a/x4o-plugin/x4o-plugin-ant-elddoc/src/test/java/org/x4o/plugin/ant/eld/doc/EldDocWriterTaskTest.java b/x4o-plugin/x4o-plugin-ant/src/test/java/org/x4o/plugin/ant/X4OWriteLanguageDocTaskTest.java similarity index 92% rename from x4o-plugin/x4o-plugin-ant-elddoc/src/test/java/org/x4o/plugin/ant/eld/doc/EldDocWriterTaskTest.java rename to x4o-plugin/x4o-plugin-ant/src/test/java/org/x4o/plugin/ant/X4OWriteLanguageDocTaskTest.java index c0e3f2c..faff422 100644 --- a/x4o-plugin/x4o-plugin-ant-elddoc/src/test/java/org/x4o/plugin/ant/eld/doc/EldDocWriterTaskTest.java +++ b/x4o-plugin/x4o-plugin-ant/src/test/java/org/x4o/plugin/ant/X4OWriteLanguageDocTaskTest.java @@ -21,22 +21,22 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.x4o.plugin.ant.eld.doc; +package org.x4o.plugin.ant; import java.io.File; import org.apache.tools.ant.BuildFileTest; /** - * SchemaTaskTest tests the schema ant task. + * X4OWriteDocTaskTest tests the doc ant task. * * @author Willem Cazander * @version 1.0 Aug 23, 2012 */ -public class EldDocWriterTaskTest extends BuildFileTest { +public class X4OWriteLanguageDocTaskTest extends BuildFileTest { public void setUp() { - configureProject("src/test/resources/tests/ant-elddoc-task.xml"); + configureProject("src/test/resources/tests/test-write-language-doc.xml"); } public void testEldDocCel() { @@ -59,7 +59,7 @@ public class EldDocWriterTaskTest extends BuildFileTest { public void testEldDocEldVerbose() { executeTarget("test-elddoc-cel-verbose"); - assertLogContaining("verbose:"); + assertLogContaining("Verbose:"); } public void testFailAllMissing() { diff --git a/x4o-plugin/x4o-plugin-ant-schema/src/test/java/org/x4o/plugin/ant/eld/xsd/EldXsdWriterTaskTest.java b/x4o-plugin/x4o-plugin-ant/src/test/java/org/x4o/plugin/ant/X4OWriteLanguageSchemaTaskTest.java similarity index 91% rename from x4o-plugin/x4o-plugin-ant-schema/src/test/java/org/x4o/plugin/ant/eld/xsd/EldXsdWriterTaskTest.java rename to x4o-plugin/x4o-plugin-ant/src/test/java/org/x4o/plugin/ant/X4OWriteLanguageSchemaTaskTest.java index 9343705..f01a022 100644 --- a/x4o-plugin/x4o-plugin-ant-schema/src/test/java/org/x4o/plugin/ant/eld/xsd/EldXsdWriterTaskTest.java +++ b/x4o-plugin/x4o-plugin-ant/src/test/java/org/x4o/plugin/ant/X4OWriteLanguageSchemaTaskTest.java @@ -21,22 +21,22 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package org.x4o.plugin.ant.eld.xsd; +package org.x4o.plugin.ant; import java.io.File; import org.apache.tools.ant.BuildFileTest; /** - * SchemaTaskTest tests the schema ant task. + * X4OWriteSchemaTaskTest tests the schema ant task. * * @author Willem Cazander * @version 1.0 Aug 23, 2012 */ -public class EldXsdWriterTaskTest extends BuildFileTest { +public class X4OWriteLanguageSchemaTaskTest extends BuildFileTest { public void setUp() { - configureProject("src/test/resources/tests/ant-schema-task.xml"); + configureProject("src/test/resources/tests/test-write-language-schema.xml"); } public void testCelSchemaFull() { @@ -59,7 +59,7 @@ public class EldXsdWriterTaskTest extends BuildFileTest { public void testCelSchemaVerbose() { executeTarget("test-cel-schema-verbose"); - assertLogContaining("verbose:"); + assertLogContaining("Verbose:"); } public void testFailAllMissing() { diff --git a/x4o-plugin/x4o-plugin-ant-elddoc/src/test/resources/tests/ant-elddoc-task.xml b/x4o-plugin/x4o-plugin-ant/src/test/resources/tests/test-write-language-doc.xml similarity index 85% rename from x4o-plugin/x4o-plugin-ant-elddoc/src/test/resources/tests/ant-elddoc-task.xml rename to x4o-plugin/x4o-plugin-ant/src/test/resources/tests/test-write-language-doc.xml index 8ef58d2..1598db3 100644 --- a/x4o-plugin/x4o-plugin-ant-elddoc/src/test/resources/tests/ant-elddoc-task.xml +++ b/x4o-plugin/x4o-plugin-ant/src/test/resources/tests/test-write-language-doc.xml @@ -28,14 +28,14 @@ - + - @@ -43,7 +43,7 @@ - - - + - + - + - + - + \ No newline at end of file diff --git a/x4o-plugin/x4o-plugin-ant-schema/src/test/resources/tests/ant-schema-task.xml b/x4o-plugin/x4o-plugin-ant/src/test/resources/tests/test-write-language-schema.xml similarity index 85% rename from x4o-plugin/x4o-plugin-ant-schema/src/test/resources/tests/ant-schema-task.xml rename to x4o-plugin/x4o-plugin-ant/src/test/resources/tests/test-write-language-schema.xml index e8ee6ed..3b4eb68 100644 --- a/x4o-plugin/x4o-plugin-ant-schema/src/test/resources/tests/ant-schema-task.xml +++ b/x4o-plugin/x4o-plugin-ant/src/test/resources/tests/test-write-language-schema.xml @@ -28,14 +28,14 @@ - + - @@ -43,7 +43,7 @@ - - - + - + - + - + - + \ No newline at end of file