diff --git a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/HibernateOrmPlugin.java b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/HibernateOrmPlugin.java index 7b1ec99322..1869f4c715 100644 --- a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/HibernateOrmPlugin.java +++ b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/HibernateOrmPlugin.java @@ -111,7 +111,7 @@ public class HibernateOrmPlugin implements Plugin { genTask.injectSourceSet( ormDsl.getSourceSet() ); - genTask.getGenerationOutputDirectory().set( ormDsl.getJpaMetamodel().getGenerationOutputDirectory() ); + genTask.getGenerationOutputDirectory().convention( ormDsl.getJpaMetamodel().getGenerationOutputDirectory() ); genTask.getApplyGeneratedAnnotation().convention( ormDsl.getJpaMetamodel().getApplyGeneratedAnnotation() ); genTask.getSuppressions().convention( ormDsl.getJpaMetamodel().getSuppressions() ); diff --git a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/HibernateOrmSpec.java b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/HibernateOrmSpec.java index 76034d23ec..433439f999 100644 --- a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/HibernateOrmSpec.java +++ b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/HibernateOrmSpec.java @@ -69,6 +69,11 @@ public abstract class HibernateOrmSpec implements ExtensionAware { return javaPluginExtension.getSourceSets().getByName( name ); } + @Override + public abstract ExtensionContainer getExtensions(); + + + /** * Should the plugin inject a dependency on the same version of `hibernate-core` * as the version of this plugin? The dependency is added to the `implementation` @@ -82,20 +87,6 @@ public abstract class HibernateOrmSpec implements ExtensionAware { return useSameVersion; } - /** - * @see #getUseSameVersion() - */ - public void setUseSameVersion(boolean value) { - useSameVersion.set( value ); - } - - /** - * @see #getUseSameVersion() - */ - public void useSameVersion() { - useSameVersion.set( true ); - } - /** * The source-set containing the domain model. Defaults to the `main` source-set */ @@ -103,34 +94,6 @@ public abstract class HibernateOrmSpec implements ExtensionAware { return sourceSet; } - /** - * @see #getSourceSet() - */ - public void setSourceSet(String name) { - setSourceSet( resolveSourceSet( name, project ) ); - } - - /** - * @see #getSourceSet() - */ - public void setSourceSet(SourceSet sourceSet) { - this.sourceSet.set( sourceSet ); - } - - /** - * @see #getSourceSet() - */ - public void sourceSet(String name) { - setSourceSet( resolveSourceSet( name, project ) ); - } - - /** - * @see #getSourceSet() - */ - public void sourceSet(SourceSet sourceSet) { - setSourceSet( sourceSet ); - } - /** * The languages used in the project */ @@ -138,13 +101,6 @@ public abstract class HibernateOrmSpec implements ExtensionAware { return languages; } - public void setLanguages(Iterable languages) { - this.languages.set( languages ); - } - - public void languages(String language) { - this.languages.add( language ); - } /** * DSL extension for configuring bytecode enhancement. Also acts as the trigger for @@ -158,17 +114,6 @@ public abstract class HibernateOrmSpec implements ExtensionAware { return enhancementDsl; } - /** - * Provider access to {@link #getEnhancement()} - */ - public Provider getEnhancementDslAccess() { - return enhancementDslAccess; - } - - public boolean isEnhancementEnabled() { - return enhancementDsl != null; - } - /** * @see #getEnhancement() */ @@ -187,18 +132,6 @@ public abstract class HibernateOrmSpec implements ExtensionAware { return jpaMetamodelDsl; } - - /** - * Provider access to {@link #getJpaMetamodel()} - */ - public Provider getJpaMetamodelDslAccess() { - return jpaMetamodelDslAccess; - } - - public boolean isMetamodelGenerationEnabled() { - return jpaMetamodelDsl != null; - } - /** * @see #getJpaMetamodel() */ @@ -206,6 +139,114 @@ public abstract class HibernateOrmSpec implements ExtensionAware { action.execute( getJpaMetamodel() ); } - @Override - public abstract ExtensionContainer getExtensions(); + + public boolean isEnhancementEnabled() { + return enhancementDsl != null; + } + + public boolean isMetamodelGenerationEnabled() { + return jpaMetamodelDsl != null; + } + + + /** + * @see #getUseSameVersion() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void setUseSameVersion(boolean value) { + useSameVersion.set( value ); + } + + /** + * @see #getUseSameVersion() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void useSameVersion() { + useSameVersion.set( true ); + } + + /** + * @see #getSourceSet() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void setSourceSet(String name) { + setSourceSet( resolveSourceSet( name, project ) ); + } + + /** + * @see #getSourceSet() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void setSourceSet(SourceSet sourceSet) { + this.sourceSet.set( sourceSet ); + } + + /** + * @see #getSourceSet() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void sourceSet(String name) { + setSourceSet( resolveSourceSet( name, project ) ); + } + + /** + * @see #getSourceSet() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void sourceSet(SourceSet sourceSet) { + setSourceSet( sourceSet ); + } + + /** + * @see #getLanguages() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void setLanguages(Iterable languages) { + this.languages.set( languages ); + } + + /** + * @see #getLanguages() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated + public void languages(String language) { + this.languages.add( language ); + } + + /** + * Provider access to {@link #getEnhancement()} + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated + public Provider getEnhancementDslAccess() { + return enhancementDslAccess; + } + + + /** + * Provider access to {@link #getJpaMetamodel()} + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated + public Provider getJpaMetamodelDslAccess() { + return jpaMetamodelDslAccess; + } } diff --git a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/enhance/EnhancementSpec.java b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/enhance/EnhancementSpec.java index 7572274c3d..dfba9c8f4b 100644 --- a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/enhance/EnhancementSpec.java +++ b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/enhance/EnhancementSpec.java @@ -36,10 +36,18 @@ public class EnhancementSpec { enableLazyInitialization = makeProperty( project ).convention( true ); enableDirtyTracking = makeProperty( project ).convention( true ); - enableAssociationManagement = makeProperty( project ); - enableExtendedEnhancement = makeProperty( project ); + enableAssociationManagement = makeProperty( project ).convention( false ); + enableExtendedEnhancement = makeProperty( project ).convention( false ); } + @SuppressWarnings( "UnstableApiUsage" ) + public static Property makeProperty(Project project) { + return project.getObjects().property( Boolean.class ); + } + + /** + * Whether any property values indicate work to be done. + */ public boolean hasAnythingToDo() { return enableLazyInitialization.get() || enableDirtyTracking.get() @@ -47,96 +55,144 @@ public class EnhancementSpec { || enableExtendedEnhancement.get(); } - @Deprecated(forRemoval = true) + /** + * Whether lazy-initialization handling should be incorporated into the enhanced bytecode + */ public Property getEnableLazyInitialization() { return enableLazyInitialization; } + /** + * Whether dirty-tracking should be incorporated into the enhanced bytecode + */ + public Property getEnableDirtyTracking() { + return enableDirtyTracking; + } + + /** + * Whether bidirectional association-management handling should be incorporated into the enhanced bytecode + */ + public Property getEnableAssociationManagement() { + return enableAssociationManagement; + } + + /** + * Whether extended enhancement should be performed. + */ + public Property getEnableExtendedEnhancement() { + return enableExtendedEnhancement; + } + + + /** + * @deprecated See the Gradle property naming guidelines + */ @Deprecated(forRemoval = true) public void setEnableLazyInitialization(boolean enable) { enableLazyInitialization.set( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ @Deprecated(forRemoval = true) public void enableLazyInitialization(boolean enable) { setEnableLazyInitialization( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ @Deprecated(forRemoval = true) public void lazyInitialization(boolean enable) { setEnableLazyInitialization( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ @Deprecated(forRemoval = true) public void setLazyInitialization(boolean enable) { setEnableLazyInitialization( enable ); } - - @Deprecated(forRemoval = true) - public Property getEnableDirtyTracking() { - return enableDirtyTracking; - } - + /** + * @deprecated See the Gradle property naming guidelines + */ @Deprecated(forRemoval = true) public void setEnableDirtyTracking(boolean enable) { enableDirtyTracking.set( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ @Deprecated(forRemoval = true) public void enableDirtyTracking(boolean enable) { setEnableDirtyTracking( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ @Deprecated(forRemoval = true) public void dirtyTracking(boolean enable) { setEnableDirtyTracking( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ @Deprecated(forRemoval = true) public void setDirtyTracking(boolean enable) { setEnableDirtyTracking( enable ); } - - public Property getEnableAssociationManagement() { - return enableAssociationManagement; - } - + /** + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) public void setEnableAssociationManagement(boolean enable) { enableAssociationManagement.set( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) public void enableAssociationManagement(boolean enable) { setEnableAssociationManagement( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) public void associationManagement(boolean enable) { setEnableAssociationManagement( enable ); } - - public Property getEnableExtendedEnhancement() { - return enableExtendedEnhancement; - } - + /** + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) public void setEnableExtendedEnhancement(boolean enable) { enableExtendedEnhancement.set( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) public void enableExtendedEnhancement(boolean enable) { setEnableExtendedEnhancement( enable ); } + /** + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) public void extendedEnhancement(boolean enable) { setEnableExtendedEnhancement( enable ); } - - @SuppressWarnings( "UnstableApiUsage" ) - public static Property makeProperty(Project project) { - final Property createdProperty = project.getObjects().property( Boolean.class ); - // default to false - createdProperty.convention( false ); - return createdProperty; - } } diff --git a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/metamodel/JpaMetamodelGenerationSpec.java b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/metamodel/JpaMetamodelGenerationSpec.java index 60a6530189..5a17ab26ff 100644 --- a/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/metamodel/JpaMetamodelGenerationSpec.java +++ b/tooling/hibernate-gradle-plugin/src/main/java/org/hibernate/orm/tooling/gradle/metamodel/JpaMetamodelGenerationSpec.java @@ -56,30 +56,55 @@ public class JpaMetamodelGenerationSpec { return applyGeneratedAnnotation; } - public void applyGeneratedAnnotation(boolean apply) { - applyGeneratedAnnotation.set( apply ); - } - public SetProperty getSuppressions() { return suppressions; } - public void suppress(String warning) { - suppressions.add( warning ); - } - public DirectoryProperty getGenerationOutputDirectory() { return generationOutputDirectory; } - public void generationOutputDirectory(Object ref) { - generationOutputDirectory.set( project.file( ref ) ); - } - public DirectoryProperty getCompileOutputDirectory() { return compileOutputDirectory; } + + /** + * @see #getApplyGeneratedAnnotation() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void applyGeneratedAnnotation(boolean apply) { + applyGeneratedAnnotation.set( apply ); + } + + /** + * @see #getSuppressions() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void suppress(String warning) { + suppressions.add( warning ); + } + + /** + * @see #getGenerationOutputDirectory() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) + public void generationOutputDirectory(Object ref) { + generationOutputDirectory.set( project.file( ref ) ); + } + + /** + * @see #getCompileOutputDirectory() + * + * @deprecated See the Gradle property naming guidelines + */ + @Deprecated(forRemoval = true) public void compileOutputDirectory(Object ref) { compileOutputDirectory.set( project.file( ref ) ); } diff --git a/tooling/hibernate-gradle-plugin/src/test/resources/projects/multi-part-source-set-name/build.gradle b/tooling/hibernate-gradle-plugin/src/test/resources/projects/multi-part-source-set-name/build.gradle index 67e0058d29..70316df759 100644 --- a/tooling/hibernate-gradle-plugin/src/test/resources/projects/multi-part-source-set-name/build.gradle +++ b/tooling/hibernate-gradle-plugin/src/test/resources/projects/multi-part-source-set-name/build.gradle @@ -37,13 +37,12 @@ hibernate { useSameVersion = false sourceSet = 'mySpecialSourceSet' enhancement { - lazyInitialization( true ) + enableLazyInitialization.set(true) + lazyInitialization = true + + enableDirtyTracking.set(true) dirtyTracking = true } jpaMetamodel { } } - -tasks.withType(JavaCompile).forEach { - logger.lifecycle " - compile task : " + it.name -} diff --git a/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-kotlin/build.gradle b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-kotlin/build.gradle index d4a5fd6308..3c477402f7 100644 --- a/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-kotlin/build.gradle +++ b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple-kotlin/build.gradle @@ -28,7 +28,10 @@ dependencies { hibernate { useSameVersion = false enhancement { - lazyInitialization( true ) + enableLazyInitialization.set(true) + lazyInitialization = true + + enableDirtyTracking.set(true) dirtyTracking = true } jpaMetamodel { diff --git a/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple/build.gradle b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple/build.gradle index c5886befc6..a76152118a 100644 --- a/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple/build.gradle +++ b/tooling/hibernate-gradle-plugin/src/test/resources/projects/simple/build.gradle @@ -28,7 +28,10 @@ dependencies { hibernate { useSameVersion = false enhancement { - lazyInitialization( true ) + enableLazyInitialization.set(true) + lazyInitialization = true + + enableDirtyTracking.set(true) dirtyTracking = true } jpaMetamodel {