Merged ant plugins to one.

This commit is contained in:
Willem Cazander 2013-04-08 21:44:16 +02:00
parent 179c0f3bfe
commit 37d249eb24
18 changed files with 288 additions and 448 deletions

View file

@ -39,14 +39,14 @@ import org.x4o.xml.io.X4OSchemaWriter;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 22, 2012 * @version 1.0 Aug 22, 2012
*/ */
public class X4OSchemaWriterExecutor { public class X4OWriteLanguageSchemaExecutor {
private String language = null; private String language = null;
private String languageNamespaceUri = null; private String languageNamespaceUri = null;
private File basePath; private File basePath;
static public void main(String argu[]) { static public void main(String argu[]) {
X4OSchemaWriterExecutor languageSchema = new X4OSchemaWriterExecutor(); X4OWriteLanguageSchemaExecutor languageSchema = new X4OWriteLanguageSchemaExecutor();
List<String> arguList = Arrays.asList(argu); List<String> arguList = Arrays.asList(argu);
Iterator<String> arguIterator = arguList.iterator(); Iterator<String> arguIterator = arguList.iterator();
boolean printStack = false; boolean printStack = false;
@ -85,10 +85,6 @@ public class X4OSchemaWriterExecutor {
languageSchema.execute(); languageSchema.execute();
} catch (ElementException e1) { } catch (ElementException e1) {
e = e1; e = e1;
} catch (InstantiationException e2) {
e = e2;
} catch (IllegalAccessException e3) {
e = e3;
} }
if (e!=null) { if (e!=null) {
System.err.println("Error while schema writing: "+e.getMessage()); System.err.println("Error while schema writing: "+e.getMessage());
@ -102,7 +98,7 @@ public class X4OSchemaWriterExecutor {
} }
} }
public void execute() throws ElementException, InstantiationException, IllegalAccessException { public void execute() throws ElementException {
// Start xsd generator // Start xsd generator
X4ODriver<?> driver = X4ODriverManager.getX4ODriver(getLanguage()); X4ODriver<?> driver = X4ODriverManager.getX4ODriver(getLanguage());
X4OSchemaWriter xsd = driver.createSchemaWriter(driver.getLanguageVersionDefault()); X4OSchemaWriter xsd = driver.createSchemaWriter(driver.getLanguageVersionDefault());

View file

@ -21,11 +21,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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 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 org.x4o.xml.test.swixml.SwiXmlDriver;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -36,7 +38,7 @@ import junit.framework.TestCase;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Auh 16, 2012 * @version 1.0 Auh 16, 2012
*/ */
public class EldSchemaTest extends TestCase { public class X4OWriteLanguageSchemaExecutorTest extends TestCase {
private File getTempPath(String dir) throws Exception { private File getTempPath(String dir) throws Exception {
File tempFile = File.createTempFile("test-path", ".tmp"); File tempFile = File.createTempFile("test-path", ".tmp");
@ -51,27 +53,27 @@ public class EldSchemaTest extends TestCase {
} }
public void testEldSchema() throws Exception { public void testEldSchema() throws Exception {
X4OSchemaWriterExecutor writer = new X4OSchemaWriterExecutor(); X4OWriteLanguageSchemaExecutor writer = new X4OWriteLanguageSchemaExecutor();
writer.setBasePath(getTempPath("junit-xsd-eld")); writer.setBasePath(getTempPath("junit-xsd-eld"));
writer.setLanguage(EldDriver.LANGUAGE_NAME); writer.setLanguage(EldDriver.LANGUAGE_NAME);
writer.execute(); writer.execute();
} }
public void testEldCoreSchema() throws Exception { public void testEldCoreSchema() throws Exception {
X4OSchemaWriterExecutor writer = new X4OSchemaWriterExecutor(); X4OWriteLanguageSchemaExecutor writer = new X4OWriteLanguageSchemaExecutor();
writer.setBasePath(getTempPath("junit-xsd-cel")); writer.setBasePath(getTempPath("junit-xsd-cel"));
writer.setLanguage(CelDriver.LANGUAGE_NAME); writer.setLanguage(CelDriver.LANGUAGE_NAME);
writer.execute(); writer.execute();
} }
public void testSwiXmlSchema() throws Exception { public void testSwiXmlSchema() throws Exception {
X4OSchemaWriterExecutor writer = new X4OSchemaWriterExecutor(); X4OWriteLanguageSchemaExecutor writer = new X4OWriteLanguageSchemaExecutor();
writer.setBasePath(getTempPath("junit-xsd-swixml2")); writer.setBasePath(getTempPath("junit-xsd-swixml2"));
writer.setLanguage(SwiXmlDriver.LANGUAGE_NAME); writer.setLanguage(SwiXmlDriver.LANGUAGE_NAME);
writer.execute(); writer.execute();
} }
public void testEldDocMain() throws Exception { 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});
} }
} }

View file

@ -34,19 +34,19 @@ import org.x4o.xml.element.ElementException;
import org.x4o.xml.lang.X4OLanguageContext; 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 * @author Willem Cazander
* @version 1.0 Aug 22, 2012 * @version 1.0 Aug 22, 2012
*/ */
public class X4ODocWriterExecutor { public class X4OWriteLanguageDocExecutor {
private String language = null; private String language = null;
private String languageVersion = null; private String languageVersion = null;
private File basePath; private File basePath;
static public void main(String argu[]) { static public void main(String argu[]) {
X4ODocWriterExecutor languageSchema = new X4ODocWriterExecutor(); X4OWriteLanguageDocExecutor languageSchema = new X4OWriteLanguageDocExecutor();
List<String> arguList = Arrays.asList(argu); List<String> arguList = Arrays.asList(argu);
Iterator<String> arguIterator = arguList.iterator(); Iterator<String> arguIterator = arguList.iterator();
while (arguIterator.hasNext()) { while (arguIterator.hasNext()) {

View file

@ -39,7 +39,7 @@ import junit.framework.TestCase;
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 26, 2010 * @version 1.0 Aug 26, 2010
*/ */
public class EldDocTest extends TestCase { public class X4OWriteLanguageDocExecutorTest extends TestCase {
private File getTempPath(String dir) throws Exception { private File getTempPath(String dir) throws Exception {
File tempFile = File.createTempFile("test-path", ".tmp"); File tempFile = File.createTempFile("test-path", ".tmp");
@ -54,28 +54,28 @@ public class EldDocTest extends TestCase {
} }
public void testCelDoc() throws Exception { public void testCelDoc() throws Exception {
X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
writer.setBasePath(getTempPath("junit-cel")); writer.setBasePath(getTempPath("junit-cel"));
writer.setLanguage(CelDriver.LANGUAGE_NAME); writer.setLanguage(CelDriver.LANGUAGE_NAME);
writer.execute(); writer.execute();
} }
public void testEldDoc() throws Exception { public void testEldDoc() throws Exception {
X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
writer.setBasePath(getTempPath("junit-eld")); writer.setBasePath(getTempPath("junit-eld"));
writer.setLanguage(EldDriver.LANGUAGE_NAME); writer.setLanguage(EldDriver.LANGUAGE_NAME);
writer.execute(); writer.execute();
} }
public void testUnitDoc() throws Exception { public void testUnitDoc() throws Exception {
X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
writer.setBasePath(getTempPath("junit-test")); writer.setBasePath(getTempPath("junit-test"));
writer.setLanguage(TestDriver.LANGUAGE_NAME); writer.setLanguage(TestDriver.LANGUAGE_NAME);
writer.execute(); writer.execute();
} }
public void testSwiXml2Doc() throws Exception { public void testSwiXml2Doc() throws Exception {
X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
writer.setBasePath(getTempPath("junit-swixml2")); writer.setBasePath(getTempPath("junit-swixml2"));
writer.setLanguage(SwiXmlDriver.LANGUAGE_NAME); writer.setLanguage(SwiXmlDriver.LANGUAGE_NAME);
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2); writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_2);
@ -83,7 +83,7 @@ public class EldDocTest extends TestCase {
} }
public void testSwiXml3Doc() throws Exception { public void testSwiXml3Doc() throws Exception {
X4ODocWriterExecutor writer = new X4ODocWriterExecutor(); X4OWriteLanguageDocExecutor writer = new X4OWriteLanguageDocExecutor();
writer.setBasePath(getTempPath("junit-swixml3")); writer.setBasePath(getTempPath("junit-swixml3"));
writer.setLanguage(SwiXmlDriver.LANGUAGE_NAME); writer.setLanguage(SwiXmlDriver.LANGUAGE_NAME);
writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3); writer.setLanguageVersion(SwiXmlDriver.LANGUAGE_VERSION_3);
@ -92,6 +92,6 @@ public class EldDocTest extends TestCase {
public void testEldDocMain() throws Exception { 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});
} }
} }

View file

@ -12,8 +12,7 @@
<name>x4o-plugin</name> <name>x4o-plugin</name>
<description>x4o plugins for other applications</description> <description>x4o plugins for other applications</description>
<modules> <modules>
<module>x4o-plugin-ant-schema</module> <module>x4o-plugin-ant</module>
<module>x4o-plugin-ant-elddoc</module>
</modules> </modules>
<build> <build>
<pluginManagement> <pluginManagement>

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>x4o-plugin-ant-schema</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -1,141 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>x4o-plugin</artifactId>
<groupId>org.x4o.plugin</groupId>
<version>0.8.5-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>x4o-plugin-ant-schema</artifactId>
<packaging>jar</packaging>
<name>x4o-plugin-ant-schema</name>
<description>Creates schema for languauge</description>
<dependencies>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>${ant.version}</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-testutil</artifactId>
<version>${ant-testutil.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel</artifactId>
<version>${juel.version}</version>
</dependency>
<dependency>
<groupId>org.x4o</groupId>
<artifactId>x4o-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>${xerces.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site-plugin.version}</version>
<configuration>
<siteDirectory>${project.basedir}/../../src/site-child</siteDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>update-schema-cel</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>update-schema-cel-ant</id>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
<taskdef name="eldXsdWriter" classname="org.x4o.plugin.ant.eld.xsd.EldXsdWriterTask" classpathref="maven.plugin.classpath"/>
<eldXsdWriter destdir="${coredir}/cel" language="cel"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin-ant-schema</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>update-schema-eld</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>update-schema-eld-ant</id>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
<taskdef name="eldXsdWriter" classname="org.x4o.plugin.ant.eld.xsd.EldXsdWriterTask" classpathref="maven.plugin.classpath"/>
<eldXsdWriter destdir="${coredir}/eld" language="eld"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin-ant-schema</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View file

@ -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;
}
}

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>x4o-plugin-ant-elddoc</name> <name>x4o-plugin-ant</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

View file

@ -1,15 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>x4o-plugin</artifactId>
<groupId>org.x4o.plugin</groupId> <groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin</artifactId>
<version>0.8.5-SNAPSHOT</version> <version>0.8.5-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent> </parent>
<artifactId>x4o-plugin-ant-elddoc</artifactId> <artifactId>x4o-plugin-ant</artifactId>
<packaging>jar</packaging> <name>x4o-plugin-ant</name>
<name>x4o-plugin-ant-elddoc</name> <description>x4o-plugin-ant</description>
<description>Creates elddoc for languauge</description>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.x4o</groupId> <groupId>org.x4o</groupId>
@ -42,7 +40,6 @@
<groupId>de.odysseus.juel</groupId> <groupId>de.odysseus.juel</groupId>
<artifactId>juel</artifactId> <artifactId>juel</artifactId>
<version>${juel.version}</version> <version>${juel.version}</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.x4o</groupId> <groupId>org.x4o</groupId>
@ -73,6 +70,76 @@
</pluginManagement> </pluginManagement>
</build> </build>
<profiles> <profiles>
<profile>
<id>update-schema-cel</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>update-schema-cel-ant</id>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
<taskdef name="writeLanguageSchema" classname="org.x4o.plugin.ant.X4OWriteLanguageSchemaTask" classpathref="maven.plugin.classpath"/>
<writeLanguageSchema destdir="${coredir}/cel" language="cel"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin-ant-schema</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>update-schema-eld</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<id>update-schema-eld-ant</id>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="coredir" value="${basedir}/../../x4o-core/src/main/resources/META-INF"/>
<taskdef name="writeLanguageSchema" classname="org.x4o.plugin.ant.X4OWriteLanguageSchemaTask" classpathref="maven.plugin.classpath"/>
<writeLanguageSchema destdir="${coredir}/cel" language="cel"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin-ant-schema</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile> <profile>
<id>site-elddoc</id> <id>site-elddoc</id>
<build> <build>
@ -93,12 +160,12 @@
<mkdir dir="${coredir}/junit-test"/> <mkdir dir="${coredir}/junit-test"/>
<mkdir dir="${coredir}/junit-swixml2"/> <mkdir dir="${coredir}/junit-swixml2"/>
<mkdir dir="${coredir}/junit-swixml3"/> <mkdir dir="${coredir}/junit-swixml3"/>
<taskdef name="eldDocWriter" classname="org.x4o.plugin.ant.eld.doc.EldDocWriterTask" classpathref="maven.plugin.classpath"/> <taskdef name="writeLanguageDoc" classname="org.x4o.plugin.ant.X4OWriteLanguageDocTask" classpathref="maven.plugin.classpath"/>
<eldDocWriter destdir="${coredir}/cel" language="cel"/> <writeLanguageDoc destdir="${coredir}/cel" language="cel"/>
<eldDocWriter destdir="${coredir}/eld" language="eld"/> <writeLanguageDoc destdir="${coredir}/eld" language="eld"/>
<eldDocWriter destdir="${coredir}/junit-test" language="test"/> <writeLanguageDoc destdir="${coredir}/junit-test" language="test"/>
<eldDocWriter destdir="${coredir}/junit-swixml2" language="swixml" version="2.0"/> <writeLanguageDoc destdir="${coredir}/junit-swixml2" language="swixml" version="2.0"/>
<eldDocWriter destdir="${coredir}/junit-swixml3" language="swixml"/> <writeLanguageDoc destdir="${coredir}/junit-swixml3" language="swixml"/>
</target> </target>
</configuration> </configuration>
<goals> <goals>
@ -109,7 +176,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.x4o.plugin</groupId> <groupId>org.x4o.plugin</groupId>
<artifactId>x4o-plugin-ant-elddoc</artifactId> <artifactId>x4o-plugin-ant</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>

View file

@ -21,7 +21,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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 java.io.File;
@ -29,16 +29,14 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; 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 * @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 language = null;
private String destdir = null; private String destdir = null;
@ -52,7 +50,14 @@ public class EldDocWriterTask extends Task {
@Override @Override
public void execute() throws BuildException { public void execute() throws BuildException {
try { 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) { } catch (BuildException e) {
if (isFailonerror()) { if (isFailonerror()) {
throw e; throw e;
@ -62,42 +67,36 @@ public class EldDocWriterTask extends Task {
} }
} }
private void executeTask() throws BuildException { private void executeLanguageTask() throws BuildException {
if (getLanguage()==null) { if (getLanguage()==null) {
throw new BuildException("language attribute is not set."); throw new BuildException("language attribute is not set.");
} }
if (getDestdir()==null) { if (getDestdir()==null) {
throw new BuildException("basePath attribute is not set."); throw new BuildException("basePath attribute is not set.");
} }
if (isVerbose()) { if (getLanguage().length()==0) {
log("Execute task from: "+getLocation()); throw new BuildException("language attribute is empty.");
log("language:"+getLanguage()); }
log("destdir:"+getDestdir()); if (getDestdir().length()==0) {
log("verbose:"+isVerbose()); throw new BuildException("basePath attribute is empty.");
log("failonerror:"+isFailonerror());
} }
File basePathFile = new File(getDestdir()); File basePathFile = new File(getDestdir());
if (basePathFile.exists()==false) { if (basePathFile.exists()==false) {
throw new BuildException("destdir does not exists: "+basePathFile); 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()) { if (isVerbose()) {
log("Starting writing."); log("Starting "+getLanguageTaskName());
} }
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
writer.execute(); executeLanguageTask(basePathFile);
long stopTime = System.currentTimeMillis(); long stopTime = System.currentTimeMillis();
log("Done writing elddoc in "+(stopTime-startTime)+" ms."); log("Done "+getLanguageTaskName()+" in "+(stopTime-startTime)+" ms.");
} catch (ElementException e) {
throw new BuildException(e);
}
} }
abstract String getLanguageTaskName();
abstract void executeLanguageTask(File basePath) throws BuildException;
/** /**
* @return the language * @return the language
*/ */

View file

@ -21,10 +21,44 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/** package org.x4o.plugin.ant;
* The ant x4o schema plugin.
*
* @since 1.0
*/
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);
}
}
}

View file

@ -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;
}
}

View file

@ -22,9 +22,9 @@
*/ */
/** /**
* The ant elddoc plugin. * The ant plugin tasks.
* *
* @since 1.0 * @since 1.0
*/ */
package org.x4o.plugin.ant.eld.doc; package org.x4o.plugin.ant;

View file

@ -21,22 +21,22 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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 java.io.File;
import org.apache.tools.ant.BuildFileTest; import org.apache.tools.ant.BuildFileTest;
/** /**
* SchemaTaskTest tests the schema ant task. * X4OWriteDocTaskTest tests the doc ant task.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 23, 2012 * @version 1.0 Aug 23, 2012
*/ */
public class EldDocWriterTaskTest extends BuildFileTest { public class X4OWriteLanguageDocTaskTest extends BuildFileTest {
public void setUp() { 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() { public void testEldDocCel() {
@ -59,7 +59,7 @@ public class EldDocWriterTaskTest extends BuildFileTest {
public void testEldDocEldVerbose() { public void testEldDocEldVerbose() {
executeTarget("test-elddoc-cel-verbose"); executeTarget("test-elddoc-cel-verbose");
assertLogContaining("verbose:"); assertLogContaining("Verbose:");
} }
public void testFailAllMissing() { public void testFailAllMissing() {

View file

@ -21,22 +21,22 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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 java.io.File;
import org.apache.tools.ant.BuildFileTest; import org.apache.tools.ant.BuildFileTest;
/** /**
* SchemaTaskTest tests the schema ant task. * X4OWriteSchemaTaskTest tests the schema ant task.
* *
* @author Willem Cazander * @author Willem Cazander
* @version 1.0 Aug 23, 2012 * @version 1.0 Aug 23, 2012
*/ */
public class EldXsdWriterTaskTest extends BuildFileTest { public class X4OWriteLanguageSchemaTaskTest extends BuildFileTest {
public void setUp() { 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() { public void testCelSchemaFull() {
@ -59,7 +59,7 @@ public class EldXsdWriterTaskTest extends BuildFileTest {
public void testCelSchemaVerbose() { public void testCelSchemaVerbose() {
executeTarget("test-cel-schema-verbose"); executeTarget("test-cel-schema-verbose");
assertLogContaining("verbose:"); assertLogContaining("Verbose:");
} }
public void testFailAllMissing() { public void testFailAllMissing() {

View file

@ -28,14 +28,14 @@
<property name="test.dir" value="${basedir}/target/test-elddoc/"/> <property name="test.dir" value="${basedir}/target/test-elddoc/"/>
<target name="init"> <target name="init">
<taskdef name="eldDocWriter" classname="org.x4o.plugin.ant.eld.doc.EldDocWriterTask"/> <taskdef name="writeLanguageDoc" classname="org.x4o.plugin.ant.X4OWriteLanguageDocTask"/>
<mkdir dir="${test.dir}"/> <mkdir dir="${test.dir}"/>
<mkdir dir="${test.dir}/test"/> <mkdir dir="${test.dir}/test"/>
</target> </target>
<target name="test-elddoc-cel" depends="init"> <target name="test-elddoc-cel" depends="init">
<mkdir dir="${test.dir}/cel"/> <mkdir dir="${test.dir}/cel"/>
<eldDocWriter <writeLanguageDoc
destdir="${test.dir}/cel" destdir="${test.dir}/cel"
language="cel" language="cel"
/> />
@ -43,7 +43,7 @@
<target name="test-elddoc-cel-verbose" depends="init"> <target name="test-elddoc-cel-verbose" depends="init">
<mkdir dir="${test.dir}/cel"/> <mkdir dir="${test.dir}/cel"/>
<eldDocWriter <writeLanguageDoc
verbose="true" verbose="true"
destdir="${test.dir}/cel" destdir="${test.dir}/cel"
language="cel" language="cel"
@ -52,26 +52,26 @@
<target name="test-elddoc-eld" depends="init"> <target name="test-elddoc-eld" depends="init">
<mkdir dir="${test.dir}/eld"/> <mkdir dir="${test.dir}/eld"/>
<eldDocWriter <writeLanguageDoc
destdir="${test.dir}/eld" destdir="${test.dir}/eld"
language="cel" language="cel"
/> />
</target> </target>
<target name="test-fail-all" depends="init"> <target name="test-fail-all" depends="init">
<eldDocWriter/> <writeLanguageDoc/>
</target> </target>
<target name="test-fail-destdir" depends="init"> <target name="test-fail-destdir" depends="init">
<eldDocWriter language="cel"/> <writeLanguageDoc language="cel"/>
</target> </target>
<target name="test-fail-destdir-error" depends="init"> <target name="test-fail-destdir-error" depends="init">
<eldDocWriter language="cel" destdir="${test.dir}/no-dir"/> <writeLanguageDoc language="cel" destdir="${test.dir}/no-dir"/>
</target> </target>
<target name="test-fail-language" depends="init"> <target name="test-fail-language" depends="init">
<eldDocWriter destdir="${test.dir}/test"/> <writeLanguageDoc destdir="${test.dir}/test"/>
</target> </target>
<target name="test-fail-language-error" depends="init"> <target name="test-fail-language-error" depends="init">
<eldDocWriter destdir="${test.dir}/test" language="cel-error"/> <writeLanguageDoc destdir="${test.dir}/test" language="cel-error"/>
</target> </target>
</project> </project>

View file

@ -28,14 +28,14 @@
<property name="test.dir" value="${basedir}/target/test-schemas/"/> <property name="test.dir" value="${basedir}/target/test-schemas/"/>
<target name="init"> <target name="init">
<taskdef name="eldXsdWriter" classname="org.x4o.plugin.ant.eld.xsd.EldXsdWriterTask"/> <taskdef name="writeLanguageSchema" classname="org.x4o.plugin.ant.X4OWriteLanguageSchemaTask"/>
<mkdir dir="${test.dir}"/> <mkdir dir="${test.dir}"/>
<mkdir dir="${test.dir}/test"/> <mkdir dir="${test.dir}/test"/>
</target> </target>
<target name="test-cel-schema-full" depends="init"> <target name="test-cel-schema-full" depends="init">
<mkdir dir="${test.dir}/cel-full"/> <mkdir dir="${test.dir}/cel-full"/>
<eldXsdWriter <writeLanguageSchema
destdir="${test.dir}/cel-full" destdir="${test.dir}/cel-full"
language="eld" language="eld"
/> />
@ -43,7 +43,7 @@
<target name="test-cel-schema-single" depends="init"> <target name="test-cel-schema-single" depends="init">
<mkdir dir="${test.dir}/cel-single"/> <mkdir dir="${test.dir}/cel-single"/>
<eldXsdWriter <writeLanguageSchema
destdir="${test.dir}/cel-single" destdir="${test.dir}/cel-single"
language="cel" language="cel"
nsuri="http://cel.x4o.org/xml/ns/cel-core" nsuri="http://cel.x4o.org/xml/ns/cel-core"
@ -52,7 +52,7 @@
<target name="test-cel-schema-verbose" depends="init"> <target name="test-cel-schema-verbose" depends="init">
<mkdir dir="${test.dir}/cel-single"/> <mkdir dir="${test.dir}/cel-single"/>
<eldXsdWriter <writeLanguageSchema
verbose="true" verbose="true"
destdir="${test.dir}/cel-single" destdir="${test.dir}/cel-single"
language="cel" language="cel"
@ -61,19 +61,19 @@
</target> </target>
<target name="test-fail-all" depends="init"> <target name="test-fail-all" depends="init">
<eldXsdWriter/> <writeLanguageSchema/>
</target> </target>
<target name="test-fail-destdir" depends="init"> <target name="test-fail-destdir" depends="init">
<eldXsdWriter language="cel"/> <writeLanguageSchema language="cel"/>
</target> </target>
<target name="test-fail-destdir-error" depends="init"> <target name="test-fail-destdir-error" depends="init">
<eldXsdWriter language="cel" destdir="${test.dir}/no-dir"/> <writeLanguageSchema language="cel" destdir="${test.dir}/no-dir"/>
</target> </target>
<target name="test-fail-language" depends="init"> <target name="test-fail-language" depends="init">
<eldXsdWriter destdir="${test.dir}/test"/> <writeLanguageSchema destdir="${test.dir}/test"/>
</target> </target>
<target name="test-fail-language-error" depends="init"> <target name="test-fail-language-error" depends="init">
<eldXsdWriter destdir="${test.dir}/test" language="eld-error"/> <writeLanguageSchema destdir="${test.dir}/test" language="eld-error"/>
</target> </target>
</project> </project>