HHH-16563: Using jakarta.annotation.Generated instead of javax versions
This commit is contained in:
parent
7e115eb8f4
commit
a415555df4
|
@ -22,6 +22,7 @@ dependencies {
|
||||||
compileOnly libs.ant
|
compileOnly libs.ant
|
||||||
|
|
||||||
annotationProcessor project( ':hibernate-jpamodelgen' )
|
annotationProcessor project( ':hibernate-jpamodelgen' )
|
||||||
|
compileOnly jakartaLibs.annotation
|
||||||
|
|
||||||
testImplementation project( ':hibernate-testing' )
|
testImplementation project( ':hibernate-testing' )
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ dependencies {
|
||||||
testImplementation project( ':hibernate-testing' )
|
testImplementation project( ':hibernate-testing' )
|
||||||
|
|
||||||
testAnnotationProcessor project( ':hibernate-jpamodelgen' )
|
testAnnotationProcessor project( ':hibernate-jpamodelgen' )
|
||||||
|
testCompileOnly jakartaLibs.annotation
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|
|
@ -113,6 +113,7 @@ dependencyResolutionManagement {
|
||||||
alias( "validation" ).to( "jakarta.validation", "jakarta.validation-api" ).version( "3.0.2" )
|
alias( "validation" ).to( "jakarta.validation", "jakarta.validation-api" ).version( "3.0.2" )
|
||||||
alias( "jacc" ).to( "jakarta.authorization", "jakarta.authorization-api" ).version( "2.1.0" )
|
alias( "jacc" ).to( "jakarta.authorization", "jakarta.authorization-api" ).version( "2.1.0" )
|
||||||
alias( "cdi" ).to( "jakarta.enterprise", "jakarta.enterprise.cdi-api" ).version( "4.0.1" )
|
alias( "cdi" ).to( "jakarta.enterprise", "jakarta.enterprise.cdi-api" ).version( "4.0.1" )
|
||||||
|
alias( "annotation" ).to( "jakarta.annotation", "jakarta.annotation-api" ).version( "2.1.1" )
|
||||||
alias( "interceptors" ).to( "jakarta.interceptor", "jakarta.interceptor-api" ).version( "2.1.0" )
|
alias( "interceptors" ).to( "jakarta.interceptor", "jakarta.interceptor-api" ).version( "2.1.0" )
|
||||||
alias( "jsonbApi" ).to( "jakarta.json.bind", "jakarta.json.bind-api" ).version( "3.0.0" )
|
alias( "jsonbApi" ).to( "jakarta.json.bind", "jakarta.json.bind-api" ).version( "3.0.0" )
|
||||||
alias( "jsonb" ).to( "org.eclipse", "yasson" ).versionRef( "jsonbRuntime" )
|
alias( "jsonb" ).to( "org.eclipse", "yasson" ).versionRef( "jsonbRuntime" )
|
||||||
|
|
|
@ -29,6 +29,7 @@ dependencies {
|
||||||
testImplementation project( ':hibernate-core' )
|
testImplementation project( ':hibernate-core' )
|
||||||
|
|
||||||
testImplementation jakartaLibs.validation
|
testImplementation jakartaLibs.validation
|
||||||
|
testImplementation jakartaLibs.annotation
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets.main {
|
sourceSets.main {
|
||||||
|
|
|
@ -203,7 +203,7 @@ public final class ClassWriter {
|
||||||
private static String writeGeneratedAnnotation(MetaEntity entity, Context context) {
|
private static String writeGeneratedAnnotation(MetaEntity entity, Context context) {
|
||||||
StringBuilder generatedAnnotation = new StringBuilder();
|
StringBuilder generatedAnnotation = new StringBuilder();
|
||||||
generatedAnnotation.append( "@" )
|
generatedAnnotation.append( "@" )
|
||||||
.append( entity.importType( context.getGeneratedAnnotationFqcn() ) )
|
.append( entity.importType( "jakarta.annotation.Generated" ) )
|
||||||
.append( "(value = \"" )
|
.append( "(value = \"" )
|
||||||
.append( JPAMetaModelEntityProcessor.class.getName() );
|
.append( JPAMetaModelEntityProcessor.class.getName() );
|
||||||
if ( context.addGeneratedDate() ) {
|
if ( context.addGeneratedDate() ) {
|
||||||
|
|
|
@ -52,7 +52,6 @@ public final class Context {
|
||||||
private final boolean lazyXmlParsing;
|
private final boolean lazyXmlParsing;
|
||||||
private final String persistenceXmlLocation;
|
private final String persistenceXmlLocation;
|
||||||
private final List<String> ormXmlFiles;
|
private final List<String> ormXmlFiles;
|
||||||
private final String generatedAnnotation;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether all mapping files are xml-mapping-metadata-complete. In this case no annotation processing will take
|
* Whether all mapping files are xml-mapping-metadata-complete. In this case no annotation processing will take
|
||||||
|
@ -97,18 +96,6 @@ public final class Context {
|
||||||
|
|
||||||
lazyXmlParsing = Boolean.parseBoolean( pe.getOptions().get( JPAMetaModelEntityProcessor.LAZY_XML_PARSING ) );
|
lazyXmlParsing = Boolean.parseBoolean( pe.getOptions().get( JPAMetaModelEntityProcessor.LAZY_XML_PARSING ) );
|
||||||
logDebug = Boolean.parseBoolean( pe.getOptions().get( JPAMetaModelEntityProcessor.DEBUG_OPTION ) );
|
logDebug = Boolean.parseBoolean( pe.getOptions().get( JPAMetaModelEntityProcessor.DEBUG_OPTION ) );
|
||||||
|
|
||||||
// Workaround that Eclipse transformer tries to replace this constant which we don't want
|
|
||||||
String j = "j";
|
|
||||||
TypeElement java8AndBelowGeneratedAnnotation =
|
|
||||||
pe.getElementUtils().getTypeElement( j + "avax.annotation.Generated" );
|
|
||||||
if ( java8AndBelowGeneratedAnnotation != null ) {
|
|
||||||
generatedAnnotation = java8AndBelowGeneratedAnnotation.getQualifiedName().toString();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Using the new name for this annotation in Java 9 and above
|
|
||||||
generatedAnnotation = "javax.annotation.processing.Generated";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProcessingEnvironment getProcessingEnvironment() {
|
public ProcessingEnvironment getProcessingEnvironment() {
|
||||||
|
@ -119,10 +106,6 @@ public final class Context {
|
||||||
return addGeneratedAnnotation;
|
return addGeneratedAnnotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGeneratedAnnotationFqcn() {
|
|
||||||
return generatedAnnotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAddGeneratedAnnotation(boolean addGeneratedAnnotation) {
|
public void setAddGeneratedAnnotation(boolean addGeneratedAnnotation) {
|
||||||
this.addGeneratedAnnotation = addGeneratedAnnotation;
|
this.addGeneratedAnnotation = addGeneratedAnnotation;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue