[jOOQ/jOOQ#12601] Produce compilation error if code generator version
doesn't match runtime version
This commit is contained in:
parent
91a25a5c1d
commit
2766eeb4b5
@ -104,6 +104,7 @@ abstract class AbstractGenerator implements Generator {
|
||||
boolean generateImmutableInterfaces = false;
|
||||
boolean generateSerializableInterfaces = true;
|
||||
boolean generateDaos = false;
|
||||
boolean generateJooqVersionReference = true;
|
||||
boolean generateJPAAnnotations = false;
|
||||
String generateJPAVersion = "";
|
||||
boolean generateValidationAnnotations = false;
|
||||
@ -627,6 +628,16 @@ abstract class AbstractGenerator implements Generator {
|
||||
this.generateDaos = generateDaos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateJooqVersionReference() {
|
||||
return generateJooqVersionReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenerateJooqVersionReference(boolean generateJooqVersionReference) {
|
||||
this.generateJooqVersionReference = generateJooqVersionReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateJPAAnnotations() {
|
||||
return generateJPAAnnotations;
|
||||
|
||||
@ -53,7 +53,7 @@ public final class Constants {
|
||||
/**
|
||||
* The latest jOOQ minor version.
|
||||
*/
|
||||
public static final String MINOR_VERSION = "3.15";
|
||||
public static final String MINOR_VERSION = "3.16";
|
||||
|
||||
/**
|
||||
* The latest jOOQ version.
|
||||
@ -155,6 +155,16 @@ public final class Constants {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The minor release 3.15.
|
||||
*/
|
||||
public static final String VERSION_3_15 = "3.15";
|
||||
|
||||
/**
|
||||
* The minor release 3.16.
|
||||
*/
|
||||
public static final String VERSION_3_16 = "3.16";
|
||||
|
||||
/**
|
||||
* No further instances
|
||||
*/
|
||||
|
||||
@ -754,6 +754,8 @@ public class GenerationTool {
|
||||
generator.setGenerateSerializableInterfaces(g.getGenerate().isSerializableInterfaces());
|
||||
if (g.getGenerate().isDaos() != null)
|
||||
generator.setGenerateDaos(g.getGenerate().isDaos());
|
||||
if (g.getGenerate().isJooqVersionReference() != null)
|
||||
generator.setGenerateJooqVersionReference(g.getGenerate().isJooqVersionReference());
|
||||
if (g.getGenerate().isJpaAnnotations() != null)
|
||||
generator.setGenerateJPAAnnotations(g.getGenerate().isJpaAnnotations());
|
||||
if (g.getGenerate().getJpaVersion() != null)
|
||||
|
||||
@ -41,6 +41,7 @@ package org.jooq.codegen;
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jooq.Constants;
|
||||
import org.jooq.meta.Database;
|
||||
import org.jooq.meta.jaxb.GeneratedAnnotationType;
|
||||
import org.jooq.meta.jaxb.GeneratedSerialVersionUID;
|
||||
@ -487,6 +488,20 @@ public interface Generator {
|
||||
*/
|
||||
void setGenerateDaos(boolean generateDaos);
|
||||
|
||||
/**
|
||||
* Whether generated objects should reference the runtime jOOQ version in
|
||||
* {@link Constants}, to help debug code generator / runtime version
|
||||
* mismatches.
|
||||
*/
|
||||
boolean generateJooqVersionReference();
|
||||
|
||||
/**
|
||||
* Whether generated objects should reference the runtime jOOQ version in
|
||||
* {@link Constants}, to help debug code generator / runtime version
|
||||
* mismatches.
|
||||
*/
|
||||
void setGenerateJooqVersionReference(boolean generateJooqVersionReference);
|
||||
|
||||
/**
|
||||
* Whether POJO's and records should be annotated with JPA annotations
|
||||
*/
|
||||
|
||||
@ -6751,6 +6751,21 @@ public class JavaGenerator extends AbstractGenerator {
|
||||
|
||||
printReferences(out, schemas, Schema.class, false);
|
||||
|
||||
if (generateJooqVersionReference()) {
|
||||
String version = org.jooq.codegen.Constants.MINOR_VERSION.replace(".", "_");
|
||||
|
||||
out.javadoc("A reference to the " + org.jooq.codegen.Constants.MINOR_VERSION + " minor release of the code generator. "
|
||||
+ "If this doesn't compile, it's because the runtime library uses an older minor release, namely: " + org.jooq.Constants.MINOR_VERSION + ". "
|
||||
+ "You can turn off the generation of this reference by specifying /configuration/generator/generate/jooqVersionReference");
|
||||
|
||||
if (scala)
|
||||
out.println("private val REQUIRE_RUNTIME_JOOQ_VERSION = %s.VERSION_%s", org.jooq.Constants.class, version);
|
||||
else if (kotlin)
|
||||
out.println("private val REQUIRE_RUNTIME_JOOQ_VERSION = %s.VERSION_%s", org.jooq.Constants.class, version);
|
||||
else
|
||||
out.println("private static final String REQUIRE_RUNTIME_JOOQ_VERSION = %s.VERSION_%s;", org.jooq.Constants.class, version);
|
||||
}
|
||||
|
||||
generateCatalogClassFooter(catalog, out);
|
||||
out.println("}");
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public final class Constants {
|
||||
/**
|
||||
* The latest jOOQ minor version.
|
||||
*/
|
||||
public static final String MINOR_VERSION = "3.15";
|
||||
public static final String MINOR_VERSION = "3.16";
|
||||
|
||||
/**
|
||||
* The latest jOOQ version.
|
||||
@ -155,6 +155,16 @@ public final class Constants {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The minor release 3.15.
|
||||
*/
|
||||
public static final String VERSION_3_15 = "3.15";
|
||||
|
||||
/**
|
||||
* The minor release 3.16.
|
||||
*/
|
||||
public static final String VERSION_3_16 = "3.16";
|
||||
|
||||
/**
|
||||
* No further instances
|
||||
*/
|
||||
|
||||
@ -114,6 +114,8 @@ public class Generate implements Serializable, XMLAppendable
|
||||
protected Boolean serializableInterfaces = true;
|
||||
@XmlElement(defaultValue = "false")
|
||||
protected Boolean daos = false;
|
||||
@XmlElement(defaultValue = "true")
|
||||
protected Boolean jooqVersionReference = true;
|
||||
@XmlElement(defaultValue = "false")
|
||||
protected Boolean jpaAnnotations = false;
|
||||
@XmlJavaTypeAdapter(StringAdapter.class)
|
||||
@ -1174,6 +1176,30 @@ public class Generate implements Serializable, XMLAppendable
|
||||
this.daos = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate references to the most up to date minor release in {@link org.jooq.Constants} to produce compilation errors if an outdated runtime library is being used.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public Boolean isJooqVersionReference() {
|
||||
return jooqVersionReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the jooqVersionReference property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Boolean }
|
||||
*
|
||||
*/
|
||||
public void setJooqVersionReference(Boolean value) {
|
||||
this.jooqVersionReference = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Annotate POJOs and Records with JPA annotations.
|
||||
*
|
||||
@ -2498,6 +2524,11 @@ public class Generate implements Serializable, XMLAppendable
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withJooqVersionReference(Boolean value) {
|
||||
setJooqVersionReference(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Generate withJpaAnnotations(Boolean value) {
|
||||
setJpaAnnotations(value);
|
||||
return this;
|
||||
@ -2808,6 +2839,7 @@ public class Generate implements Serializable, XMLAppendable
|
||||
builder.append("immutableInterfaces", immutableInterfaces);
|
||||
builder.append("serializableInterfaces", serializableInterfaces);
|
||||
builder.append("daos", daos);
|
||||
builder.append("jooqVersionReference", jooqVersionReference);
|
||||
builder.append("jpaAnnotations", jpaAnnotations);
|
||||
builder.append("jpaVersion", jpaVersion);
|
||||
builder.append("validationAnnotations", validationAnnotations);
|
||||
@ -3245,6 +3277,15 @@ public class Generate implements Serializable, XMLAppendable
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (jooqVersionReference == null) {
|
||||
if (other.jooqVersionReference!= null) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!jooqVersionReference.equals(other.jooqVersionReference)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (jpaAnnotations == null) {
|
||||
if (other.jpaAnnotations!= null) {
|
||||
return false;
|
||||
@ -3716,6 +3757,7 @@ public class Generate implements Serializable, XMLAppendable
|
||||
result = ((prime*result)+((immutableInterfaces == null)? 0 :immutableInterfaces.hashCode()));
|
||||
result = ((prime*result)+((serializableInterfaces == null)? 0 :serializableInterfaces.hashCode()));
|
||||
result = ((prime*result)+((daos == null)? 0 :daos.hashCode()));
|
||||
result = ((prime*result)+((jooqVersionReference == null)? 0 :jooqVersionReference.hashCode()));
|
||||
result = ((prime*result)+((jpaAnnotations == null)? 0 :jpaAnnotations.hashCode()));
|
||||
result = ((prime*result)+((jpaVersion == null)? 0 :jpaVersion.hashCode()));
|
||||
result = ((prime*result)+((validationAnnotations == null)? 0 :validationAnnotations.hashCode()));
|
||||
|
||||
@ -1738,6 +1738,10 @@ jOOQ version used for source code.]]></jxb:javadoc></jxb:property></appinfo></an
|
||||
<element name="daos" type="boolean" default="false" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate DAOs.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="jooqVersionReference" type="boolean" default="true" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Generate references to the most up to date minor release in {@link org.jooq.Constants} to produce compilation errors if an outdated runtime library is being used.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
</element>
|
||||
|
||||
<element name="jpaAnnotations" type="boolean" default="false" minOccurs="0" maxOccurs="1">
|
||||
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Annotate POJOs and Records with JPA annotations.]]></jxb:javadoc></jxb:property></appinfo></annotation>
|
||||
|
||||
@ -53,7 +53,7 @@ public final class Constants {
|
||||
/**
|
||||
* The latest jOOQ minor version.
|
||||
*/
|
||||
public static final String MINOR_VERSION = "3.15";
|
||||
public static final String MINOR_VERSION = "3.16";
|
||||
|
||||
/**
|
||||
* The latest jOOQ version.
|
||||
@ -155,6 +155,16 @@ public final class Constants {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The minor release 3.15.
|
||||
*/
|
||||
public static final String VERSION_3_15 = "3.15";
|
||||
|
||||
/**
|
||||
* The minor release 3.16.
|
||||
*/
|
||||
public static final String VERSION_3_16 = "3.16";
|
||||
|
||||
/**
|
||||
* No further instances
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user