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