Init commit of full project.
This commit is contained in:
parent
130d471bd9
commit
787b1174b0
286 changed files with 27010 additions and 1 deletions
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* 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.doc;
|
||||
|
||||
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.core.X4OParserSupportException;
|
||||
import org.x4o.xml.core.config.X4OLanguageClassLoader;
|
||||
import org.x4o.xml.eld.doc.X4OLanguageEldDocWriter;
|
||||
|
||||
/**
|
||||
* EldDocWriterTask creates schema for language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 24, 2012
|
||||
*/
|
||||
public class EldDocWriterTask extends Task {
|
||||
|
||||
private String supportclass = 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 (getSupportclass()==null) {
|
||||
throw new BuildException("supportclass attribute is not set.");
|
||||
}
|
||||
if (getDestdir()==null) {
|
||||
throw new BuildException("basePath attribute is not set.");
|
||||
}
|
||||
if (isVerbose()) {
|
||||
log("Execute task from: "+getLocation());
|
||||
log("destdir:"+getDestdir());
|
||||
log("supportclass:"+getSupportclass());
|
||||
log("verbose:"+isVerbose());
|
||||
log("failonerror:"+isFailonerror());
|
||||
}
|
||||
File basePathFile = new File(getDestdir());
|
||||
if (basePathFile.exists()==false) {
|
||||
throw new BuildException("destdir does not exists: "+basePathFile);
|
||||
}
|
||||
Class<?> parserSupport = null;
|
||||
try {
|
||||
parserSupport = X4OLanguageClassLoader.loadClass(getSupportclass());
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new BuildException("Could not load class: "+getSupportclass(),e);
|
||||
}
|
||||
|
||||
// Config and start schema writer
|
||||
X4OLanguageEldDocWriter writer = new X4OLanguageEldDocWriter();
|
||||
writer.setBasePath(basePathFile);
|
||||
writer.setLanguageParserSupport(parserSupport);
|
||||
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 (X4OParserSupportException e) {
|
||||
throw new BuildException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the supportclass
|
||||
*/
|
||||
public String getSupportclass() {
|
||||
return supportclass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param supportclass the supportclass to set
|
||||
*/
|
||||
public void setSupportclass(String supportclass) {
|
||||
this.supportclass = supportclass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The ant elddoc plugin.
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
package org.x4o.plugin.ant.eld.doc;
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* 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.doc;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.tools.ant.BuildFileTest;
|
||||
|
||||
/**
|
||||
* SchemaTaskTest tests the schema ant task.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 23, 2012
|
||||
*/
|
||||
public class EldDocWriterTaskTest extends BuildFileTest {
|
||||
|
||||
public void setUp() {
|
||||
configureProject("src/test/resources/tests/ant-elddoc-task.xml");
|
||||
}
|
||||
|
||||
public void testEldDocCel() {
|
||||
executeTarget("test-elddoc-cel");
|
||||
File testDir = new File("target/test-elddoc/cel");
|
||||
int files = testDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
}
|
||||
|
||||
public void testEldDocEld() {
|
||||
executeTarget("test-elddoc-eld");
|
||||
File testDir = new File("target/test-elddoc/eld");
|
||||
int files = testDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
|
||||
///assertEquals("Message was logged but should not.", getLog(), "");
|
||||
//expectLog("use.message", "attribute-text");
|
||||
//assertLogContaining("Nested Element 1");
|
||||
}
|
||||
|
||||
public void testEldDocEldVerbose() {
|
||||
executeTarget("test-elddoc-cel-verbose");
|
||||
assertLogContaining("verbose:");
|
||||
}
|
||||
|
||||
public void testFailBasePath() {
|
||||
expectBuildException("test-fail-destdir", "Should get exception id destdir is not set.");
|
||||
}
|
||||
public void testFailBasePathError() {
|
||||
expectBuildException("test-fail-destdir-error", "Should get exception id destdir does not exists.");
|
||||
}
|
||||
public void testFailSupportClass() {
|
||||
expectBuildException("test-fail-supportclass", "Should get exception id supportclass is not set.");
|
||||
}
|
||||
public void testFailSupportClassError() {
|
||||
expectBuildException("test-fail-supportclass-error", "Should get exception id supportclass throws error.");
|
||||
}
|
||||
public void testFailAllMissing() {
|
||||
expectBuildException("test-fail-all", "Should get exception with no attributes.");
|
||||
}
|
||||
public void testFailClassError() {
|
||||
expectBuildException("test-fail-class-error", "No build exception while class is missing.");
|
||||
}
|
||||
public void testFailClassErrorNo() {
|
||||
executeTarget("test-fail-class-error-no");
|
||||
assertLogContaining("Could not load class:");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<project name="ant-elddoc-task" basedir="../../../..">
|
||||
|
||||
<property name="test.dir" value="${basedir}/target/test-elddoc/"/>
|
||||
|
||||
<target name="init">
|
||||
<taskdef name="eldDocWriter" classname="org.x4o.plugin.ant.eld.doc.EldDocWriterTask"/>
|
||||
<mkdir dir="${test.dir}"/>
|
||||
<mkdir dir="${test.dir}/test"/>
|
||||
</target>
|
||||
|
||||
<target name="test-elddoc-cel" depends="init">
|
||||
<mkdir dir="${test.dir}/cel"/>
|
||||
<eldDocWriter
|
||||
destdir="${test.dir}/cel"
|
||||
supportclass="org.x4o.xml.eld.EldParserSupportCore"
|
||||
/>
|
||||
</target>
|
||||
|
||||
<target name="test-elddoc-cel-verbose" depends="init">
|
||||
<mkdir dir="${test.dir}/cel"/>
|
||||
<eldDocWriter
|
||||
verbose="true"
|
||||
destdir="${test.dir}/cel"
|
||||
supportclass="org.x4o.xml.eld.EldParserSupportCore"
|
||||
/>
|
||||
</target>
|
||||
|
||||
<target name="test-elddoc-eld" depends="init">
|
||||
<mkdir dir="${test.dir}/eld"/>
|
||||
<eldDocWriter
|
||||
destdir="${test.dir}/eld"
|
||||
supportclass="org.x4o.xml.eld.EldParserSupportCore"
|
||||
/>
|
||||
</target>
|
||||
|
||||
<target name="test-fail-all" depends="init">
|
||||
<eldDocWriter/>
|
||||
</target>
|
||||
<target name="test-fail-destdir" depends="init">
|
||||
<eldDocWriter supportclass="org.x4o.xml.eld.EldParserSupportCore"/>
|
||||
</target>
|
||||
<target name="test-fail-destdir-error" depends="init">
|
||||
<eldDocWriter supportclass="org.x4o.xml.eld.EldParserSupportCore" destdir="${test.dir}/no-dir"/>
|
||||
</target>
|
||||
<target name="test-fail-supportclass" depends="init">
|
||||
<eldDocWriter destdir="${test.dir}/test"/>
|
||||
</target>
|
||||
<target name="test-fail-supportclass-error" depends="init">
|
||||
<eldDocWriter destdir="${test.dir}/test" supportclass="org.x4o.xml.eld.EldErrorParserSupport"/>
|
||||
</target>
|
||||
<target name="test-fail-class-error" depends="init">
|
||||
<eldDocWriter destdir="${test.dir}/test" supportclass="non.excisting.clazz"/>
|
||||
</target>
|
||||
<target name="test-fail-class-error-no" depends="init">
|
||||
<eldDocWriter destdir="${test.dir}/test" supportclass="non.excisting.clazz" failonerror="false"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue