Has torque 4 lost the ability to generate schema files from a live database?
In torque 3 you could use "maven torque:jdbc" to generate the schema from the database which was nice, but it looks like torque 4 have lost that ability.
So do I have to write my xml schema files by hand with torque 4, or is there a way to auto generate them from either sql or a live database like in torque 3?
------------- Added as per comment -------
It seems my pom.xml is wrong somehow. I get the following error, when I try to run mvn generate-test-sources
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Eddie torque generator 1.0.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:1.0.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.197s
[INFO] Finished at: Tue Sep 24 22:43:25 CEST 2013
[INFO] Final Memory: 5M/240M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-compiler-plugin:1.0.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:1.0.0: Failure to find org.apache.maven.plugins:maven-compiler-plugin:pom:1.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
My current pom.xml is: (It may be insanely wrong and stupid, because I have newer used maven before, and my project don't use maven for anything. So I don't really understand how maven works.).
<?xml version="1.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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Eddie</groupId>
<artifactId>eddie</artifactId>
<packaging>jar</packaging>
<name>Eddie torque generator</name>
<version>1.0.0</version>
<dependencies>
<!-- Torque runtime -->
<dependency>
<artifactId>torque-runtime</artifactId>
<groupId>org.apache.torque</groupId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.4-701.jdbc4</version>
</dependency>
<!-- Logging via log4j -->
<dependency>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
<version>1.2.16</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.torque</groupId>
<artifactId>torque-maven-plugin</artifactId>
<version>4.0</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<packaging>classpath</packaging>
<configPackage>org.apache.torque.templates.om</configPackage>
<sourceDir>src/schema</sourceDir>
<options>
<torque.om.package>dk.mt3.libris.server.auto</torque.om.package>
<torque.database>postgresql</torque.database>
</options>
</configuration>
</execution>
<execution>
<id>generate-sql</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<packaging>classpath</packaging>
<configPackage>org.apache.torque.templates.sql</configPackage>
<sourceDir>src/schema</sourceDir>
<defaultOutputDir>target/generated-sql</defaultOutputDir>
<defaultOutputDirUsage>none</defaultOutputDirUsage>
<options>
<torque.database>postgresql</torque.database>
</options>
</configuration>
</execution>
<!-- Insert start -->
<execution>
<id>generate-schema-from-jdbc</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<packaging>classpath</packaging>
<configPackage>org.apache.torque.templates.jdbc2schema</configPackage>
<newFileTargetDir>target/generated-schema</newFileTargetDir>
<newFileTargetDirUsage>none</newFileTargetDirUsage>
<options>
<driver></driver>
<url></url>
<username>tiller</username>
<torque.jdbc2schema.driver>org.postgresql.Driver</torque.jdbc2schema.driver>
<torque.jdbc2schema.url>jdbc:postgresql://localhost/librisepubcreator</torque.jdbc2schema.url>
<torque.jdbc2schema.user>tiller</torque.jdbc2schema.user>
<torque.jdbc2schema.password></torque.jdbc2schema.password>
</options>
</configuration>
</execution>
<!-- Insert end -->
</executions>
<dependencies>
<dependency>
<groupId>org.apache.torque</groupId>
<artifactId>torque-templates</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost/librisepubcreator</url>
<username>tiller</username>
<!--
<password></password>
-->
<onError>continue</onError>
<autocommit>true</autocommit>
<fileset>
<basedir>${basedir}/target/generated-sql</basedir>
<includes>
<include>*.sql</include>
</includes>
</fileset>
</configuration>
</plugin>
<plugin>
<!-- setting java version to 1.5 -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The Torque Maven plugin now only offers a "generate" goal.
See "Generation of XML schema from an existing database" in the Running the Generator section.
In short, use torque.jdbc2schema
options. Example:
<execution>
<id>generate-schema-from-jdbc</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<packaging>classpath</packaging>
<configPackage>org.apache.torque.templates.jdbc2schema</configPackage>
<newFileTargetDir>target/generated-schema</newFileTargetDir>
<newFileTargetDirUsage>none</newFileTargetDirUsage>
<options>
<torque.jdbc2schema.driver>${torque.driver}</torque.jdbc2schema.driver>
<torque.jdbc2schema.url>${torque.database.url}</torque.jdbc2schema.url>
<torque.jdbc2schema.user>${torque.database.user}</torque.jdbc2schema.user>
<torque.jdbc2schema.password>${torque.database.password}</torque.jdbc2schema.password>
<torque.jdbc2schema.schema>${torque.database.schema}</torque.jdbc2schema.schema>
</options>
</configuration>
</execution>