HHH-16563: Using jakarta.annotation.Generated instead of javax versions

This commit is contained in:
Francois Steyn 2023-05-06 11:56:15 +02:00 committed by Steve Ebersole
parent 7e115eb8f4
commit a415555df4
6 changed files with 5 additions and 18 deletions

View File

@ -22,6 +22,7 @@ dependencies {
compileOnly libs.ant
annotationProcessor project( ':hibernate-jpamodelgen' )
compileOnly jakartaLibs.annotation
testImplementation project( ':hibernate-testing' )
}

View File

@ -9,6 +9,7 @@ dependencies {
testImplementation project( ':hibernate-testing' )
testAnnotationProcessor project( ':hibernate-jpamodelgen' )
testCompileOnly jakartaLibs.annotation
}
sourceSets {

View File

@ -113,6 +113,7 @@ dependencyResolutionManagement {
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( "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( "jsonbApi" ).to( "jakarta.json.bind", "jakarta.json.bind-api" ).version( "3.0.0" )
alias( "jsonb" ).to( "org.eclipse", "yasson" ).versionRef( "jsonbRuntime" )

View File

@ -29,6 +29,7 @@ dependencies {
testImplementation project( ':hibernate-core' )
testImplementation jakartaLibs.validation
testImplementation jakartaLibs.annotation
}
sourceSets.main {

View File

@ -203,7 +203,7 @@ public final class ClassWriter {
private static String writeGeneratedAnnotation(MetaEntity entity, Context context) {
StringBuilder generatedAnnotation = new StringBuilder();
generatedAnnotation.append( "@" )
.append( entity.importType( context.getGeneratedAnnotationFqcn() ) )
.append( entity.importType( "jakarta.annotation.Generated" ) )
.append( "(value = \"" )
.append( JPAMetaModelEntityProcessor.class.getName() );
if ( context.addGeneratedDate() ) {

View File

@ -52,7 +52,6 @@ public final class Context {
private final boolean lazyXmlParsing;
private final String persistenceXmlLocation;
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
@ -97,18 +96,6 @@ public final class Context {
lazyXmlParsing = Boolean.parseBoolean( pe.getOptions().get( JPAMetaModelEntityProcessor.LAZY_XML_PARSING ) );
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() {
@ -119,10 +106,6 @@ public final class Context {
return addGeneratedAnnotation;
}
public String getGeneratedAnnotationFqcn() {
return generatedAnnotation;
}
public void setAddGeneratedAnnotation(boolean addGeneratedAnnotation) {
this.addGeneratedAnnotation = addGeneratedAnnotation;
}