Nice question..I saw it just today and it was fun running the plugin from command line :)
The answer lies in the org.generama.tests.AbstractPluginTestCase
May there is a better way but i liked this one.
I tweaked it a little bit to create AbstractRunPluginFromCommandLineUtil
You can extend this for your plugin and see if it works. Mine works.
Also my plugin sets the Destdir and Filereplace attribute from within the plugin.
*************AbstractRunPluginFromCommandLineUtil.java****************
import org.generama.MetadataProvider;
import org.generama.Plugin;
import org.generama.WriterMapper;
import org.generama.defaults.Outcome;
import org.generama.defaults.FileWriterMapper;
abstract class AbstractRunPluginFromCommandLineUtil{
protected Plugin plugin;
private WriterMapper writerMapper;
public AbstractRunPluginFromCommandLineUtil() throws Throwable {
writerMapper = new FileWriterMapper();
plugin = createPlugin(createMetadataProvider(), writerMapper);
run();
}
public void run() throws Throwable {
plugin.start();
}
protected abstract Plugin createPlugin(MetadataProvider metadataProvider, WriterMapper writerMapper) throws Exception;
protected abstract MetadataProvider createMetadataProvider() throws Exception;
}
**********************************************************************
/** my plugin and template engine, you can have yours **/
import com.xdoclet2tutorial.plugin.command.GroovyCommandPlugin;
import com.xdoclet2tutorial.templateengine.groovy.GroovyTemplateEngine;
import org.xdoclet.QDoxMetadataProvider;
import java.io.File;
import java.io.IOException;
import java.net.URL;
public class RunGroovyCommandPluginFromCommandLineUtil extends AbstractRunPluginFromCommandLineUtil {
public RunCommandPluginFromCommandLineUtil() throws Throwable{
super();
}
protected MetadataProvider createMetadataProvider() throws IOException {
URL reader = new File("D:/lab/xdoclet2/src/main/java").toURL();
return new QDoxMetadataProvider(new File(reader.getPath()));
}
protected Plugin createPlugin(MetadataProvider metadataProvider, WriterMapper writerMapper)
throws Exception {
return new GroovyCommandPlugin(new GroovyTemplateEngine(), (QDoxMetadataProvider) metadataProvider, writerMapper);
}
public static void main(String[] args) throws Throwable{
AbstractRunPluginFromCommandLineUtil util = new RunCommandPluginFromCommandLineUtil();
}
}
regards,
karthik