You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2010/08/23 21:09:07 UTC
svn commit: r988254 - in /db/torque/torque4/trunk/torque-ant-tasks: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/torque/ src/main/java/org/apache/torque/ant/
src/main/java/org/apache/torque/ant/...
Author: tfischer
Date: Mon Aug 23 19:09:05 2010
New Revision: 988254
URL: http://svn.apache.org/viewvc?rev=988254&view=rev
Log:
Created ant tasks project
Added:
db/torque/torque4/trunk/torque-ant-tasks/pom.xml
db/torque/torque4/trunk/torque-ant-tasks/src/
db/torque/torque4/trunk/torque-ant-tasks/src/main/
db/torque/torque4/trunk/torque-ant-tasks/src/main/java/
db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/
db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/
db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/
db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/
db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/
db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/Option.java
db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java
db/torque/torque4/trunk/torque-ant-tasks/src/test/
db/torque/torque4/trunk/torque-ant-tasks/src/test/java/
db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/
db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/apache/
db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/apache/torque/
db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/apache/torque/ant/
db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/apache/torque/ant/task/
db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/apache/torque/ant/task/TorqueGeneratorTaskTest.java
db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/
db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/org/
db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/org/apache/
db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/org/apache/torque/
db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/org/apache/torque/ant/
db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/org/apache/torque/ant/PropertyKeys.java
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/conf/
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/conf/control.xml
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/outlets/
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/outlets/enumOutlets.xml
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/src/
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/src/propertiesData.properties
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/classFrame.vm
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constant.vm
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constructor.vm
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/getKey.vm
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/keyField.vm
db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/toString.vm
Modified:
db/torque/torque4/trunk/torque-ant-tasks/ (props changed)
Propchange: db/torque/torque4/trunk/torque-ant-tasks/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Aug 23 19:09:05 2010
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project
Added: db/torque/torque4/trunk/torque-ant-tasks/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/pom.xml?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/pom.xml (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/pom.xml Mon Aug 23 19:09:05 2010
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<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/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.torque</groupId>
+ <artifactId>torque-maven-parent</artifactId>
+ <version>4.0-alpha1-SNAPSHOT</version>
+ <relativePath>../torque-maven-parent</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>torque-generator-ant-tasks</artifactId>
+ <packaging>jar</packaging>
+ <name>Torque Generator Ant tasks</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.torque</groupId>
+ <artifactId>torque-generator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.8.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit-addons</groupId>
+ <artifactId>junit-addons</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/Option.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/Option.java?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/Option.java (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/Option.java Mon Aug 23 19:09:05 2010
@@ -0,0 +1,30 @@
+package org.apache.torque.ant.task;
+
+public class Option
+{
+ private String key;
+
+ private String value;
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey(String key)
+ {
+ this.key = key;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+
+}
Added: db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/main/java/org/apache/torque/ant/task/TorqueGeneratorTask.java Mon Aug 23 19:09:05 2010
@@ -0,0 +1,431 @@
+package org.apache.torque.ant.task;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.torque.generator.configuration.ConfigurationException;
+import org.apache.torque.generator.configuration.UnitDescriptor;
+import org.apache.torque.generator.configuration.UnitDescriptor.Packaging;
+import org.apache.torque.generator.configuration.controller.Loglevel;
+import org.apache.torque.generator.configuration.option.MapOptionsConfiguration;
+import org.apache.torque.generator.configuration.option.OptionsConfiguration;
+import org.apache.torque.generator.configuration.paths.CustomProjectPaths;
+import org.apache.torque.generator.configuration.paths.DefaultTorqueGeneratorPaths;
+import org.apache.torque.generator.configuration.paths.Maven2DirectoryProjectPaths;
+import org.apache.torque.generator.configuration.paths.Maven2JarProjectPaths;
+import org.apache.torque.generator.configuration.paths.ProjectPaths;
+import org.apache.torque.generator.control.Controller;
+import org.apache.torque.generator.file.Fileset;
+import org.apache.torque.generator.source.stream.FileSourceProvider;
+
+/**
+ * Executes a unit of generation within the torque generator.
+ *
+ * $Id: $
+ *
+ * @goal generate
+ */
+public class TorqueGeneratorTask extends Task
+{
+ /**
+ * The packaging type of the generation unit, either "directory" , "jar"
+ * or "classpath". Default is "directory".
+ */
+ private String packaging = "directory";
+
+ /**
+ * The root directory of the project.
+ * Has no effect if packaging is "classpath".
+ * Default is ".".
+ */
+ private File projectRootDir = new File(".");
+
+ /**
+ * The configuration directory of the generation unit.
+ * Has no effect if packaging is "classpath".
+ */
+ private File configDir;
+
+ /**
+ * The configuration package of the generation unit.
+ * Has only effect if packaging is "classpath".
+ */
+ private String configPackage;
+
+ /**
+ * The directory where the source files reside.
+ */
+ private File sourceDir;
+
+ /**
+ * Include patterns for the source files.
+ * If set, the include and exclude patterns from the templates
+ * are overridden.
+ * If not set, then the include patterns from the templates are used.
+ * The patterns are case sensitive, wildcards are * and ?.
+ */
+ private Set<String> sourceIncludes;
+
+ /**
+ * Exclude patterns for the source files.
+ * If set, the include and exclude patterns from the templates
+ * are overridden.
+ * If not set, then the include patterns from the templates are used.
+ * The patterns are case sensitive, wildcards are * and ?.
+ */
+ private Set<String> sourceExcludes;
+
+ /**
+ * The target directory for files which are generated each time anew.
+ * Default is "./generated-sources"
+ */
+ private File newFileTargetDir = new File("target/generated-sources");
+
+ /**
+ * The target directory for files which are not generated each time anew.
+ * Default is "./src/main/generated-java"
+ */
+ private File modifiedFileTargetDir = new File("src/main/generated-java");
+
+ /**
+ * The filename of the jar file of the generation unit.
+ * Has only effect if packaging is "jar".
+ */
+ private String jarFile;
+
+ /**
+ * The config directory of the project overriding the settings.
+ * If set, the settings of this directory are used as "child"
+ * and the "normal" settings are used as "parent".
+ */
+ private File overrideConfigDir;
+
+ /**
+ * The Loglevel to use in the generation process. Must be one of
+ * trace, debug, info, warn or error.
+ */
+ private String loglevel;
+
+ private List<Option> options = new ArrayList<Option>();
+
+ public Option createOption()
+ {
+ Option option = new Option();
+ options.add(option);
+ return option;
+ }
+
+ public void execute() throws BuildException
+ {
+ Controller controller = new Controller();
+ List<UnitDescriptor> unitDescriptors = new ArrayList<UnitDescriptor>();
+
+ UnitDescriptor.Packaging packaging;
+ if ("jar".equals(this.packaging))
+ {
+ packaging = UnitDescriptor.Packaging.JAR;
+ }
+ else if ("directory".equals(this.packaging))
+ {
+ packaging = UnitDescriptor.Packaging.DIRECTORY;
+ }
+ else if ("classpath".equals(this.packaging))
+ {
+ packaging = UnitDescriptor.Packaging.CLASSPATH;
+ }
+ else
+ {
+ throw new IllegalArgumentException(
+ "Unknown packaging " + this.packaging
+ + ", must be jar, directory or classpath");
+ }
+ log("Packaging is " + packaging, Project.MSG_DEBUG);
+
+ ProjectPaths defaultProjectPaths;
+ if (UnitDescriptor.Packaging.JAR == packaging)
+ {
+ defaultProjectPaths
+ = new Maven2JarProjectPaths(projectRootDir, jarFile);
+ }
+ else if (UnitDescriptor.Packaging.DIRECTORY == packaging)
+ {
+ defaultProjectPaths
+ = new Maven2DirectoryProjectPaths(projectRootDir);
+ }
+ else if (UnitDescriptor.Packaging.CLASSPATH == packaging)
+ {
+ defaultProjectPaths
+ = new Maven2DirectoryProjectPaths(projectRootDir);
+ }
+ else
+ {
+ throw new IllegalStateException("Unknown packaging" + packaging);
+ }
+
+ CustomProjectPaths projectPaths
+ = new CustomProjectPaths(defaultProjectPaths);
+
+ if (UnitDescriptor.Packaging.CLASSPATH == packaging)
+ {
+ if (configPackage == null)
+ {
+ throw new BuildException(
+ "configPackage must be set for packaging =\"classpath\"");
+ }
+ projectPaths.setConfigurationPackage(configPackage);
+ projectPaths.setConfigurationDir(null);
+ }
+ else
+ {
+ if (configDir != null)
+ {
+ projectPaths.setConfigurationDir(configDir);
+ log("Setting config dir to " + configDir.toString(),
+ Project.MSG_DEBUG);
+ }
+ }
+
+ if (sourceDir != null)
+ {
+ projectPaths.setSourceDir(sourceDir);
+ log("Setting source dir to " + sourceDir.toString(),
+ Project.MSG_DEBUG);
+ }
+
+ FileSourceProvider fileSourceProvider = null;
+ if (sourceIncludes != null || sourceExcludes != null)
+ {
+ Fileset sourceFileset
+ = new Fileset(
+ projectPaths.getDefaultSourcePath(),
+ sourceIncludes,
+ sourceExcludes);
+ log("Setting source includes to " + sourceIncludes,
+ Project.MSG_DEBUG);
+ log("Setting source excludes to " + sourceExcludes,
+ Project.MSG_DEBUG);
+ try
+ {
+ fileSourceProvider
+ = new FileSourceProvider(null, sourceFileset);
+ }
+ catch (ConfigurationException e)
+ {
+ throw new BuildException(
+ "The source provider cannot be instantiated", e);
+ }
+ }
+
+ if (newFileTargetDir != null)
+ {
+ projectPaths.setNewFileTargetDir(newFileTargetDir);
+ log("Setting newFileTargetDir to " + newFileTargetDir.toString(),
+ Project.MSG_DEBUG);
+ }
+ if (modifiedFileTargetDir != null)
+ {
+ projectPaths.setModifiedFileTargetDir(modifiedFileTargetDir);
+ log("Setting modifiedFileTargetDir to "
+ + modifiedFileTargetDir.toString(),
+ Project.MSG_DEBUG);
+ }
+ log("ProjectPaths = " + projectPaths, Project.MSG_DEBUG);
+
+ OptionsConfiguration optionConfiguration = null;
+ if (!options.isEmpty())
+ {
+ Map<String, String> optionsMap = new HashMap<String, String>();
+ for (Option option : options)
+ {
+ optionsMap.put(option.getKey(), option.getValue());
+ }
+ optionConfiguration = new MapOptionsConfiguration(optionsMap);
+ }
+ Loglevel convertedLoglevel = null;
+ if (this.loglevel != null)
+ {
+ convertedLoglevel = Loglevel.getByKey(loglevel);
+ }
+ UnitDescriptor unitDescriptor = new UnitDescriptor(
+ packaging,
+ projectPaths,
+ new DefaultTorqueGeneratorPaths(),
+ null,
+ fileSourceProvider,
+ optionConfiguration,
+ convertedLoglevel);
+ log("unit descriptor created", Project.MSG_DEBUG);
+ if (overrideConfigDir != null)
+ {
+ CustomProjectPaths childProjectPaths
+ = new CustomProjectPaths(projectPaths);
+ childProjectPaths.setConfigurationDir(overrideConfigDir);
+
+ unitDescriptor = new UnitDescriptor(
+ Packaging.DIRECTORY,
+ childProjectPaths,
+ new DefaultTorqueGeneratorPaths(),
+ unitDescriptor,
+ fileSourceProvider,
+ optionConfiguration,
+ convertedLoglevel);
+ log("child unit descriptor created",Project.MSG_DEBUG);
+ }
+ unitDescriptors.add(unitDescriptor);
+ try
+ {
+ log("Generation started", Project.MSG_DEBUG);
+ controller.run(unitDescriptors);
+ log("Generation successful", Project.MSG_INFO);
+ }
+ catch (Exception e)
+ {
+ log("Error during generation", e, Project.MSG_ERR);
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+ /**
+ * Sets the packaging.
+ *
+ * @param packaging the packaging, either "jar" or "directory"
+ */
+ public void setPackaging(String packaging)
+ {
+ this.packaging = packaging;
+ }
+
+ /**
+ * Sets the root directory of the project.
+ *
+ * @param projectRootDir the project root Directory.
+ */
+ public void setProjectRootDir(File projectRootDir)
+ {
+ this.projectRootDir = projectRootDir;
+ }
+
+ public void setConfigDir(File configDir)
+ {
+ this.configDir = configDir;
+ }
+
+ public void setConfigPackage(String configPackage)
+ {
+ this.configPackage = configPackage;
+ }
+
+ /**
+ * Sets the target directory for files which are generated each time anew.
+ *
+ * @param targetDir the target directory, or null to use the default.
+ */
+ public void setNewFileTargetDir(File targetDir)
+ {
+ this.newFileTargetDir = targetDir;
+ }
+
+ /**
+ * Sets the target directory for files which are not generated
+ * each time anew.
+ *
+ * @param targetDir the target directory, or null to use the default.
+ */
+ public void setModifiedFileTargetDir(File targetDir)
+ {
+ this.modifiedFileTargetDir = targetDir;
+ }
+
+ /**
+ * The path to the jar file to use.
+ *
+ * @param jarFile the jar file, or null.
+ */
+ public void setJarFile(String jarFile)
+ {
+ this.jarFile = jarFile;
+ }
+
+ /**
+ * Sets the directory in which the source files are located.
+ *
+ * @param sourceDir the directory in which the source files are located.
+ */
+ public void setSourceDir(File sourceDir)
+ {
+ this.sourceDir = sourceDir;
+ }
+
+ /**
+ * Sets the pattern which files are included in the generation process.
+ *
+ * @param sourceIncludes a list containing the include patterns, or null
+ * if no include pattern should be used.
+ */
+ public void setSourceIncludes(Set<String> sourceIncludes)
+ {
+ this.sourceIncludes = sourceIncludes;
+ }
+
+ /**
+ * Sets the pattern which files are excluded in the generation process.
+ *
+ * @param sourceExcludes a list containing the exclude patterns, or null
+ * if no exclude pattern should be used.
+ */
+ public void setSourceExcludes(Set<String> sourceExcludes)
+ {
+ this.sourceExcludes = sourceExcludes;
+ }
+
+ /**
+ * Sets the config directory overriding the template settings.
+ * If set, the settings of this directory are used as "child"
+ * and the "normal" settings are used as "parent".
+ *
+ * @parameter the config directory overriding the template settings,
+ * or null if the template settings will not be overridden.
+ */
+ public void setOverrideConfigDir(File overrideConfigDir)
+ {
+ this.overrideConfigDir = overrideConfigDir;
+ }
+
+ /**
+ * Sets the Loglevel to use in the generation process.
+ *
+ * @param loglevel the loglevel, must be one of trace, debug, info, warn
+ * or error, or null if the loglevel defined in the templates
+ * should be used.
+ */
+ public void setLoglevel(String loglevel)
+ {
+ this.loglevel = loglevel;
+ }
+}
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/apache/torque/ant/task/TorqueGeneratorTaskTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/apache/torque/ant/task/TorqueGeneratorTaskTest.java?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/apache/torque/ant/task/TorqueGeneratorTaskTest.java (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/java/org/apache/torque/ant/task/TorqueGeneratorTaskTest.java Mon Aug 23 19:09:05 2010
@@ -0,0 +1,51 @@
+package org.apache.torque.ant.task;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+
+public class TorqueGeneratorTaskTest extends TestCase
+{
+ public void testExecute() throws Exception
+ {
+ File target = new File("target/tests/torqueGeneratorTaskTest");
+ FileUtils.deleteDirectory(target);
+ TorqueGeneratorTask task = new TorqueGeneratorTask();
+ task.setPackaging("directory");
+ task.setProjectRootDir(new File("src/test/torqueGeneratorTaskTest"));
+ task.setNewFileTargetDir(target);
+ task.execute();
+
+ assertTrue(target.exists());
+ File generatedJavaFile = new File(
+ target,
+ "org/apache/torque/ant/PropertyKeys.java");
+ assertTrue(generatedJavaFile.exists());
+ File expectedJavaFile = new File(
+ "src/test/resources/org/apache/torque/ant/PropertyKeys.java");
+ junitx.framework.FileAssert.assertEquals(
+ expectedJavaFile,
+ generatedJavaFile);
+ }
+}
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/org/apache/torque/ant/PropertyKeys.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/org/apache/torque/ant/PropertyKeys.java?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/org/apache/torque/ant/PropertyKeys.java (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/resources/org/apache/torque/ant/PropertyKeys.java Mon Aug 23 19:09:05 2010
@@ -0,0 +1,61 @@
+package org.apache.torque.generator.maven;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Contains all keys in the property file.
+ */
+public enum PropertyKeys
+{
+ /** Key for torque.sample.property */
+ TORQUE_SAMPLE_PROPERTY("torque.sample.property"),
+
+ /** Key for torque.some.other.property */
+ TORQUE_SOME_OTHER_PROPERTY("torque.some.other.property");
+
+ /** The property key. */
+ private String key;
+
+ /**
+ * Constructor.
+ *
+ * @param key the key of the property.
+ */
+ private PropertyKeys(String key)
+ {
+ this.key = key;
+ }
+
+ /**
+ * Returns the property key.
+ *
+ * @return the property key.
+ */
+ public String getKey()
+ {
+ return key;
+ }
+
+ @Override
+ public String toString()
+ {
+ return key;
+ }
+}
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/conf/control.xml?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/conf/control.xml (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/conf/control.xml Mon Aug 23 19:09:05 2010
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<control loglevel="debug"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://db.apache.org/torque/4.0/generator/configuration http://db.apache.org/torque/4.0/generator/configuration.xsd"
+ xmlns="http://db.apache.org/torque/4.0/generator/configuration">
+ <output name="propertyKeys"
+ file="org/apache/torque/ant/PropertyKeys.java">
+ <source xsi:type="fileSource">
+ <include>propertiesData.properties</include>
+ </source>
+ <outlet name="classFrame"/>
+ </output>
+</control>
+
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/outlets/enumOutlets.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/outlets/enumOutlets.xml?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/outlets/enumOutlets.xml (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/outlets/enumOutlets.xml Mon Aug 23 19:09:05 2010
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<outlets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://db.apache.org/torque/4.0/generator/configuration http://db.apache.org/torque/4.0/generator/configuration.xsd"
+ xmlns="http://db.apache.org/torque/4.0/generator/configuration">
+ <outlet name="classFrame" xsi:type="velocityOutlet" path="classFrame.vm">
+ <mergepoint name="constants">
+ <action xsi:type="traverseAllAction" element="entry" outlet="constant"/>
+ </mergepoint>
+ <mergepoint name="fields">
+ <action xsi:type="applyAction" outlet="keyField"/>
+ <action xsi:type="applyAction" outlet="newline"/>
+ </mergepoint>
+ <mergepoint name="methods">
+ <action xsi:type="applyAction" outlet="constructor"/>
+ <action xsi:type="applyAction" outlet="newline"/>
+ <action xsi:type="applyAction" outlet="getKey"/>
+ <action xsi:type="applyAction" outlet="newline"/>
+ <action xsi:type="applyAction" outlet="toString"/>
+ </mergepoint>
+ </outlet>
+
+ <outlet name="constant" xsi:type="velocityOutlet" path="constant.vm">
+ <mergepoint name="constantName">
+ <action xsi:type="applyAction" outlet="constantName"/>
+ </mergepoint>
+ </outlet>
+
+ <outlet name="constantName" xsi:type="javaOutlet" class="org.apache.torque.generator.outlet.java.ConstantNameOutlet">
+ <inputSourceElement>.</inputSourceElement>
+ <sourceElementAttribute>key</sourceElementAttribute>
+ </outlet>
+
+ <outlet name="keyField" xsi:type="velocityOutlet" path="keyField.vm"/>
+ <outlet name="constructor" xsi:type="velocityOutlet" path="constructor.vm"/>
+ <outlet name="getKey" xsi:type="velocityOutlet" path="getKey.vm"/>
+ <outlet name="toString" xsi:type="velocityOutlet" path="toString.vm"/>
+ <outlet name="newline" xsi:type="javaOutlet" class="org.apache.torque.generator.outlet.java.NewlineOutlet"/>
+</outlets>
\ No newline at end of file
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/src/propertiesData.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/src/propertiesData.properties?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/src/propertiesData.properties (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/src/propertiesData.properties Mon Aug 23 19:09:05 2010
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+torque.sample.property = sampleValue
+torque.some.other.property = someOtherValue
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/classFrame.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/classFrame.vm?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/classFrame.vm (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/classFrame.vm Mon Aug 23 19:09:05 2010
@@ -0,0 +1,47 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+package org.apache.torque.generator.maven;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Contains all keys in the property file.
+ */
+public enum PropertyKeys
+{
+$torqueGen.mergepoint("constants")##
+$torqueGen.mergepoint("fields")##
+$torqueGen.mergepoint("methods")##
+}
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constant.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constant.vm?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constant.vm (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constant.vm Mon Aug 23 19:09:05 2010
@@ -0,0 +1,21 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+ /** Key for ${key} */
+ $torqueGen.mergepoint("constantName")("${key}")#if(${torqueGen.getSourceElement().hasFollowingSibling()}),#else;#end
+
+
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constructor.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constructor.vm?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constructor.vm (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/constructor.vm Mon Aug 23 19:09:05 2010
@@ -0,0 +1,26 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+ /**
+ * Constructor.
+ *
+ * @param key the key of the property.
+ */
+ private PropertyKeys(String key)
+ {
+ this.key = key;
+ }
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/getKey.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/getKey.vm?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/getKey.vm (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/getKey.vm Mon Aug 23 19:09:05 2010
@@ -0,0 +1,26 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+ /**
+ * Returns the property key.
+ *
+ * @return the property key.
+ */
+ public String getKey()
+ {
+ return key;
+ }
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/keyField.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/keyField.vm?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/keyField.vm (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/keyField.vm Mon Aug 23 19:09:05 2010
@@ -0,0 +1,19 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+ /** The property key. */
+ private String key;
Added: db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/toString.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/toString.vm?rev=988254&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/toString.vm (added)
+++ db/torque/torque4/trunk/torque-ant-tasks/src/test/torqueGeneratorTaskTest/src/main/torque-gen/templates/toString.vm Mon Aug 23 19:09:05 2010
@@ -0,0 +1,22 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements. See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership. The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied. See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+ @Override
+ public String toString()
+ {
+ return key;
+ }
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org