Create language task api and converted the current tasks.
This commit is contained in:
parent
57f3c20655
commit
6cd968eb17
69 changed files with 2092 additions and 1315 deletions
|
|
@ -22,11 +22,15 @@
|
|||
*/
|
||||
package org.x4o.plugin.ant;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.Task;
|
||||
import org.x4o.xml.lang.task.X4OLanguageTaskException;
|
||||
import org.x4o.xml.lang.task.run.X4OTaskProperty;
|
||||
import org.x4o.xml.lang.task.run.X4OTaskRunner;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -35,18 +39,29 @@ import org.apache.tools.ant.Task;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 8, 2013
|
||||
*/
|
||||
abstract public class AbstractX4OLanguageTask extends Task {
|
||||
public class X4OTask extends Task {
|
||||
|
||||
private String taskId = null;
|
||||
private String languageName = null;
|
||||
private String languageVersion = null;
|
||||
private String destdir = null;
|
||||
private boolean verbose = false;
|
||||
private boolean failonerror = true;
|
||||
private List<X4OTaskProperty> taskProperties = null;
|
||||
|
||||
/**
|
||||
* Constructs this ant x4o task.
|
||||
*/
|
||||
public X4OTask() {
|
||||
taskProperties = new ArrayList<X4OTaskProperty>(15);
|
||||
}
|
||||
|
||||
abstract String getLanguageTaskName();
|
||||
|
||||
abstract void executeLanguageTask(File basePath) throws BuildException;
|
||||
/**
|
||||
* Adds the ant child x4oTaskProperty element.
|
||||
* @param property
|
||||
*/
|
||||
public void addX4oTaskProperty(X4OTaskProperty property) {
|
||||
taskProperties.add(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the x4o eld schema task.
|
||||
|
|
@ -59,7 +74,6 @@ abstract public class AbstractX4OLanguageTask extends Task {
|
|||
log("Task location: "+getLocation());
|
||||
log("X4O language name: "+getLanguageName());
|
||||
log("X4O language version: "+getLanguageVersion());
|
||||
log("Destination directory: "+getDestdir());
|
||||
log("Verbose: "+isVerbose());
|
||||
log("Fail on error: "+isFailonerror());
|
||||
}
|
||||
|
|
@ -75,28 +89,31 @@ abstract public class AbstractX4OLanguageTask extends Task {
|
|||
|
||||
private void executeLanguageTask() throws BuildException {
|
||||
if (getLanguageName()==null) {
|
||||
throw new BuildException("language attribute is not set.");
|
||||
}
|
||||
if (getDestdir()==null) {
|
||||
throw new BuildException("basePath attribute is not set.");
|
||||
throw new BuildException("languageName attribute is not set.");
|
||||
}
|
||||
if (getLanguageName().length()==0) {
|
||||
throw new BuildException("language attribute is empty.");
|
||||
throw new BuildException("languageName attribute is empty.");
|
||||
}
|
||||
if (getDestdir().length()==0) {
|
||||
throw new BuildException("basePath attribute is empty.");
|
||||
if (getLanguageVersion()!=null && getLanguageVersion().length()==0) {
|
||||
throw new BuildException("languageVersion attribute is empty.");
|
||||
}
|
||||
File basePathFile = new File(getDestdir());
|
||||
if (basePathFile.exists()==false) {
|
||||
throw new BuildException("destdir does not exists: "+basePathFile);
|
||||
if (getTaskId()==null) {
|
||||
throw new BuildException("taskId attribute is not set.");
|
||||
}
|
||||
if (getTaskId().length()==0) {
|
||||
throw new BuildException("taskId attribute is empty.");
|
||||
}
|
||||
if (isVerbose()) {
|
||||
log("Starting "+getLanguageTaskName());
|
||||
log("Starting "+getTaskId());
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
executeLanguageTask(basePathFile);
|
||||
try {
|
||||
X4OTaskRunner.runTask(getLanguageName(),getLanguageVersion(), getTaskId(), taskProperties);
|
||||
} catch (X4OLanguageTaskException e) {
|
||||
throw new BuildException(e);
|
||||
}
|
||||
long stopTime = System.currentTimeMillis();
|
||||
log("Done "+getLanguageTaskName()+" in "+(stopTime-startTime)+" ms.");
|
||||
log("Done "+getTaskId()+" in "+(stopTime-startTime)+" ms.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,67 +122,67 @@ abstract public class AbstractX4OLanguageTask extends Task {
|
|||
public String getLanguageName() {
|
||||
return languageName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param languageName the languageName to set
|
||||
*/
|
||||
public void setLanguageName(String languageName) {
|
||||
this.languageName = languageName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the languageVersion
|
||||
*/
|
||||
public String getLanguageVersion() {
|
||||
return languageVersion;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param languageVersion the languageVersion to set
|
||||
*/
|
||||
public void setLanguageVersion(String languageVersion) {
|
||||
this.languageVersion = languageVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the taskId
|
||||
*/
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param taskId the taskId to set
|
||||
*/
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2013, 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.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.setLanguageName(getLanguageName());
|
||||
writer.setLanguageVersion(getLanguageVersion());
|
||||
try {
|
||||
writer.execute();
|
||||
} catch (ElementException e) {
|
||||
throw new BuildException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2013, 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.setLanguageName(getLanguageName());
|
||||
writer.setLanguageVersion(getLanguageVersion());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -56,6 +56,13 @@ public class X4OWriteLanguageDocTaskTest extends BuildFileTest {
|
|||
//assertLogContaining("Nested Element 1");
|
||||
}
|
||||
|
||||
public void testEldDocEldCustom() {
|
||||
executeTarget("test-elddoc-eld-custom");
|
||||
File testDir = new File("target/test-elddoc/eld-custom");
|
||||
int files = testDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
}
|
||||
|
||||
public void testEldDocEldVerbose() {
|
||||
executeTarget("test-elddoc-cel-verbose");
|
||||
assertLogContaining("Verbose:");
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class X4OWriteLanguageSchemaTaskTest extends BuildFileTest {
|
|||
executeTarget("test-cel-schema-full");
|
||||
File testDir = new File("target/test-schemas/cel-full");
|
||||
int files = testDir.listFiles().length;
|
||||
assertEquals("Should created only 3 files", 3, files);
|
||||
assertEquals("Should created only 2 files", 2, files);
|
||||
}
|
||||
|
||||
public void testCelSchemaSingle() {
|
||||
|
|
|
|||
|
|
@ -28,50 +28,83 @@
|
|||
<property name="test.dir" value="${basedir}/target/test-elddoc/"/>
|
||||
|
||||
<target name="init">
|
||||
<taskdef name="writeLanguageDoc" classname="org.x4o.plugin.ant.X4OWriteLanguageDocTask"/>
|
||||
<taskdef name="x4oTask" classname="org.x4o.plugin.ant.X4OTask"/>
|
||||
<mkdir dir="${test.dir}"/>
|
||||
<mkdir dir="${test.dir}/test"/>
|
||||
</target>
|
||||
|
||||
<target name="test-elddoc-cel" depends="init">
|
||||
<mkdir dir="${test.dir}/cel"/>
|
||||
<writeLanguageDoc
|
||||
destdir="${test.dir}/cel"
|
||||
languageName="cel"
|
||||
<x4oTask languageName="cel" taskId="eld-doc">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/output/path"
|
||||
value="${test.dir}/cel"
|
||||
/>
|
||||
</x4oTask>
|
||||
</target>
|
||||
|
||||
<target name="test-elddoc-cel-verbose" depends="init">
|
||||
<mkdir dir="${test.dir}/cel"/>
|
||||
<writeLanguageDoc
|
||||
verbose="true"
|
||||
destdir="${test.dir}/cel"
|
||||
languageName="cel"
|
||||
<mkdir dir="${test.dir}/cel-verbose"/>
|
||||
<x4oTask languageName="cel" taskId="eld-doc" verbose="true">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/output/path"
|
||||
value="${test.dir}/cel-verbose"
|
||||
/>
|
||||
</x4oTask>
|
||||
</target>
|
||||
|
||||
<target name="test-elddoc-eld" depends="init">
|
||||
<mkdir dir="${test.dir}/eld"/>
|
||||
<writeLanguageDoc
|
||||
destdir="${test.dir}/eld"
|
||||
languageName="cel"
|
||||
<x4oTask languageName="eld" taskId="eld-doc">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/output/path"
|
||||
value="${test.dir}/eld"
|
||||
/>
|
||||
</x4oTask>
|
||||
</target>
|
||||
|
||||
<target name="test-elddoc-eld-custom" depends="init">
|
||||
<mkdir dir="${test.dir}/eld-custom"/>
|
||||
<x4oTask languageName="eld" taskId="eld-doc">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/output/path"
|
||||
value="${test.dir}/eld-custom"
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/content/output/charTab"
|
||||
value=" "
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/meta/stylesheet-thema"
|
||||
value="jdk6"
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/javadoc/link"
|
||||
value="http://docs.oracle.com/javase/7/docs/api/"
|
||||
/>
|
||||
<!-- fixme map type property config
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-doc/javadoc/link-offline"
|
||||
value="http://www.x4o.org/apidocs/,file:///home/willemc/devv/git/x4o/x4o-driver/target/apidocs"
|
||||
/>
|
||||
-->
|
||||
</x4oTask>
|
||||
</target>
|
||||
|
||||
<target name="test-fail-all" depends="init">
|
||||
<writeLanguageDoc/>
|
||||
<x4oTask/>
|
||||
</target>
|
||||
<target name="test-fail-destdir" depends="init">
|
||||
<writeLanguageDoc languageName="cel"/>
|
||||
<x4oTask languageName="cel"/>
|
||||
</target>
|
||||
<target name="test-fail-destdir-error" depends="init">
|
||||
<writeLanguageDoc languageName="cel" destdir="${test.dir}/no-dir"/>
|
||||
<x4oTask languageName="cel" destdir="${test.dir}/no-dir"/>
|
||||
</target>
|
||||
<target name="test-fail-language" depends="init">
|
||||
<writeLanguageDoc destdir="${test.dir}/test"/>
|
||||
<x4oTask destdir="${test.dir}/test"/>
|
||||
</target>
|
||||
<target name="test-fail-language-error" depends="init">
|
||||
<writeLanguageDoc destdir="${test.dir}/test" languageName="cel-error"/>
|
||||
<x4oTask destdir="${test.dir}/test" languageName="cel-error"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -28,52 +28,63 @@
|
|||
<property name="test.dir" value="${basedir}/target/test-schemas/"/>
|
||||
|
||||
<target name="init">
|
||||
<taskdef name="writeLanguageSchema" classname="org.x4o.plugin.ant.X4OWriteLanguageSchemaTask"/>
|
||||
<taskdef name="x4oTask" classname="org.x4o.plugin.ant.X4OTask"/>
|
||||
<mkdir dir="${test.dir}"/>
|
||||
<mkdir dir="${test.dir}/test"/>
|
||||
</target>
|
||||
|
||||
<target name="test-cel-schema-full" depends="init">
|
||||
<mkdir dir="${test.dir}/cel-full"/>
|
||||
<writeLanguageSchema
|
||||
destdir="${test.dir}/cel-full"
|
||||
languageName="eld"
|
||||
<x4oTask languageName="cel" taskId="eld-xsd">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/output/path"
|
||||
value="${test.dir}/cel-full"
|
||||
/>
|
||||
</x4oTask>
|
||||
</target>
|
||||
|
||||
<target name="test-cel-schema-single" depends="init">
|
||||
<mkdir dir="${test.dir}/cel-single"/>
|
||||
<writeLanguageSchema
|
||||
destdir="${test.dir}/cel-single"
|
||||
languageName="cel"
|
||||
nsuri="http://cel.x4o.org/xml/ns/cel-core"
|
||||
<x4oTask languageName="cel" taskId="eld-xsd">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/output/path"
|
||||
value="${test.dir}/cel-single"
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/filter/namespace"
|
||||
value="http://cel.x4o.org/xml/ns/cel-core"
|
||||
/>
|
||||
</x4oTask>
|
||||
</target>
|
||||
|
||||
<target name="test-cel-schema-verbose" depends="init">
|
||||
<mkdir dir="${test.dir}/cel-single"/>
|
||||
<writeLanguageSchema
|
||||
verbose="true"
|
||||
destdir="${test.dir}/cel-single"
|
||||
languageName="cel"
|
||||
nsuri="http://cel.x4o.org/xml/ns/cel-core"
|
||||
<mkdir dir="${test.dir}/cel-single-verbose"/>
|
||||
<x4oTask languageName="cel" taskId="eld-xsd" verbose="true">
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/output/path"
|
||||
value="${test.dir}/cel-single-verbose"
|
||||
/>
|
||||
<x4oTaskProperty
|
||||
key="http://language.x4o.org/xml/properties/eld-xsd/filter/namespace"
|
||||
value="http://cel.x4o.org/xml/ns/cel-core"
|
||||
/>
|
||||
</x4oTask>
|
||||
</target>
|
||||
|
||||
<target name="test-fail-all" depends="init">
|
||||
<writeLanguageSchema/>
|
||||
<x4oTask/>
|
||||
</target>
|
||||
<target name="test-fail-destdir" depends="init">
|
||||
<writeLanguageSchema languageName="cel"/>
|
||||
<x4oTask languageName="cel"/>
|
||||
</target>
|
||||
<target name="test-fail-destdir-error" depends="init">
|
||||
<writeLanguageSchema languageName="cel" destdir="${test.dir}/no-dir"/>
|
||||
<x4oTask languageName="cel" destdir="${test.dir}/no-dir"/>
|
||||
</target>
|
||||
<target name="test-fail-language" depends="init">
|
||||
<writeLanguageSchema destdir="${test.dir}/test"/>
|
||||
<x4oTask destdir="${test.dir}/test"/>
|
||||
</target>
|
||||
<target name="test-fail-language-error" depends="init">
|
||||
<writeLanguageSchema destdir="${test.dir}/test" languageName="eld-error"/>
|
||||
<x4oTask destdir="${test.dir}/test" languageName="eld-error"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -81,6 +81,12 @@
|
|||
<id>build-site-x4o-support</id>
|
||||
<phase>pre-site</phase>
|
||||
<configuration>
|
||||
<languageName>cel</languageName>
|
||||
<taskId>eld-xsd</taskId>
|
||||
<taskPropertyValues>
|
||||
<taskPropertyValue>http://language.x4o.org/xml/properties/eld-xsd/output/path=${basedir}/../../target/site/x4o-support</taskPropertyValue>
|
||||
</taskPropertyValues>
|
||||
<!-- TODO: add exe'ids
|
||||
<outputDirectory>${basedir}/../../target/site/x4o-support</outputDirectory>
|
||||
<languages>
|
||||
<cel>ALL</cel>
|
||||
|
|
@ -88,10 +94,10 @@
|
|||
<test>ALL</test>
|
||||
<swixml>2.0-3.0</swixml>
|
||||
</languages>
|
||||
-->
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>write-language-doc</goal>
|
||||
<goal>write-language-schema</goal>
|
||||
<goal>x4o-language-task</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
|||
|
|
@ -1,221 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2013, 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.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.x4o.xml.X4ODriver;
|
||||
import org.x4o.xml.X4ODriverManager;
|
||||
|
||||
/**
|
||||
* AbstractX4OLanguageMojo can perform a task on languages and versions.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 9, 2013
|
||||
*/
|
||||
public abstract class AbstractX4OLanguageMojo extends AbstractMojo {
|
||||
|
||||
private final static String DEFAULT_OUTPUT_DIRECTORY = "target/x4o";
|
||||
|
||||
@Parameter(property="outputDirectory",defaultValue=DEFAULT_OUTPUT_DIRECTORY)
|
||||
private File outputDirectory;
|
||||
|
||||
@Parameter
|
||||
private Map<String,String> languages;
|
||||
|
||||
@Parameter(property="languages")
|
||||
private String languageCommandLineString;
|
||||
|
||||
@Parameter(defaultValue="false",property="verbose")
|
||||
private boolean verbose = false;
|
||||
|
||||
@Parameter(defaultValue="true",property="failOnError")
|
||||
private boolean failOnError = true;
|
||||
|
||||
abstract String getLanguageTaskDirectoryLabel();
|
||||
|
||||
abstract String getLanguageTaskName();
|
||||
|
||||
abstract void executeLanguageTask(String languageName,String languageVersion,File outputDirectory) throws MojoExecutionException;
|
||||
|
||||
private void executeLanguageTask() throws MojoExecutionException {
|
||||
if (languages==null) {
|
||||
languages = new HashMap<String,String>(10); // maven does not support setting map on cmd line ?
|
||||
}
|
||||
if (outputDirectory==null) {
|
||||
outputDirectory = new File(DEFAULT_OUTPUT_DIRECTORY);
|
||||
}
|
||||
if (verbose) {
|
||||
getLog().info("Output directory: "+outputDirectory);
|
||||
getLog().info("Verbose: "+verbose);
|
||||
getLog().info("Fail on error: "+failOnError);
|
||||
}
|
||||
if (outputDirectory.exists()==false) {
|
||||
outputDirectory.mkdirs(); // incl parents
|
||||
if (verbose) {
|
||||
getLog().info("Created directory: "+outputDirectory);
|
||||
}
|
||||
}
|
||||
if (languageCommandLineString!=null && languageCommandLineString.startsWith("{") && languageCommandLineString.endsWith("}")) {
|
||||
languages.clear();
|
||||
String langString = languageCommandLineString.substring(1,languageCommandLineString.length()-1);
|
||||
String[] lang = langString.split(",");
|
||||
for (String l:lang) {
|
||||
String[] ll = l.split("=");
|
||||
if (ll.length!=2) {
|
||||
getLog().warn("Wrong langauge key split: '"+l+"' of languageString: '"+languageCommandLineString+"'");
|
||||
continue;
|
||||
}
|
||||
String langName = ll[0];
|
||||
String langVersion = ll[1];
|
||||
languages.put(langName,langVersion);
|
||||
}
|
||||
}
|
||||
if (languages.size()==0) {
|
||||
if (verbose) {
|
||||
getLog().info("Defaulting to all languages in classpath.");
|
||||
}
|
||||
for (String lang:X4ODriverManager.getX4OLanguages()) {
|
||||
languages.put(lang, "ALL");
|
||||
}
|
||||
}
|
||||
for (String languageName:languages.keySet()) {
|
||||
String languageVersions = languages.get(languageName);
|
||||
if (languageVersions.contains("*") || languageVersions.contains("ALL")) {
|
||||
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(languageName);
|
||||
if (driver==null) {
|
||||
throw new MojoExecutionException("Couln't load x4o language driver for: "+languageName);
|
||||
}
|
||||
for (String supportedVersion:driver.getLanguageVersions()) {
|
||||
executeLanguageTask(languageName,supportedVersion);
|
||||
}
|
||||
} else if (languageVersions.contains("-")) {
|
||||
for (String languageVersion:languageVersions.split("-")) {
|
||||
executeLanguageTask(languageName,languageVersion);
|
||||
}
|
||||
} else {
|
||||
executeLanguageTask(languageName,languageVersions); // only one version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void executeLanguageTask(String languageName,String languageVersion) throws MojoExecutionException {
|
||||
long startTime = System.currentTimeMillis();
|
||||
if (verbose) {
|
||||
getLog().info("Starting "+getLanguageTaskName()+" for "+languageName+":"+languageVersion);
|
||||
}
|
||||
StringBuffer buf = new StringBuffer(100);
|
||||
buf.append(outputDirectory.getAbsolutePath());
|
||||
buf.append(File.separatorChar);
|
||||
buf.append(getLanguageTaskDirectoryLabel());
|
||||
buf.append("-");
|
||||
buf.append(languageName);
|
||||
buf.append("-");
|
||||
buf.append(languageVersion);
|
||||
File outputLanguagPath = new File(buf.toString());
|
||||
if (outputLanguagPath.exists()==false) {
|
||||
outputLanguagPath.mkdir();
|
||||
if (verbose) {
|
||||
getLog().info("Created directory: "+outputLanguagPath);
|
||||
}
|
||||
}
|
||||
executeLanguageTask(languageName,languageVersion,outputLanguagPath);
|
||||
long stopTime = System.currentTimeMillis();
|
||||
getLog().info("Done "+getLanguageTaskName()+" for "+languageName+":"+languageVersion+" in "+(stopTime-startTime)+" ms.");
|
||||
}
|
||||
|
||||
public void execute() throws MojoExecutionException {
|
||||
try {
|
||||
executeLanguageTask();
|
||||
} catch (MojoExecutionException e) {
|
||||
if (failOnError) {
|
||||
throw e;
|
||||
} else {
|
||||
getLog().warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the outputDirectory
|
||||
*/
|
||||
public File getOutputDirectory() {
|
||||
return outputDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param outputDirectory the outputDirectory to set
|
||||
*/
|
||||
public void setOutputDirectory(File outputDirectory) {
|
||||
this.outputDirectory = outputDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the languages
|
||||
*/
|
||||
public Map<String, String> getLanguages() {
|
||||
return languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an language with version.
|
||||
* @param languageName the languageName to set
|
||||
* @param languageVersion the languageVersion to set
|
||||
*/
|
||||
public void addLanguage(String languageName,String languageVersion) {
|
||||
languages.put(languageName,languageVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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,178 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2013, 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.maven;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||
import org.x4o.xml.lang.task.X4OLanguageTaskException;
|
||||
import org.x4o.xml.lang.task.run.X4OTaskProperty;
|
||||
import org.x4o.xml.lang.task.run.X4OTaskRunner;
|
||||
|
||||
/**
|
||||
* X4OLanguageTaskMojo can execute a task on a language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 9, 2013
|
||||
*/
|
||||
@Mojo( name = X4OLanguageTaskMojo.GOAL,requiresProject=true,requiresDependencyResolution=ResolutionScope.COMPILE)
|
||||
public class X4OLanguageTaskMojo extends AbstractMojo {
|
||||
|
||||
static public final String GOAL = "x4o-language-task";
|
||||
|
||||
@Parameter
|
||||
private String languageName = null;
|
||||
|
||||
@Parameter
|
||||
private String languageVersion = null;
|
||||
|
||||
@Parameter
|
||||
private String taskId = null;
|
||||
|
||||
@Parameter
|
||||
private List<String> taskPropertyValues;
|
||||
|
||||
@Parameter(defaultValue="false",property="verbose")
|
||||
private boolean verbose = false;
|
||||
|
||||
@Parameter(defaultValue="true",property="failOnError")
|
||||
private boolean failOnError = true;
|
||||
|
||||
private void executeLanguageTask() throws MojoExecutionException {
|
||||
if (taskPropertyValues==null) {
|
||||
taskPropertyValues = new ArrayList<String>(10);
|
||||
}
|
||||
if (verbose) {
|
||||
getLog().info("Verbose: "+verbose);
|
||||
getLog().info("Fail on error: "+failOnError);
|
||||
}
|
||||
long startTime = System.currentTimeMillis();
|
||||
if (verbose) {
|
||||
getLog().info("Starting "+getTaskId()+" for "+getLanguageName()); //+":"+languageVersion
|
||||
}
|
||||
List<X4OTaskProperty> taskProperties = new ArrayList<X4OTaskProperty>(20);
|
||||
for (String taskPropertyLine:taskPropertyValues) {
|
||||
taskProperties.add(X4OTaskProperty.parseLine(taskPropertyLine));
|
||||
}
|
||||
try {
|
||||
X4OTaskRunner.runTask(getLanguageName(),getLanguageVersion(), getTaskId(), taskProperties);
|
||||
} catch (X4OLanguageTaskException e) {
|
||||
throw new MojoExecutionException("Error while running task: "+getTaskId()+" error: "+e.getMessage(),e);
|
||||
}
|
||||
long stopTime = System.currentTimeMillis();
|
||||
getLog().info("Done "+getTaskId()+" for "+languageName+":"+languageVersion+" in "+(stopTime-startTime)+" ms.");
|
||||
}
|
||||
|
||||
public void execute() throws MojoExecutionException {
|
||||
try {
|
||||
executeLanguageTask();
|
||||
} catch (MojoExecutionException e) {
|
||||
if (failOnError) {
|
||||
throw e;
|
||||
} else {
|
||||
getLog().warn(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getTaskPropertyValues() {
|
||||
return taskPropertyValues;
|
||||
}
|
||||
|
||||
public void addTaskPropertyValue(String taskPropertyLine) {
|
||||
taskPropertyValues.add(taskPropertyLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the languageName
|
||||
*/
|
||||
public String getLanguageName() {
|
||||
return languageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param languageName the languageName to set
|
||||
*/
|
||||
public void setLanguageName(String languageName) {
|
||||
this.languageName = languageName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the languageVersion
|
||||
*/
|
||||
public String getLanguageVersion() {
|
||||
return languageVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param languageVersion the languageVersion to set
|
||||
*/
|
||||
public void setLanguageVersion(String languageVersion) {
|
||||
this.languageVersion = languageVersion;
|
||||
}
|
||||
/**
|
||||
* @return the taskId
|
||||
*/
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
/**
|
||||
* @param taskId the taskId to set
|
||||
*/
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2013, 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.maven;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||
|
||||
import org.x4o.xml.eld.doc.X4OWriteLanguageDocExecutor;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
/**
|
||||
* X4OWriteLanguageDocMojo creates docs for language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 9, 2013
|
||||
*/
|
||||
@Mojo( name = X4OWriteLanguageDocMojo.GOAL,requiresProject=true,requiresDependencyResolution=ResolutionScope.COMPILE)
|
||||
public class X4OWriteLanguageDocMojo extends AbstractX4OLanguageMojo {
|
||||
|
||||
static public final String GOAL = "write-language-doc";
|
||||
|
||||
String getLanguageTaskDirectoryLabel() {
|
||||
return "doc";
|
||||
}
|
||||
|
||||
String getLanguageTaskName() {
|
||||
return "X4O Write language documentation";
|
||||
}
|
||||
|
||||
void executeLanguageTask(String languageName,String languageVersion,File basePath) throws MojoExecutionException {
|
||||
X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
|
||||
writer.setBasePath(basePath);
|
||||
writer.setLanguageName(languageName);
|
||||
writer.setLanguageVersion(languageVersion);
|
||||
try {
|
||||
writer.execute();
|
||||
} catch (ElementException e) {
|
||||
throw new MojoExecutionException(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2013, 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.maven;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||
|
||||
import org.x4o.xml.eld.xsd.X4OWriteLanguageSchemaExecutor;
|
||||
import org.x4o.xml.element.ElementException;
|
||||
|
||||
/**
|
||||
* X4OWriteLanguageSchemaMojo creates schema for language.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 10, 2013
|
||||
*/
|
||||
@Mojo( name = X4OWriteLanguageSchemaMojo.GOAL,requiresProject=true,requiresDependencyResolution=ResolutionScope.COMPILE)
|
||||
public class X4OWriteLanguageSchemaMojo extends AbstractX4OLanguageMojo {
|
||||
|
||||
static public final String GOAL = "write-language-schema";
|
||||
|
||||
String getLanguageTaskDirectoryLabel() {
|
||||
return "xsd";
|
||||
}
|
||||
|
||||
String getLanguageTaskName() {
|
||||
return "X4O Write language schema";
|
||||
}
|
||||
|
||||
void executeLanguageTask(String languageName,String languageVersion,File basePath) throws MojoExecutionException {
|
||||
X4OWriteLanguageSchemaExecutor writer = new X4OWriteLanguageSchemaExecutor();
|
||||
writer.setBasePath(basePath);
|
||||
writer.setLanguageName(languageName);
|
||||
writer.setLanguageVersion(languageVersion);
|
||||
try {
|
||||
writer.execute();
|
||||
} catch (ElementException e) {
|
||||
throw new MojoExecutionException(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,12 +28,12 @@ import org.apache.maven.plugin.Mojo;
|
|||
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
|
||||
|
||||
/**
|
||||
* X4OWriteLanguageDocMojoTest.
|
||||
* XX4OLanguageTaskMojoTest.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 6, 2013
|
||||
*/
|
||||
public class X4OWriteLanguageDocMojoTest extends AbstractMojoTestCase {
|
||||
public class X4OLanguageTaskMojoTest extends AbstractMojoTestCase {
|
||||
|
||||
/** {@inheritDoc} */
|
||||
protected void setUp() throws Exception {
|
||||
|
|
@ -49,7 +49,7 @@ public class X4OWriteLanguageDocMojoTest extends AbstractMojoTestCase {
|
|||
File pom = getTestFile(testFile);
|
||||
assertNotNull(pom);
|
||||
assertTrue(pom.exists());
|
||||
X4OWriteLanguageDocMojo mojo = (X4OWriteLanguageDocMojo) lookupMojo(goal,pom);
|
||||
X4OLanguageTaskMojo mojo = (X4OLanguageTaskMojo) lookupMojo(goal,pom);
|
||||
assertNotNull(mojo);
|
||||
mojo.execute();
|
||||
}
|
||||
|
|
@ -64,8 +64,9 @@ public class X4OWriteLanguageDocMojoTest extends AbstractMojoTestCase {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
public void testConfAllWriteDoc() throws Exception {
|
||||
executeGoal(X4OWriteLanguageDocMojo.GOAL,"src/test/resources/junit/test-plugin-conf-all.pom");
|
||||
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-all.pom");
|
||||
File outputDir = new File("target/jtest/test-plugin-conf-all/doc-eld-1.0");
|
||||
assertTrue(outputDir.exists());
|
||||
int files = outputDir.listFiles().length;
|
||||
|
|
@ -74,14 +75,14 @@ public class X4OWriteLanguageDocMojoTest extends AbstractMojoTestCase {
|
|||
|
||||
|
||||
public void testConfLangWriteDoc() throws Exception {
|
||||
executeGoal(X4OWriteLanguageDocMojo.GOAL,"src/test/resources/junit/test-plugin-conf-lang.pom");
|
||||
File outputDir = new File("target/jtest/test-plugin-conf-lang/doc-cel-1.0");
|
||||
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-lang.pom");
|
||||
File outputDir = new File("target/jtest/test-plugin-conf-lang/cel");
|
||||
int files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
assertEquals("Should created more then one files", true, files>1);
|
||||
}
|
||||
|
||||
public void testConfDefaultsWriteDoc() throws Exception {
|
||||
executeGoal(X4OWriteLanguageDocMojo.GOAL,"src/test/resources/junit/test-plugin-defaults.pom");
|
||||
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-defaults.pom");
|
||||
File outputDir = new File("target/x4o/doc-cel-1.0");
|
||||
int files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
|
|
@ -89,4 +90,32 @@ public class X4OWriteLanguageDocMojoTest extends AbstractMojoTestCase {
|
|||
files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
}
|
||||
|
||||
|
||||
public void testConfAllWriteSchema() throws Exception {
|
||||
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-all.pom");
|
||||
File outputDir = new File("target/jtest/test-plugin-conf-all/xsd-eld-1.0");
|
||||
assertTrue(outputDir.exists());
|
||||
int files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
}
|
||||
|
||||
|
||||
public void testConfLangWriteSchema() throws Exception {
|
||||
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-conf-lang.pom");
|
||||
File outputDir = new File("target/jtest/test-plugin-conf-lang/xsd-cel-1.0");
|
||||
int files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then one file", true, files>1);
|
||||
}
|
||||
|
||||
public void testConfDefaultsWriteSchema() throws Exception {
|
||||
executeGoal(X4OLanguageTaskMojo.GOAL,"src/test/resources/junit/test-plugin-defaults.pom");
|
||||
File outputDir = new File("target/x4o/xsd-cel-1.0");
|
||||
int files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then one file", true, files>1);
|
||||
outputDir = new File("target/x4o/xsd-eld-1.0");
|
||||
files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2013, 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.maven;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
|
||||
|
||||
/**
|
||||
* X4OWriteLanguageSchemaMojoTest.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Apr 14, 2013
|
||||
*/
|
||||
public class X4OWriteLanguageSchemaMojoTest extends AbstractMojoTestCase {
|
||||
|
||||
private void executeGoal(String goal,String testFile) throws Exception {
|
||||
File pom = getTestFile(testFile);
|
||||
assertNotNull(pom);
|
||||
assertTrue(pom.exists());
|
||||
X4OWriteLanguageSchemaMojo mojo = (X4OWriteLanguageSchemaMojo) lookupMojo(goal,pom);
|
||||
assertNotNull(mojo);
|
||||
mojo.execute();
|
||||
}
|
||||
|
||||
public void testConfAllWriteSchema() throws Exception {
|
||||
executeGoal(X4OWriteLanguageSchemaMojo.GOAL,"src/test/resources/junit/test-plugin-conf-all.pom");
|
||||
File outputDir = new File("target/jtest/test-plugin-conf-all/xsd-eld-1.0");
|
||||
assertTrue(outputDir.exists());
|
||||
int files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
}
|
||||
|
||||
|
||||
public void testConfLangWriteSchema() throws Exception {
|
||||
executeGoal(X4OWriteLanguageSchemaMojo.GOAL,"src/test/resources/junit/test-plugin-conf-lang.pom");
|
||||
File outputDir = new File("target/jtest/test-plugin-conf-lang/xsd-cel-1.0");
|
||||
int files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then one file", true, files>1);
|
||||
}
|
||||
|
||||
public void testConfDefaultsWriteSchema() throws Exception {
|
||||
executeGoal(X4OWriteLanguageSchemaMojo.GOAL,"src/test/resources/junit/test-plugin-defaults.pom");
|
||||
File outputDir = new File("target/x4o/xsd-cel-1.0");
|
||||
int files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then one file", true, files>1);
|
||||
outputDir = new File("target/x4o/xsd-eld-1.0");
|
||||
files = outputDir.listFiles().length;
|
||||
assertEquals("Should created more then two files", true, files>2);
|
||||
}
|
||||
}
|
||||
|
|
@ -46,10 +46,11 @@
|
|||
<plugin>
|
||||
<artifactId>x4o-plugin-maven</artifactId>
|
||||
<configuration>
|
||||
<outputDirectory>target/jtest/test-plugin-conf-lang</outputDirectory>
|
||||
<languages>
|
||||
<cel>1.0</cel>
|
||||
</languages>
|
||||
<languageName>cel</languageName>
|
||||
<taskId>eld-xsd</taskId>
|
||||
<taskPropertyValues>
|
||||
<taskPropertyValue>http://language.x4o.org/xml/properties/eld-xsd/output/path=target/jtest/test-plugin-conf-lang/cel</taskPropertyValue>
|
||||
</taskPropertyValues>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue