[#1149] Allow for optional "http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd" namespace in jooq-codegen configuration

This commit is contained in:
Lukas Eder 2012-02-16 20:59:00 +00:00
parent b3f0b08d95
commit 17a61d8856
16 changed files with 184 additions and 135 deletions

View File

@ -39,7 +39,11 @@ package org.jooq.util;
import static org.jooq.tools.StringUtils.defaultString;
import static org.jooq.tools.StringUtils.isBlank;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.ArrayList;
@ -104,7 +108,16 @@ public class GenerationTool {
try {
if (args[0].endsWith(".xml")) {
main(JAXB.unmarshal(in, Configuration.class));
// [#1149] If there is no namespace defined, add the default one
ByteArrayOutputStream out = new ByteArrayOutputStream();
copyLarge(in, out);
String xml = out.toString();
xml = xml.replace(
"<configuration>",
"<configuration xmlns=\"http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd\">");
main(JAXB.unmarshal(new StringReader(xml), Configuration.class));
}
else {
Properties properties = new Properties();
@ -349,4 +362,29 @@ public class GenerationTool {
log.error("Usage : GenerationTool <configuration-file>");
System.exit(-1);
}
/**
* Copy bytes from a large (over 2GB) <code>InputStream</code> to an
* <code>OutputStream</code>.
* <p>
* This method buffers the input internally, so there is no need to use a
* <code>BufferedInputStream</code>.
*
* @param input the <code>InputStream</code> to read from
* @param output the <code>OutputStream</code> to write to
* @return the number of bytes copied
* @throws NullPointerException if the input or output is null
* @throws IOException if an I/O error occurs
* @since Commons IO 1.3
*/
public static long copyLarge(InputStream input, OutputStream output) throws IOException {
byte[] buffer = new byte[1024 * 4];
long count = 0;
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
count += n;
}
return count;
}
}

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.12 at 02:50:41 PM MEZ
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//

View File

@ -0,0 +1,9 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0.5-b02-fcs
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.16 at 09:49:36 PM MEZ
//
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package org.jooq.util.jaxb;

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">
<jdbc>
<driver>oracle.jdbc.OracleDriver</driver>
<url>jdbc:oracle:thin:@localhost:1521:xe</url>

View File

@ -1,123 +1,123 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<jdbc>
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
<url>jdbc:sqlserver://localhost:1433;databaseName=test;integratedSecurity=true</url>
<schema>dbo</schema>
<user></user>
<password></password>
</jdbc>
<generator>
<name>org.jooq.util.DefaultGenerator</name>
<strategy/>
<database>
<name>org.jooq.util.sqlserver.SQLServerDatabase</name>
<includes>t_.*,x_.*,v_.*,p_.*,f_.*,(f|p)[0-9]+,s_.*</includes>
<excludes>t_book_details</excludes>
<dateAsTimestamp>false</dateAsTimestamp>
<masterDataTables>
<masterDataTable>
<name>t_language</name>
<literal>cd</literal>
<description>description</description>
</masterDataTable>
<masterDataTable>
<name>t_658_11</name>
</masterDataTable>
<masterDataTable>
<name>t_658_21</name>
</masterDataTable>
<masterDataTable>
<name>t_658_31</name>
</masterDataTable>
<masterDataTable>
<name>t_658_12</name>
<literal>cd</literal>
</masterDataTable>
<masterDataTable>
<name>t_658_22</name>
<literal>cd</literal>
</masterDataTable>
<masterDataTable>
<name>t_658_32</name>
<literal>cd</literal>
</masterDataTable>
</masterDataTables>
<enumTypes>
<enumType>
<name>BOOLEAN_YN_LC</name>
<literals>y,&quot;n&quot;</literals>
</enumType>
<enumType>
<name>BOOLEAN_YN_UC</name>
<literals>&quot;Y&quot;,N</literals>
</enumType>
<enumType>
<name>BOOLEAN_TRUE_FALSE_LC</name>
<literals>true,false</literals>
</enumType>
<enumType>
<name>BOOLEAN_TRUE_FALSE_UC</name>
<literals>TRUE,FALSE</literals>
</enumType>
<enumType>
<name>BOOLEAN_10</name>
<literals>1,0</literals>
</enumType>
<enumType>
<name>BOOLEAN_YES_NO_LC</name>
<literals>yes,no</literals>
</enumType>
<enumType>
<name>BOOLEAN_YES_NO_UC</name>
<literals>&quot;YES&quot;,&quot;NO&quot;</literals>
</enumType>
</enumTypes>
<forcedTypes>
<forcedType>
<name>BOOLEAN_YES_NO_LC</name>
<expressions>(?i:(.*?.)?T_BOOLEANS.YES_NO_LC)</expressions>
</forcedType>
<forcedType>
<name>BOOLEAN_YES_NO_UC</name>
<expressions>(?i:(.*?.)?T_BOOLEANS.YES_NO_UC)</expressions>
</forcedType>
<forcedType>
<name>BOOLEAN_YN_LC</name>
<expressions>(?i:(.*?.)?T_BOOLEANS.Y_N_LC)</expressions>
</forcedType>
<forcedType>
<name>BOOLEAN_YN_UC</name>
<expressions>(?i:(.*?.)?T_BOOLEANS.Y_N_UC)</expressions>
</forcedType>
<forcedType>
<name>BOOLEAN_TRUE_FALSE_LC</name>
<expressions>(?i:(.*?.)?T_BOOLEANS.TRUE_FALSE_LC)</expressions>
</forcedType>
<forcedType>
<name>BOOLEAN_TRUE_FALSE_UC</name>
<expressions>(?i:(.*?.)?T_BOOLEANS.TRUE_FALSE_UC)</expressions>
</forcedType>
<forcedType>
<name>BIT</name>
<expressions>(?i:(.*?.)?T_BOOLEANS.(VC|C|N)_BOOLEAN)</expressions>
</forcedType>
<forcedType>
<name>BOOLEAN_10</name>
<expressions>(?i:(.*?.)?T_BOOLEANS.ONE_ZERO)</expressions>
</forcedType>
</forcedTypes>
</database>
<generate>
<relations>true</relations>
<deprecated>true</deprecated>
<instanceFields>true</instanceFields>
<unsignedTypes>true</unsignedTypes>
<generatedAnnotation>false</generatedAnnotation>
</generate>
<target>
<packageName>org.jooq.test.sqlserver.generatedclasses</packageName>
<directory>./src</directory>
</target>
</generator>
</configuration>
<jooq:configuration xmlns:jooq="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">
<jooq:jdbc>
<jooq:driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jooq:driver>
<jooq:url>jdbc:sqlserver://localhost:1433;databaseName=test;integratedSecurity=true</jooq:url>
<jooq:schema>dbo</jooq:schema>
<jooq:user></jooq:user>
<jooq:password></jooq:password>
</jooq:jdbc>
<jooq:generator>
<jooq:name>org.jooq.util.DefaultGenerator</jooq:name>
<jooq:strategy/>
<jooq:database>
<jooq:name>org.jooq.util.sqlserver.SQLServerDatabase</jooq:name>
<jooq:includes>t_.*,x_.*,v_.*,p_.*,f_.*,(f|p)[0-9]+,s_.*</jooq:includes>
<jooq:excludes>t_book_details</jooq:excludes>
<jooq:dateAsTimestamp>false</jooq:dateAsTimestamp>
<jooq:masterDataTables>
<jooq:masterDataTable>
<jooq:name>t_language</jooq:name>
<jooq:literal>cd</jooq:literal>
<jooq:description>description</jooq:description>
</jooq:masterDataTable>
<jooq:masterDataTable>
<jooq:name>t_658_11</jooq:name>
</jooq:masterDataTable>
<jooq:masterDataTable>
<jooq:name>t_658_21</jooq:name>
</jooq:masterDataTable>
<jooq:masterDataTable>
<jooq:name>t_658_31</jooq:name>
</jooq:masterDataTable>
<jooq:masterDataTable>
<jooq:name>t_658_12</jooq:name>
<jooq:literal>cd</jooq:literal>
</jooq:masterDataTable>
<jooq:masterDataTable>
<jooq:name>t_658_22</jooq:name>
<jooq:literal>cd</jooq:literal>
</jooq:masterDataTable>
<jooq:masterDataTable>
<jooq:name>t_658_32</jooq:name>
<jooq:literal>cd</jooq:literal>
</jooq:masterDataTable>
</jooq:masterDataTables>
<jooq:enumTypes>
<jooq:enumType>
<jooq:name>BOOLEAN_YN_LC</jooq:name>
<jooq:literals>y,&quot;n&quot;</jooq:literals>
</jooq:enumType>
<jooq:enumType>
<jooq:name>BOOLEAN_YN_UC</jooq:name>
<jooq:literals>&quot;Y&quot;,N</jooq:literals>
</jooq:enumType>
<jooq:enumType>
<jooq:name>BOOLEAN_TRUE_FALSE_LC</jooq:name>
<jooq:literals>true,false</jooq:literals>
</jooq:enumType>
<jooq:enumType>
<jooq:name>BOOLEAN_TRUE_FALSE_UC</jooq:name>
<jooq:literals>TRUE,FALSE</jooq:literals>
</jooq:enumType>
<jooq:enumType>
<jooq:name>BOOLEAN_10</jooq:name>
<jooq:literals>1,0</jooq:literals>
</jooq:enumType>
<jooq:enumType>
<jooq:name>BOOLEAN_YES_NO_LC</jooq:name>
<jooq:literals>yes,no</jooq:literals>
</jooq:enumType>
<jooq:enumType>
<jooq:name>BOOLEAN_YES_NO_UC</jooq:name>
<jooq:literals>&quot;YES&quot;,&quot;NO&quot;</jooq:literals>
</jooq:enumType>
</jooq:enumTypes>
<jooq:forcedTypes>
<jooq:forcedType>
<jooq:name>BOOLEAN_YES_NO_LC</jooq:name>
<jooq:expressions>(?i:(.*?.)?T_BOOLEANS.YES_NO_LC)</jooq:expressions>
</jooq:forcedType>
<jooq:forcedType>
<jooq:name>BOOLEAN_YES_NO_UC</jooq:name>
<jooq:expressions>(?i:(.*?.)?T_BOOLEANS.YES_NO_UC)</jooq:expressions>
</jooq:forcedType>
<jooq:forcedType>
<jooq:name>BOOLEAN_YN_LC</jooq:name>
<jooq:expressions>(?i:(.*?.)?T_BOOLEANS.Y_N_LC)</jooq:expressions>
</jooq:forcedType>
<jooq:forcedType>
<jooq:name>BOOLEAN_YN_UC</jooq:name>
<jooq:expressions>(?i:(.*?.)?T_BOOLEANS.Y_N_UC)</jooq:expressions>
</jooq:forcedType>
<jooq:forcedType>
<jooq:name>BOOLEAN_TRUE_FALSE_LC</jooq:name>
<jooq:expressions>(?i:(.*?.)?T_BOOLEANS.TRUE_FALSE_LC)</jooq:expressions>
</jooq:forcedType>
<jooq:forcedType>
<jooq:name>BOOLEAN_TRUE_FALSE_UC</jooq:name>
<jooq:expressions>(?i:(.*?.)?T_BOOLEANS.TRUE_FALSE_UC)</jooq:expressions>
</jooq:forcedType>
<jooq:forcedType>
<jooq:name>BIT</jooq:name>
<jooq:expressions>(?i:(.*?.)?T_BOOLEANS.(VC|C|N)_BOOLEAN)</jooq:expressions>
</jooq:forcedType>
<jooq:forcedType>
<jooq:name>BOOLEAN_10</jooq:name>
<jooq:expressions>(?i:(.*?.)?T_BOOLEANS.ONE_ZERO)</jooq:expressions>
</jooq:forcedType>
</jooq:forcedTypes>
</jooq:database>
<jooq:generate>
<jooq:relations>true</jooq:relations>
<jooq:deprecated>true</jooq:deprecated>
<jooq:instanceFields>true</jooq:instanceFields>
<jooq:unsignedTypes>true</jooq:unsignedTypes>
<jooq:generatedAnnotation>false</jooq:generatedAnnotation>
</jooq:generate>
<jooq:target>
<jooq:packageName>org.jooq.test.sqlserver.generatedclasses</jooq:packageName>
<jooq:directory>./src</jooq:directory>
</jooq:target>
</jooq:generator>
</jooq:configuration>

View File

@ -7,6 +7,8 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;jOOQ&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;classpathContainer path=&amp;quot;org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.classpathContainer&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;jOOQ-codegen&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;jOOQ-meta&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>