diff --git a/documentation/documentation.gradle b/documentation/documentation.gradle index 9200b920f09e..290a51f6ad5c 100644 --- a/documentation/documentation.gradle +++ b/documentation/documentation.gradle @@ -135,6 +135,9 @@ dependencies { reportAggregation project(':hibernate-processor') reportAggregation project(':hibernate-community-dialects') + dialectReportSources project( ':hibernate-core' ) + communityDialectReportSources project( ':hibernate-community-dialects' ) + core project( ':hibernate-core' ) javadocSources project( path: ':hibernate-core', configuration: 'javadocSources' ) @@ -226,7 +229,7 @@ def aggregateJavadocsTask = tasks.register( "javadoc", Javadoc ) { asciidoctorj { requires 'rouge' // Set version of AsciidoctorJ (plugin is currently uses 2.5.7 ? by default) - version '3.0.0' + version = '3.0.0' modules { pdf { version '2.3.18' diff --git a/gradle.properties b/gradle.properties index bf09b28cd3f1..2ff3f882adb8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,4 +29,9 @@ org.gradle.java.installations.auto-download=false orm.jdk.base=17 orm.jdk.min=21 # See gradlew/wrapper/gradle-wrapper.properties, https://docs.gradle.org/current/userguide/compatibility.html#java_runtime -orm.jdk.max=22 \ No newline at end of file +orm.jdk.max=22 + +# The minimum version of Gradle supported for the ORM Gradle plugin. +# This is the version used in the plugin tests, used to make sure we do not break compatibility. +# See `org.hibernate.orm.tooling.gradle.TestHelper` +orm.gradle.min=8.14 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135c49b7..8bdaf60c75ab 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d4081da476bb..2e1113280ef1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a426907..ef07e0162b18 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -203,7 +205,7 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. @@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 6689b85beecd..5eed7ee84528 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,22 +59,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell diff --git a/local-build-plugins/build.gradle b/local-build-plugins/build.gradle index 7b6bf092b073..2afd5a17741a 100644 --- a/local-build-plugins/build.gradle +++ b/local-build-plugins/build.gradle @@ -106,7 +106,7 @@ gradlePlugin { spotless { //Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically. - enforceCheck false + enforceCheck = false java { targetExclude( "**/target/**/*.java" ) licenseHeaderFile project.file("../shared/config/spotless/license.java") diff --git a/local-build-plugins/src/main/groovy/local.code-quality.gradle b/local-build-plugins/src/main/groovy/local.code-quality.gradle index 8b2652903ef7..786c554913f0 100644 --- a/local-build-plugins/src/main/groovy/local.code-quality.gradle +++ b/local-build-plugins/src/main/groovy/local.code-quality.gradle @@ -11,8 +11,8 @@ plugins { tasks.register( "ciCheck" ) { // Task used by CI builds - group "verification" - description "Checks for CI environments" + group = "verification" + description = "Checks for CI environments" dependsOn tasks.check } @@ -27,8 +27,8 @@ gradle.taskGraph.whenReady { tasks.register( "formatChecks" ) { // Only runs static code analysis, doesn't require compilation - group "verification" - description "Code style and formatting checks" + group = "verification" + description = "Code style and formatting checks" dependsOn tasks.spotlessCheck dependsOn tasks.enforceRules @@ -92,10 +92,10 @@ tasks.check.dependsOn enforceRulesTask spotless { //Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically. - enforceCheck false + enforceCheck = false java { targetExclude( "target/**/*.java" ) - licenseHeaderFile rootProject.file("shared/config/spotless/license.java") + licenseHeaderFile( rootProject.file("shared/config/spotless/license.java") ) removeUnusedImports() leadingSpacesToTabs( 4 ) trimTrailingWhitespace() diff --git a/local-build-plugins/src/main/groovy/local.java-module.gradle b/local-build-plugins/src/main/groovy/local.java-module.gradle index e2162e1b1ae1..ac895043ac1a 100644 --- a/local-build-plugins/src/main/groovy/local.java-module.gradle +++ b/local-build-plugins/src/main/groovy/local.java-module.gradle @@ -141,7 +141,7 @@ tasks.register('compile') { tasks.withType( JavaCompile ).configureEach { options.encoding = 'UTF-8' - options.warnings false + options.warnings = false options.fork = true options.forkOptions.memoryMaximumSize = '896m' @@ -162,7 +162,7 @@ tasks.withType( JavaCompile ).configureEach { } processTestResources { - duplicatesStrategy DuplicatesStrategy.INCLUDE + duplicatesStrategy = DuplicatesStrategy.INCLUDE inputs.property( "db", db ) inputs.property( "dbHost", dbHost ) diff --git a/local-build-plugins/src/main/groovy/local.publishing-java-module.gradle b/local-build-plugins/src/main/groovy/local.publishing-java-module.gradle index 7e46e9ccd404..0a045fdf94d1 100644 --- a/local-build-plugins/src/main/groovy/local.publishing-java-module.gradle +++ b/local-build-plugins/src/main/groovy/local.publishing-java-module.gradle @@ -46,8 +46,8 @@ publishingExtension.publications.named("publishedArtifacts", MavenPublication) { // Releasing def releasePrepareTask = tasks.register("releasePrepare") { - group "release" - description "See :release:releasePrepare for details. Here we hook in testing and checks ensure publish-ability" + group = "release" + description = "See :release:releasePrepare for details. Here we hook in testing and checks ensure publish-ability" dependsOn tasks.check dependsOn tasks.generateMetadataFileForPublishedArtifactsPublication @@ -56,8 +56,8 @@ def releasePrepareTask = tasks.register("releasePrepare") { // used from the h2 CI job tasks.register("preVerifyRelease") { - group "release-prepare" - description "Delegates to `releasePrepare` task" + group = "release-prepare" + description = "Delegates to `releasePrepare` task" dependsOn releasePrepareTask } diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/antlr/SplitGrammarGenerationTask.java b/local-build-plugins/src/main/java/org/hibernate/orm/antlr/SplitGrammarGenerationTask.java index f1077c898421..9a50f5544eb8 100644 --- a/local-build-plugins/src/main/java/org/hibernate/orm/antlr/SplitGrammarGenerationTask.java +++ b/local-build-plugins/src/main/java/org/hibernate/orm/antlr/SplitGrammarGenerationTask.java @@ -18,6 +18,7 @@ import org.gradle.api.tasks.PathSensitive; import org.gradle.api.tasks.PathSensitivity; import org.gradle.api.tasks.TaskAction; +import org.gradle.process.ExecOperations; import static org.hibernate.orm.antlr.AntlrHelper.stripSillyGeneratedFromLines; @@ -27,6 +28,7 @@ @CacheableTask public abstract class SplitGrammarGenerationTask extends DefaultTask { private final SplitGrammarDescriptor grammarDescriptor; + private final ExecOperations execOperations; private final Provider lexerGrammarFile; private final Provider parserGrammarFile; @@ -35,8 +37,12 @@ public abstract class SplitGrammarGenerationTask extends DefaultTask { private final Provider outputDirectory; @Inject - public SplitGrammarGenerationTask(SplitGrammarDescriptor grammarDescriptor, AntlrSpec antlrSpec) { + public SplitGrammarGenerationTask( + SplitGrammarDescriptor grammarDescriptor, + AntlrSpec antlrSpec, + ExecOperations execOperations) { this.grammarDescriptor = grammarDescriptor; + this.execOperations = execOperations; lexerGrammarFile = getProject().provider( () -> { final Directory grammarBaseDirectory = antlrSpec.getGrammarBaseDirectory().get(); @@ -109,9 +115,9 @@ private void generateLexer(File outputDir) { ); - getProject().javaexec( + execOperations.javaexec( (javaExecSpec) -> { - javaExecSpec.setMain( "org.antlr.v4.Tool" ); + javaExecSpec.getMainClass().set( "org.antlr.v4.Tool" ); javaExecSpec.classpath( getProject().getConfigurations().getByName( "antlr" ) ); javaExecSpec.args( "-o", getProject().relativePath( outputDir.getAbsolutePath() ), @@ -133,9 +139,9 @@ private void generateParser(File outputDir) { ); - getProject().javaexec( + execOperations.javaexec( (javaExecSpec) -> { - javaExecSpec.setMain( "org.antlr.v4.Tool" ); + javaExecSpec.getMainClass().set( "org.antlr.v4.Tool" ); javaExecSpec.classpath( getProject().getConfigurations().named( "antlr" ) ); javaExecSpec.args( "-o", getProject().relativePath( outputDir.getAbsolutePath() ), diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaDirectoryTransformation.java b/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaDirectoryTransformation.java deleted file mode 100644 index 02800f08ab92..000000000000 --- a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaDirectoryTransformation.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.jakarta; - -import java.io.File; -import javax.inject.Inject; - -import org.gradle.api.DefaultTask; -import org.gradle.api.file.DirectoryProperty; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.tasks.CacheableTask; -import org.gradle.api.tasks.InputDirectory; -import org.gradle.api.tasks.OutputDirectory; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.TaskAction; - -import static org.hibernate.orm.jakarta.JakartaPlugin.JAKARTA; - -/** - * @author Steve Ebersole - */ -@CacheableTask -public abstract class JakartaDirectoryTransformation extends DefaultTask { - private final DirectoryProperty sourceDirectory; - private final DirectoryProperty targetDirectory; - - @Inject - public JakartaDirectoryTransformation(ObjectFactory objectFactory) { - sourceDirectory = objectFactory.directoryProperty(); - targetDirectory = objectFactory.directoryProperty(); - - setGroup( JAKARTA ); - } - - @InputDirectory - @PathSensitive( PathSensitivity.RELATIVE ) - public DirectoryProperty getSourceDirectory() { - return sourceDirectory; - } - - @OutputDirectory - public DirectoryProperty getTargetDirectory() { - return targetDirectory; - } - - @TaskAction - void transform() { - final File sourceDirAsFile = sourceDirectory.get().getAsFile(); - final File targetDirAsFile = targetDirectory.get().getAsFile(); - - // If the target directory already exists, the transformer tool will - // skip the transformation - even if the directory is empty. - // Gradle is nice enough to make sure that directory exists, but - // unfortunately that "confuses" the transformer tool. - // - // For now, delete the dir before executing the transformer. - // - // NOTE : Gradle has already done its up-to-date checks and our task - // is actually executing at this point, so deleting the directory will - // have no effect on the incremental build - - targetDirAsFile.delete(); - - getProject().javaexec( - (javaExecSpec) -> { - javaExecSpec.classpath( getProject().getConfigurations().getByName( "jakartaeeTransformTool" ) ); - javaExecSpec.setMain( "org.eclipse.transformer.jakarta.JakartaTransformer" ); - javaExecSpec.args( - sourceDirAsFile.getAbsolutePath(), - targetDirAsFile.getAbsolutePath(), - "-q", - "-tr", getProject().getRootProject().file( "rules/jakarta-renames.properties" ).getAbsolutePath(), - "-tv", getProject().getRootProject().file( "rules/jakarta-versions.properties" ).getAbsolutePath(), - "-td", getProject().getRootProject().file( "rules/jakarta-direct.properties" ).getAbsolutePath() - ); - } - ); - } -} diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaJarTransformation.java b/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaJarTransformation.java deleted file mode 100644 index 96671e4793e0..000000000000 --- a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaJarTransformation.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.jakarta; - -import javax.inject.Inject; - -import org.gradle.api.DefaultTask; -import org.gradle.api.file.RegularFileProperty; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.tasks.CacheableTask; -import org.gradle.api.tasks.InputFile; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.PathSensitive; -import org.gradle.api.tasks.PathSensitivity; -import org.gradle.api.tasks.TaskAction; - -import static org.hibernate.orm.jakarta.JakartaPlugin.JAKARTA; - -/** - * @author Steve Ebersole - */ -@CacheableTask -public abstract class JakartaJarTransformation extends DefaultTask { - private final RegularFileProperty sourceJar; - private final RegularFileProperty targetJar; - - @Inject - public JakartaJarTransformation(ObjectFactory objectFactory) { - sourceJar = objectFactory.fileProperty(); - targetJar = objectFactory.fileProperty(); - - setGroup( JAKARTA ); - } - - @InputFile - @PathSensitive( PathSensitivity.RELATIVE ) - public RegularFileProperty getSourceJar() { - return sourceJar; - } - - @OutputFile - public RegularFileProperty getTargetJar() { - return targetJar; - } - - @TaskAction - void transform() { - getProject().javaexec( - (javaExecSpec) -> { - javaExecSpec.classpath( getProject().getConfigurations().getByName( "jakartaeeTransformTool" ) ); - javaExecSpec.setMain( "org.eclipse.transformer.jakarta.JakartaTransformer" ); - javaExecSpec.args( - sourceJar.get().getAsFile().getAbsolutePath(), - targetJar.get().getAsFile().getAbsolutePath(), - "-q", - "-tr", getProject().getRootProject().file( "rules/jakarta-renames.properties" ).getAbsolutePath(), - "-tv", getProject().getRootProject().file( "rules/jakarta-versions.properties" ).getAbsolutePath(), - "-td", getProject().getRootProject().file( "rules/jakarta-direct.properties" ).getAbsolutePath() - ); - } - ); - } -} diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaPlugin.java b/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaPlugin.java deleted file mode 100644 index 79587b3e5ac4..000000000000 --- a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaPlugin.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.jakarta; - -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.file.ConfigurableFileCollection; -import org.gradle.api.file.Directory; -import org.gradle.api.file.DirectoryProperty; -import org.gradle.api.plugins.JavaPluginConvention; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.Copy; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.api.tasks.TaskContainer; -import org.gradle.api.tasks.bundling.Jar; -import org.gradle.api.tasks.compile.JavaCompile; -import org.gradle.api.tasks.testing.Test; -import org.gradle.language.jvm.tasks.ProcessResources; - -import static org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME; -import static org.gradle.api.tasks.SourceSet.TEST_SOURCE_SET_NAME; - -/** - * @author Steve Ebersole - */ -public class JakartaPlugin implements Plugin { - public static final String JAKARTA = "jakarta"; - - @Override - public void apply(Project project) { - // register short-names for the task classes (fake "import") - project.getExtensions().getExtraProperties().set( JakartaDirectoryTransformation.class.getSimpleName(), JakartaDirectoryTransformation.class ); - project.getExtensions().getExtraProperties().set( JakartaJarTransformation.class.getSimpleName(), JakartaJarTransformation.class ); - - final Configuration api = project.getConfigurations().create( - "api", - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( false ); - } - ); - - final Configuration implementation = project.getConfigurations().create( - "implementation", - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( false ); - configuration.extendsFrom( api ); - } - ); - - final Configuration compileOnly = project.getConfigurations().create( - "compileOnly", - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( false ); - } - ); - - final Configuration runtimeOnly = project.getConfigurations().create( - "runtimeOnly", - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( false ); - } - ); - - project.getConfigurations().create( - "compileClasspath", - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( true ); - configuration.extendsFrom( compileOnly, implementation ); - } - ); - - - project.getConfigurations().create( - "runtimeClasspath", - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( true ); - configuration.extendsFrom( runtimeOnly, implementation ); - } - ); - - final Configuration testImplementation = project.getConfigurations().create( - "testImplementation", - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( false ); - configuration.extendsFrom( implementation ); - } - ); - - final Configuration testCompileOnly = project.getConfigurations().create( - "testCompileOnly", - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( false ); - configuration.extendsFrom( compileOnly ); - } - ); - - final Configuration testRuntimeOnly = project.getConfigurations().create( - "testRuntimeOnly" , - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( false ); - configuration.extendsFrom( runtimeOnly ); - } - ); - - final Configuration testCompileClasspath = project.getConfigurations().create( - "testCompileClasspath" , - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( true ); - configuration.extendsFrom( testImplementation, testCompileOnly ); - } - ); - - final Configuration testRuntimeClasspath = project.getConfigurations().create( - "testRuntimeClasspath" , - (configuration) -> { - configuration.setCanBeConsumed( false ); - configuration.setCanBeResolved( true ); - configuration.extendsFrom( testImplementation, testRuntimeOnly ); - } - ); - - // determine the "source" project - final String path = project.getPath(); - assert path.endsWith( "-jakarta" ) : "Project path did not end with `-jakarta`"; - final String sourceProjectPath = path.substring( 0, path.length() - 8 ); - final Project sourceProject = project.getRootProject().project( sourceProjectPath ); - - - // Get tasks from the source project we will need - final TaskContainer sourceProjectTasks = sourceProject.getTasks(); - final SourceSetContainer sourceProjectSourceSets = extractSourceSets( sourceProject ); - final SourceSet sourceProjectMainSourceSet = sourceProjectSourceSets.getByName( MAIN_SOURCE_SET_NAME ); - final Jar sourceProjectJarTask = (Jar) sourceProjectTasks.getByName( sourceProjectMainSourceSet.getJarTaskName() ); - final Jar sourceProjectSourcesJarTask = (Jar) sourceProjectTasks.getByName( sourceProjectMainSourceSet.getSourcesJarTaskName() ); - final Jar sourceProjectJavadocJarTask = (Jar) sourceProjectTasks.getByName( sourceProjectMainSourceSet.getJavadocJarTaskName() ); - final SourceSet sourceProjectTestSourceSet = sourceProjectSourceSets.getByName( TEST_SOURCE_SET_NAME ); - final JavaCompile sourceProjectCompileTestClassesTask = (JavaCompile) sourceProjectTasks.getByName( sourceProjectTestSourceSet.getCompileJavaTaskName() ); - final ProcessResources sourceProjectProcessTestResourcesTask = (ProcessResources) sourceProjectTasks.getByName( sourceProjectTestSourceSet.getProcessResourcesTaskName() ); - - - // Create the "jakartafication" assemble tasks - final TaskContainer tasks = project.getTasks(); - final Task jakartafyTask = tasks.create( - "jakartafy", - (task) -> { - task.setDescription( "Performs all of the Jakarta transformations" ); - task.setGroup( JAKARTA ); - } - ); - - final DirectoryProperty buildDirectory = project.getLayout().getBuildDirectory(); - - tasks.create( - "jakartafyJar", - JakartaJarTransformation.class, - (transformation) -> { - transformation.dependsOn( sourceProjectJarTask ); - transformation.setDescription( "Transforms the source project's main jar" ); - transformation.setGroup( JAKARTA ); - transformation.getSourceJar().convention( sourceProjectJarTask.getArchiveFile() ); - transformation.getTargetJar().convention( buildDirectory.file( relativeArchiveFileName( project, null ) ) ); - jakartafyTask.dependsOn( transformation ); - } - ); - - tasks.create( - "jakartafySourcesJar", - JakartaJarTransformation.class, - (transformation) -> { - transformation.dependsOn( sourceProjectSourcesJarTask ); - transformation.setDescription( "Transforms the source project's sources jar" ); - transformation.setGroup( JAKARTA ); - transformation.getSourceJar().convention( sourceProjectSourcesJarTask.getArchiveFile() ); - transformation.getTargetJar().convention( buildDirectory.file( relativeArchiveFileName( project, "sources" ) ) ); - jakartafyTask.dependsOn( transformation ); - } - ); - - tasks.create( - "jakartafyJavadocJar", - JakartaJarTransformation.class, - (transformation) -> { - transformation.dependsOn( sourceProjectJavadocJarTask ); - transformation.setDescription( "Transforms the source project's javadoc jar" ); - transformation.setGroup( JAKARTA ); - transformation.getSourceJar().convention( sourceProjectJavadocJarTask.getArchiveFile() ); - transformation.getTargetJar().convention( buildDirectory.file( relativeArchiveFileName( project, "javadoc" ) ) ); - jakartafyTask.dependsOn( transformation ); - } - ); - - final Provider testCollectDir = project.getLayout().getBuildDirectory().dir( "jakarta/collect/tests" ); - final Provider testTransformedDir = project.getLayout().getBuildDirectory().dir( "jakarta/transformed/tests" ); - - final Copy collectTests = tasks.create( - "collectTests", - Copy.class, - (task) -> { - task.dependsOn( sourceProjectCompileTestClassesTask, sourceProjectProcessTestResourcesTask ); - task.setDescription( "Collects all needed test classes and resources into a single directory for transformation" ); - task.setGroup( JAKARTA ); - task.from( sourceProjectTestSourceSet.getOutput() ); - task.into( testCollectDir ); - } - ); - - final JakartaDirectoryTransformation jakartafyTests = tasks.create( - "jakartafyTests", - JakartaDirectoryTransformation.class, - (task) -> { - task.dependsOn( collectTests ); - task.setDescription( "Jakartafies the tests in preparation for execution" ); - task.setGroup( JAKARTA ); - task.getSourceDirectory().convention( testCollectDir ); - task.getTargetDirectory().convention( testTransformedDir ); - } - ); - - tasks.create( - "test", - Test.class, - (task) -> { - task.dependsOn( jakartafyTests ); - task.setDescription( "Performs the jakartafied tests against the jakartafied artifact" ); - task.setGroup( JAKARTA ); - - final ConfigurableFileCollection transformedTests = project.files( testTransformedDir ); - task.setTestClassesDirs( transformedTests ); - task.setClasspath( task.getClasspath().plus( transformedTests ).plus( testRuntimeClasspath ) ); - - project.getLayout().getBuildDirectory(); - task.getBinaryResultsDirectory().convention( project.getLayout().getBuildDirectory().dir( "test-results/test/binary" ) ); - task.reports( (reports) -> { - reports.getHtml().getOutputLocation().convention( buildDirectory.dir( "reports/tests/test" ) ); - reports.getJunitXml().getOutputLocation().convention( buildDirectory.dir( "test-results/test" ) ); - }); - } - ); - } - - public static String relativeArchiveFileName(Project project, String classifier) { - final StringBuilder nameBuilder = new StringBuilder( "lib/" ); - nameBuilder.append( project.getName() ); - nameBuilder.append( "-" ).append( project.getVersion() ); - if ( classifier != null ) { - nameBuilder.append( "-" ).append( classifier ); - } - return nameBuilder.append( ".jar" ).toString(); - } - - public static SourceSetContainer extractSourceSets(Project project) { - final JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin( JavaPluginConvention.class ); - assert javaPluginConvention != null; - return javaPluginConvention.getSourceSets(); - } -} diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaPublishingPlugin.java b/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaPublishingPlugin.java deleted file mode 100644 index da2b11e8dc12..000000000000 --- a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaPublishingPlugin.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.jakarta; - -import java.util.function.Consumer; -import javax.inject.Inject; - -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.Task; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.attributes.AttributeContainer; -import org.gradle.api.attributes.Bundling; -import org.gradle.api.attributes.Category; -import org.gradle.api.attributes.DocsType; -import org.gradle.api.attributes.LibraryElements; -import org.gradle.api.attributes.Usage; -import org.gradle.api.component.AdhocComponentWithVariants; -import org.gradle.api.component.SoftwareComponentFactory; -import org.gradle.api.model.ObjectFactory; -import org.gradle.api.tasks.TaskContainer; -import org.gradle.api.tasks.TaskProvider; - -/** - * Models a publishable Jakartafied project - * - * @author Steve Ebersole - */ -public class JakartaPublishingPlugin implements Plugin { - public static final String MAIN_CONFIG_NAME = "jakartaElements"; - public static final String MAIN_JAR_TASK_NAME = "jakartafyJar"; - - public static final String SOURCES_CONFIG_NAME = "jakartaSourcesElements"; - public static final String SOURCES_JAR_TASK_NAME = "jakartafySourcesJar"; - - public static final String JAVADOC_CONFIG_NAME = "jakartaJavadocElements"; - public static final String JAVADOC_JAR_TASK_NAME = "jakartafyJavadocJar"; - - private final SoftwareComponentFactory softwareComponentFactory; - - @Inject - public JakartaPublishingPlugin(SoftwareComponentFactory softwareComponentFactory) { - this.softwareComponentFactory = softwareComponentFactory; - } - - @Override - public void apply(Project project) { - project.getPlugins().apply( JakartaPlugin.class ); - - final AdhocComponentWithVariants jakartaComponent = softwareComponentFactory.adhoc( "jakarta" ); - project.getComponents().add( jakartaComponent ); - - addMainVariant( jakartaComponent, project ); - addSourcesVariant( jakartaComponent, project ); - addJavadocVariant( jakartaComponent, project ); - } - - private void addMainVariant( - AdhocComponentWithVariants jakartaComponent, - Project project) { - final ObjectFactory objectFactory = project.getObjects(); - final Task jakartafyJar = project.getTasks().getByName( "jakartafyJar" ); - - addVariant( - MAIN_CONFIG_NAME, - MAIN_JAR_TASK_NAME, - null, - jakartaComponent, - jakartafyJar, - (attributes) -> { - attributes.attribute( - Usage.USAGE_ATTRIBUTE, - objectFactory.named( Usage.class, Usage.JAVA_RUNTIME ) - ); - - attributes.attribute( - Category.CATEGORY_ATTRIBUTE, - objectFactory.named( Category.class, Category.LIBRARY ) - ); - - attributes.attribute( - Bundling.BUNDLING_ATTRIBUTE, - objectFactory.named( Bundling.class, Bundling.EXTERNAL ) - ); - - attributes.attribute( - LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, - objectFactory.named( LibraryElements.class, LibraryElements.CLASSES_AND_RESOURCES ) - ); - }, - project - ); - } - - private void addSourcesVariant(AdhocComponentWithVariants jakartaComponent, Project project) { - final ObjectFactory objectFactory = project.getObjects(); - final Task jakartafyJar = project.getTasks().getByName( "jakartafySourcesJar" ); - - addVariant( - SOURCES_CONFIG_NAME, - SOURCES_JAR_TASK_NAME, - "sources", - jakartaComponent, - jakartafyJar, - (attributes) -> { - attributes.attribute( - Usage.USAGE_ATTRIBUTE, - objectFactory.named( Usage.class, Usage.JAVA_RUNTIME ) - ); - - attributes.attribute( - Bundling.BUNDLING_ATTRIBUTE, - objectFactory.named( Bundling.class, Bundling.EXTERNAL ) - ); - - attributes.attribute( - Category.CATEGORY_ATTRIBUTE, - objectFactory.named( Category.class, Category.DOCUMENTATION ) - ); - - attributes.attribute( - DocsType.DOCS_TYPE_ATTRIBUTE, - objectFactory.named( DocsType.class, DocsType.SOURCES ) - ); - }, - project - ); - } - - private void addJavadocVariant(AdhocComponentWithVariants jakartaComponent, Project project) { - final ObjectFactory objectFactory = project.getObjects(); - final Task jakartafyJar = project.getTasks().getByName( "jakartafyJavadocJar" ); - - addVariant( - JAVADOC_CONFIG_NAME, - JAVADOC_JAR_TASK_NAME, - "javadoc", - jakartaComponent, - jakartafyJar, - (attributes) -> { - attributes.attribute( - Usage.USAGE_ATTRIBUTE, - objectFactory.named( Usage.class, Usage.JAVA_RUNTIME ) - ); - - attributes.attribute( - Bundling.BUNDLING_ATTRIBUTE, - objectFactory.named( Bundling.class, Bundling.EXTERNAL ) - ); - - attributes.attribute( - Category.CATEGORY_ATTRIBUTE, - objectFactory.named( Category.class, Category.DOCUMENTATION ) - ); - - attributes.attribute( - DocsType.DOCS_TYPE_ATTRIBUTE, - objectFactory.named( DocsType.class, DocsType.JAVADOC ) - ); - }, - project - ); - } - - - private void addVariant( - String configName, - String jarTaskName, - String classifier, - AdhocComponentWithVariants jakartaComponent, - Task jakartaJarTask, - Consumer attributesAdjuster, - Project project) { - final Configuration variantConfig = project.getConfigurations().create( - configName, - (publicationConfiguration) -> { - publicationConfiguration.setDescription( "Consumable configuration for Jakartafied sources jar" ); - publicationConfiguration.setCanBeConsumed( true ); - publicationConfiguration.setCanBeResolved( false ); - publicationConfiguration.setVisible( false ); - - attributesAdjuster.accept( publicationConfiguration.getAttributes() ); - } - ); - - jakartaComponent.addVariantsFromConfiguration( - variantConfig, - (variantDetails) -> variantDetails.mapToMavenScope( "runtime" ) - ); - - final TaskProvider mainJarTask; - final TaskContainer tasks = project.getTasks(); - if ( ! tasks.getNames().contains( jarTaskName ) ) { - mainJarTask = tasks.register( - jarTaskName, - JakartaJarTransformation.class, - (jakartaficationTask) -> jakartaficationTask.setDescription( "Produces the Jakartafied main jar for `" + project.getPath() + "`" ) - ); - if ( tasks.getNames().contains( "assemble" ) ) { - tasks.named( "assemble" ).configure( (assembleTask) -> assembleTask.dependsOn( mainJarTask ) ); - } - } - else { - mainJarTask = tasks.named( jarTaskName, JakartaJarTransformation.class ); - } - - variantConfig.getOutgoing().artifact( - mainJarTask.get().getTargetJar(), - (artifact) -> { - artifact.setClassifier( classifier ); - artifact.setExtension( "jar" ); - artifact.builtBy( jakartaJarTask ); - } - ); - } - -} diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaSpec.java b/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaSpec.java deleted file mode 100644 index 19fce4205ea1..000000000000 --- a/local-build-plugins/src/main/java/org/hibernate/orm/jakarta/JakartaSpec.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * Copyright Red Hat Inc. and Hibernate Authors - */ -package org.hibernate.orm.jakarta; - -import javax.inject.Inject; - -import org.gradle.api.Project; -import org.gradle.api.artifacts.Dependency; - -/** - * Gradle DSL extension for configuring the Jakartafying transformations - * needed for a project. Mainly used to trigger different conventions depending - * on whether the "source" is a local project or an external module - * - * NOTE : abstract to allow Gradle to "weave in" behavior (like being an extension container, etc) - * - * @author Steve Ebersole - */ -public abstract class JakartaSpec { - public static final String REGISTRATION_NAME = "jakarta"; - - private final Project jakartaProject; - - private Dependency sourceDependency; - - @Inject - public JakartaSpec(Project jakartaProject) { - // `jakartaProject` is the project where this plugin gets applied - the `-jakarta` one - this.jakartaProject = jakartaProject; - } - - public void source(Object dependencyNotation) { - if ( sourceDependency != null ) { - throw new IllegalStateException( "Source Dependency already specified" ); - } - - sourceDependency = jakartaProject.getDependencies().create( dependencyNotation ); - } - - public Dependency getSourceDependency() { - return sourceDependency; - } -} diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/post/DialectReportTask.java b/local-build-plugins/src/main/java/org/hibernate/orm/post/DialectReportTask.java index 119a27fee2bd..2bb37e757022 100644 --- a/local-build-plugins/src/main/java/org/hibernate/orm/post/DialectReportTask.java +++ b/local-build-plugins/src/main/java/org/hibernate/orm/post/DialectReportTask.java @@ -4,6 +4,17 @@ */ package org.hibernate.orm.post; +import org.gradle.api.file.ConfigurableFileCollection; +import org.gradle.api.file.RegularFile; +import org.gradle.api.provider.Property; +import org.gradle.api.provider.Provider; +import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.InputFiles; +import org.gradle.api.tasks.OutputFile; +import org.gradle.api.tasks.TaskAction; +import org.jboss.jandex.ClassInfo; +import org.jboss.jandex.Index; + import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -16,41 +27,23 @@ import java.util.Comparator; import java.util.List; -import org.gradle.api.Project; -import org.gradle.api.file.RegularFile; -import org.gradle.api.provider.Property; -import org.gradle.api.provider.Provider; -import org.gradle.api.tasks.Input; -import org.gradle.api.tasks.OutputFile; -import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.api.tasks.TaskAction; - -import org.jboss.jandex.ClassInfo; -import org.jboss.jandex.Index; - /** * Generates a report on Dialect information * * @author Steve Ebersole */ public abstract class DialectReportTask extends AbstractJandexAwareTask { - private final Property sourceProject; + private final ConfigurableFileCollection dialectReportSources; private final Property sourcePackage; private final Property reportFile; public DialectReportTask() { - setDescription( "Generates a report of Dialects" ); - sourceProject = getProject().getObjects().property(String.class); + setDescription( "Generates a report of the supported Dialects" ); + dialectReportSources = getProject().getObjects().fileCollection(); sourcePackage = getProject().getObjects().property(String.class); reportFile = getProject().getObjects().fileProperty(); } - @Input - public Property getSourceProject() { - return sourceProject; - } - @Input public Property getSourcePackage() { return sourcePackage; @@ -61,6 +54,11 @@ public Property getReportFile() { return reportFile; } + @InputFiles + public ConfigurableFileCollection getDialectReportSources() { + return dialectReportSources; + } + @Override protected Provider getTaskReportFileReference() { return reportFile; @@ -68,13 +66,7 @@ protected Provider getTaskReportFileReference() { @TaskAction public void generateDialectReport() { - // TODO this probably messes up the cache since we don't declare an explicit dependency to a source set - // but the problem is pre-existing and I don't have time to investigate. - Project sourceProject = getProject().getRootProject().project( this.sourceProject.get() ); - final SourceSetContainer sourceSets = sourceProject.getExtensions().getByType( SourceSetContainer.class ); - final SourceSet sourceSet = sourceSets.getByName( SourceSet.MAIN_SOURCE_SET_NAME ); - final ClassLoader classLoader = Helper.asClassLoader( sourceSet, sourceProject.getConfigurations().getByName( "testRuntimeClasspath" ) ); - + final ClassLoader classLoader = Helper.asClassLoader( dialectReportSources ); final DialectClassDelegate dialectClassDelegate = new DialectClassDelegate( classLoader ); final Index index = getIndexManager().getIndex(); diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/post/Helper.java b/local-build-plugins/src/main/java/org/hibernate/orm/post/Helper.java index 65d2e239f9f3..53cf79c47322 100644 --- a/local-build-plugins/src/main/java/org/hibernate/orm/post/Helper.java +++ b/local-build-plugins/src/main/java/org/hibernate/orm/post/Helper.java @@ -4,6 +4,8 @@ */ package org.hibernate.orm.post; +import org.gradle.api.file.FileCollection; + import java.io.File; import java.net.MalformedURLException; import java.net.URL; @@ -11,23 +13,17 @@ import java.util.ArrayList; import java.util.List; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.file.Directory; -import org.gradle.api.tasks.SourceSet; - /** * @author Steve Ebersole */ public class Helper { - public static ClassLoader asClassLoader(SourceSet sourceSet, Configuration gradleClasspath) { + public static ClassLoader asClassLoader(FileCollection... fileCollections) { final List urls = new ArrayList<>(); - final Directory classesDirectory = sourceSet.getJava().getClassesDirectory().get(); - final File classesDir = classesDirectory.getAsFile(); - addElement( urls, classesDir ); - - for ( File dependencyFile : gradleClasspath.resolve() ) { - addElement( urls, dependencyFile ); + for ( FileCollection fileCollection : fileCollections ) { + fileCollection.getFiles().forEach( dependencyFile -> { + addElement( urls, dependencyFile ); + } ); } return new URLClassLoader( urls.toArray( new URL[0] ) ); diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/post/IndexerTask.java b/local-build-plugins/src/main/java/org/hibernate/orm/post/IndexerTask.java index 8e1f74944700..64b779b5dc99 100644 --- a/local-build-plugins/src/main/java/org/hibernate/orm/post/IndexerTask.java +++ b/local-build-plugins/src/main/java/org/hibernate/orm/post/IndexerTask.java @@ -13,7 +13,7 @@ import org.gradle.api.tasks.SkipWhenEmpty; import org.gradle.api.tasks.TaskAction; -import static org.hibernate.orm.post.ReportGenerationPlugin.CONFIG_NAME; +import static org.hibernate.orm.post.ReportGenerationPlugin.AGGREGATE_CONFIG_NAME; import static org.hibernate.orm.post.ReportGenerationPlugin.TASK_GROUP_NAME; /** @@ -26,7 +26,7 @@ public abstract class IndexerTask extends DefaultTask { public IndexerTask() { setGroup( TASK_GROUP_NAME ); - setDescription( "Builds a Jandex Index from the artifacts attached to the `" + CONFIG_NAME + "` Configuration" ); + setDescription( String.format( "Builds a Jandex Index from the artifacts attached to the `%s` Configuration", AGGREGATE_CONFIG_NAME ) ); indexManager = getProject().provider( () -> getProject().getExtensions().getByType( IndexManager.class ) ); } diff --git a/local-build-plugins/src/main/java/org/hibernate/orm/post/ReportGenerationPlugin.java b/local-build-plugins/src/main/java/org/hibernate/orm/post/ReportGenerationPlugin.java index 5cfdbe501317..b5ff4cf22dcf 100644 --- a/local-build-plugins/src/main/java/org/hibernate/orm/post/ReportGenerationPlugin.java +++ b/local-build-plugins/src/main/java/org/hibernate/orm/post/ReportGenerationPlugin.java @@ -6,78 +6,84 @@ import org.gradle.api.Plugin; import org.gradle.api.Project; -import org.gradle.api.Task; import org.gradle.api.artifacts.Configuration; -import org.gradle.api.tasks.TaskProvider; /** * @author Steve Ebersole */ public class ReportGenerationPlugin implements Plugin { - public static final String CONFIG_NAME = "reportAggregation"; public static final String TASK_GROUP_NAME = "hibernate-reports"; + public static final String AGGREGATE_CONFIG_NAME = "reportAggregation"; + public static final String DIALECT_CONFIG_NAME = "dialectReportSources"; + public static final String COMMUNITY_DIALECT_CONFIG_NAME = "communityDialectReportSources"; @Override public void apply(Project project) { final Configuration artifactsToProcess = project.getConfigurations() - .maybeCreate( CONFIG_NAME ) + .maybeCreate( AGGREGATE_CONFIG_NAME ) .setDescription( "Used to collect the jars with classes files to be used in the aggregation reports for `@Internal`, `@Incubating`, etc" ); - final IndexManager indexManager = new IndexManager( artifactsToProcess, project ); + final var indexManager = new IndexManager( artifactsToProcess, project ); project.getExtensions().add( "indexManager", indexManager ); - final TaskProvider indexerTask = project.getTasks().register( + final var indexerTask = project.getTasks().register( "buildAggregatedIndex", IndexerTask.class ); - final TaskProvider incubatingTask = project.getTasks().register( + final var incubatingTask = project.getTasks().register( "generateIncubationReport", IncubationReportTask.class, (task) -> task.dependsOn( indexerTask ) ); - final TaskProvider deprecationTask = project.getTasks().register( + final var deprecationTask = project.getTasks().register( "generateDeprecationReport", DeprecationReportTask.class, (task) -> task.dependsOn( indexerTask ) ); - final TaskProvider internalsTask = project.getTasks().register( + final var internalsTask = project.getTasks().register( "generateInternalsReport", InternalsReportTask.class, (task) -> task.dependsOn( indexerTask ) ); - final TaskProvider loggingTask = project.getTasks().register( + final var loggingTask = project.getTasks().register( "generateLoggingReport", LoggingReportTask.class, (task) -> task.dependsOn( indexerTask ) ); - final TaskProvider dialectTableTask = project.getTasks().register( + final var dialectConfig = project.getConfigurations() + .maybeCreate( DIALECT_CONFIG_NAME ) + .setDescription( "Used to define classpath for performing reflection on Dialects for the Dialect report" ); + var dialectTableTask = project.getTasks().register( "generateDialectTableReport", DialectReportTask.class, (task) -> { task.dependsOn( indexerTask ); - task.setProperty( "sourceProject", "hibernate-core" ); - task.setProperty( "sourcePackage", "org.hibernate.dialect" ); - task.setProperty( "reportFile", project.getLayout().getBuildDirectory().file( "orm/generated/dialect/dialect-table.adoc" ) ); + task.getDialectReportSources().from( dialectConfig ); + task.getSourcePackage().set( "org.hibernate.dialect" ); + task.getReportFile().set( project.getLayout().getBuildDirectory().file( "orm/generated/dialect/dialect-table.adoc" ) ); } ); - final TaskProvider communityDialectTableTask = project.getTasks().register( + final var communityDialectConfig = project.getConfigurations() + .maybeCreate( COMMUNITY_DIALECT_CONFIG_NAME ) + .setDescription( "Used to define classpath for performing reflection on Dialects for the Community Dialect report" ); + var communityDialectTableTask = project.getTasks().register( "generateCommunityDialectTableReport", DialectReportTask.class, (task) -> { task.dependsOn( indexerTask ); - task.setProperty( "sourceProject", "hibernate-community-dialects" ); - task.setProperty( "sourcePackage", "org.hibernate.community.dialect" ); - task.setProperty( "reportFile", project.getLayout().getBuildDirectory().file( "orm/generated/dialect/dialect-table-community.adoc" ) ); + task.getDialectReportSources().from( communityDialectConfig ); + task.getSourcePackage().set( "org.hibernate.community.dialect" ); + task.getReportFile().set( project.getLayout().getBuildDirectory().file( "orm/generated/dialect/dialect-table-community.adoc" ) ); } ); - final Task groupingTask = project.getTasks().maybeCreate( "generateReports" ); + final var groupingTask = project.getTasks().maybeCreate( "generateReports" ); groupingTask.setGroup( TASK_GROUP_NAME ); groupingTask.dependsOn( indexerTask ); groupingTask.dependsOn( incubatingTask ); diff --git a/release/release.gradle b/release/release.gradle index c439f01ecfc5..4a2a52ae48ce 100644 --- a/release/release.gradle +++ b/release/release.gradle @@ -20,7 +20,7 @@ idea.module { // skip building this when `build` task is run from root, as many of our CI jobs do tasks.build.dependsOn.clear() -tasks.build.enabled false +tasks.build.enabled = false // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -42,8 +42,8 @@ tasks.build.enabled false // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def releaseChecksTask = tasks.register( "releaseChecks" ) { - group 'release-prepare' - description 'Checks and preparation for release' + group = 'release-prepare' + description = 'Checks and preparation for release' doFirst { logger.lifecycle("Checking that the working tree is clean...") @@ -99,8 +99,8 @@ def releaseChecksTask = tasks.register( "releaseChecks" ) { } def changeLogFileTask = tasks.register( "changeLogFile" ) { - group 'release-prepare' - description 'Updates the changelog.txt file based on the change-log report from Jira' + group = 'release-prepare' + description = 'Updates the changelog.txt file based on the change-log report from Jira' dependsOn releaseChecksTask doFirst { @@ -110,8 +110,8 @@ def changeLogFileTask = tasks.register( "changeLogFile" ) { } def changeToReleaseVersionTask = tasks.register( "changeToReleaseVersion" ) { - group 'release-prepare' - description 'Updates `gradle/version.properties` file to the specified release-version' + group = 'release-prepare' + description = 'Updates `gradle/version.properties` file to the specified release-version' dependsOn releaseChecksTask @@ -123,8 +123,8 @@ def changeToReleaseVersionTask = tasks.register( "changeToReleaseVersion" ) { } def gitPreStepsTask = tasks.register( 'gitPreSteps' ) { - group "release-prepare" - description "update changelog, update version file and commit" + group = "release-prepare" + description = "update changelog, update version file and commit" dependsOn releaseChecksTask dependsOn changeLogFileTask @@ -139,8 +139,8 @@ def gitPreStepsTask = tasks.register( 'gitPreSteps' ) { } def gitPostStepsTask = tasks.register( 'gitPostSteps' ) { - group "release-prepare" - description "possibly create tag. update version-file and commit " + group = "release-prepare" + description = "possibly create tag. update version-file and commit " doFirst { } @@ -170,8 +170,8 @@ void updateVersionFile(String version) { } tasks.register("releasePrepare") { - group "release-prepare" - description "Scripted release 'Release Prepare' stage" + group = "release-prepare" + description = "Scripted release 'Release Prepare' stage" dependsOn releaseChecksTask dependsOn "assembleDocumentation" @@ -185,8 +185,8 @@ tasks.register("releasePrepare") { // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def stageIntegrationGuideTask = tasks.register( "stageIntegrationGuide", Copy ) { - group "documentation" - description "Stages the Integration Guide as part of assembling documentation in preparation for release" + group = "documentation" + description = "Stages the Integration Guide as part of assembling documentation in preparation for release" dependsOn ":documentation:renderIntegrationGuides" @@ -195,8 +195,8 @@ def stageIntegrationGuideTask = tasks.register( "stageIntegrationGuide", Copy ) } def stageQuickstartTask = tasks.register( "stageQuickstart", Copy ) { - group 'documentation' - description "Stages the Getting Started Guide as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the Getting Started Guide as part of assembling documentation in preparation for release" dependsOn ':documentation:renderGettingStartedGuides' @@ -205,8 +205,8 @@ def stageQuickstartTask = tasks.register( "stageQuickstart", Copy ) { } def stageTopicalGuideTask = tasks.register( "stageTopicalGuide", Copy ) { - group 'documentation' - description "Stages the Topical Guide as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the Topical Guide as part of assembling documentation in preparation for release" dependsOn ':documentation:renderTopicalGuides' @@ -215,8 +215,8 @@ def stageTopicalGuideTask = tasks.register( "stageTopicalGuide", Copy ) { } def stageIntroductionGuideTask = tasks.register( "stageIntroductionGuide", Copy ) { - group 'documentation' - description "Stages the Introduction Guide as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the Introduction Guide as part of assembling documentation in preparation for release" dependsOn ':documentation:renderIntroductionGuides' @@ -225,8 +225,8 @@ def stageIntroductionGuideTask = tasks.register( "stageIntroductionGuide", Copy } def stageQueryGuideTask = tasks.register( "stageQueryGuide", Copy ) { - group 'documentation' - description "Stages the Query Language Guide as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the Query Language Guide as part of assembling documentation in preparation for release" dependsOn ':documentation:renderQueryLanguageGuides' @@ -235,8 +235,8 @@ def stageQueryGuideTask = tasks.register( "stageQueryGuide", Copy ) { } def stageRepositoriesGuideTask = tasks.register( "stageRepositoriesGuide", Copy ) { - group 'documentation' - description "Stages the Repositories Guide as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the Repositories Guide as part of assembling documentation in preparation for release" dependsOn ':documentation:renderRepositories' @@ -245,8 +245,8 @@ def stageRepositoriesGuideTask = tasks.register( "stageRepositoriesGuide", Copy } def stageUserGuideTask = tasks.register( "stageUserGuide", Copy ) { - group 'documentation' - description "Stages the User Guide as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the User Guide as part of assembling documentation in preparation for release" dependsOn ':documentation:renderUserGuides' @@ -256,8 +256,8 @@ def stageUserGuideTask = tasks.register( "stageUserGuide", Copy ) { def stageMigrationGuideTask = tasks.register( "stageMigrationGuide", Copy ) { - group 'documentation' - description "Stages the Migration Guide as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the Migration Guide as part of assembling documentation in preparation for release" dependsOn ':documentation:renderMigrationGuide' @@ -266,8 +266,8 @@ def stageMigrationGuideTask = tasks.register( "stageMigrationGuide", Copy ) { } def stageWhatsNewGuideTask = tasks.register( "stageWhatsNewGuide", Copy ) { - group 'documentation' - description "Stages the What's New guide as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the What's New guide as part of assembling documentation in preparation for release" dependsOn ':documentation:renderWhatsNew' @@ -276,8 +276,8 @@ def stageWhatsNewGuideTask = tasks.register( "stageWhatsNewGuide", Copy ) { } def stageIncubationReportTask = tasks.register( "stageIncubationReport", Copy ) { task -> - group 'documentation' - description "Stages ORM @Incubating report as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages ORM @Incubating report as part of assembling documentation in preparation for release" dependsOn ':documentation:generateIncubationReport' tasks.stageOrmReports.dependsOn task @@ -287,8 +287,8 @@ def stageIncubationReportTask = tasks.register( "stageIncubationReport", Copy ) } def stageInternalsReportTask = tasks.register( "stageInternalsReport", Copy ) { task -> - group 'documentation' - description "Stages the @Internal report as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the @Internal report as part of assembling documentation in preparation for release" dependsOn ':documentation:generateInternalsReport' @@ -297,8 +297,8 @@ def stageInternalsReportTask = tasks.register( "stageInternalsReport", Copy ) { } def stageDeprecationReportTask = tasks.register( "stageDeprecationReport", Copy ) { - group 'documentation' - description "Stages the @Deprecated/@Remove report as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the @Deprecated/@Remove report as part of assembling documentation in preparation for release" dependsOn ':documentation:generateDeprecationReport' @@ -307,8 +307,8 @@ def stageDeprecationReportTask = tasks.register( "stageDeprecationReport", Copy } def stageLoggingReportTask = tasks.register( "stageLoggingReport", Copy ) { task -> - group 'documentation' - description "Stages the logging report as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the logging report as part of assembling documentation in preparation for release" dependsOn ':documentation:renderLoggingReport' @@ -317,8 +317,8 @@ def stageLoggingReportTask = tasks.register( "stageLoggingReport", Copy ) { task } def stageDialectReportTask = tasks.register( "stageDialectReport", Copy ) { task -> - group 'documentation' - description "Stages the supported Dialects report as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the supported Dialects report as part of assembling documentation in preparation for release" dependsOn ':documentation:renderDialectReport' @@ -327,8 +327,8 @@ def stageDialectReportTask = tasks.register( "stageDialectReport", Copy ) { task } def stageOrmReportsTask = tasks.register( "stageOrmReports" ) { - group 'documentation' - description "Stages all ORM reports as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages all ORM reports as part of assembling documentation in preparation for release" dependsOn ':documentation:generateReports' dependsOn stageIncubationReportTask @@ -339,8 +339,8 @@ def stageOrmReportsTask = tasks.register( "stageOrmReports" ) { } def stageJavadocsTask = tasks.register( "stageJavadocs", Copy ) { - group 'documentation' - description "Stages the aggregated Javadocs as part of assembling documentation in preparation for release" + group = 'documentation' + description = "Stages the aggregated Javadocs as part of assembling documentation in preparation for release" dependsOn ':documentation:javadoc' @@ -354,8 +354,8 @@ def stageJavadocsTask = tasks.register( "stageJavadocs", Copy ) { * Depends on building the docs */ def assembleDocumentationTask = tasks.register( "assembleDocumentation" ) { - group 'documentation' - description 'Assembles all documentation into the {buildDir}/documentation directory' + group = 'documentation' + description = 'Assembles all documentation into the {buildDir}/documentation directory' dependsOn ':documentation:buildDocsForPublishing' dependsOn stageJavadocsTask @@ -387,7 +387,7 @@ def assembleDocumentationTask = tasks.register( "assembleDocumentation" ) { tasks.register( 'releasePerform' ) { group = "release-perform" - description "Scripted release 'Release Perform' stage" + description = "Scripted release 'Release Perform' stage" doFirst { if ( ormBuildDetails.releaseDetails.shouldCreateTag() ) { diff --git a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle index 905961b4fe0f..695ec82f7440 100644 --- a/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle +++ b/tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle @@ -11,7 +11,7 @@ plugins { id "local.javadoc" id "local.code-quality" - id 'com.gradle.plugin-publish' version '1.2.1' + id 'com.gradle.plugin-publish' version '2.0.0' // for local publishing id 'maven-publish' } @@ -63,6 +63,7 @@ test { if ( project.hasProperty( 'excludeTests' ) ) { exclude project.property( 'excludeTests' ) as String } + systemProperty("orm.gradle.min", project.property("orm.gradle.min")) jvmArgs("--add-opens", "java.base/java.lang.invoke=ALL-UNNAMED", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.base/java.util.concurrent.atomic=ALL-UNNAMED") @@ -153,8 +154,8 @@ else { } } -tasks.publish.enabled !ormBuildDetails.hibernateVersion.isSnapshot -tasks.publishPlugins.enabled !ormBuildDetails.hibernateVersion.isSnapshot +tasks.publish.enabled = !ormBuildDetails.hibernateVersion.isSnapshot +tasks.publishPlugins.enabled = !ormBuildDetails.hibernateVersion.isSnapshot gradle.taskGraph.whenReady { tg -> // local publishing (SNAPSHOT testing), cont. diff --git a/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/HbmTransformerTests.java b/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/HbmTransformerTests.java index 60c3704de013..a1d8801f4bcd 100644 --- a/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/HbmTransformerTests.java +++ b/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/HbmTransformerTests.java @@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.gradle.testkit.runner.TaskOutcome.SUCCESS; +import static org.hibernate.orm.tooling.gradle.TestHelper.usingGradleRunner; /** @@ -33,12 +34,9 @@ void testSimpleTransformation(@TempDir Path projectDir) throws IOException { Copier.copyProject( buildFilePath, projectDir ); System.out.println( "Starting execution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ); - final GradleRunner gradleRunner = GradleRunner.create() + final GradleRunner gradleRunner = usingGradleRunner() .withProjectDir( projectDir.toFile() ) - .withPluginClasspath() - .withDebug( true ) - .withArguments( "clean", "hbmTransform", "--stacktrace", "--no-build-cache", "--configuration-cache" ) - .forwardOutput(); + .withArguments( "clean", "hbmTransform", "--stacktrace", "--no-build-cache", "--configuration-cache" ); final BuildResult result = gradleRunner.build(); final BuildTask transformationResult = result.task( ":hbmTransform" ); diff --git a/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/TestHelper.java b/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/TestHelper.java index bac8ffe2f965..46244b89999a 100644 --- a/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/TestHelper.java +++ b/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/TestHelper.java @@ -4,6 +4,7 @@ */ package org.hibernate.orm.tooling.gradle; +import org.gradle.testkit.runner.GradleRunner; import org.hibernate.engine.spi.Managed; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @@ -12,6 +13,30 @@ * @author Steve Ebersole */ public class TestHelper { + public static final String MINIMUM_GRADLE_VERSION; + + static { + // running from IDE breaks in a number of ways. one way to tell here + // that we are running in the IDE is that this system property will + // not be set. + // + // To be clear, the problem is not the version - we could hack that here. + // The problem is actually that the --add-opens applied in the build + // script do not get applied. + MINIMUM_GRADLE_VERSION = System.getProperty( "orm.gradle.min" ); + if ( MINIMUM_GRADLE_VERSION == null ) { + throw new IllegalStateException( "Gradle plugin tests cannot be run from IDE" ); + } + System.out.printf( "Testing ORM Gradle plugin using Gradle version %s\n", MINIMUM_GRADLE_VERSION ); + } + + public static GradleRunner usingGradleRunner() { + return GradleRunner.create() + .withGradleVersion( MINIMUM_GRADLE_VERSION ) + .withPluginClasspath() + .withDebug( true ) + .forwardOutput(); + } public static void verifyEnhanced(ClassLoader classLoader, String className) throws Exception { final Class loadedClass = classLoader.loadClass( className ); diff --git a/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/TestsBase.java b/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/TestsBase.java index ac7e0c187127..2e36ceec8f4a 100644 --- a/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/TestsBase.java +++ b/tooling/hibernate-gradle-plugin/src/test/java/org/hibernate/orm/tooling/gradle/TestsBase.java @@ -35,12 +35,9 @@ public void testEnhancement(Path projectDir) throws Exception { Copier.copyProject( buildFilePath, projectDir ); System.out.println( "Starting execution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ); - final GradleRunner gradleRunner = GradleRunner.create() + final GradleRunner gradleRunner = TestHelper.usingGradleRunner() .withProjectDir( projectDir.toFile() ) - .withPluginClasspath() - .withDebug( true ) - .withArguments( compileTaskName, "--stacktrace", "--no-build-cache", "--configuration-cache" ) - .forwardOutput(); + .withArguments( compileTaskName, "--stacktrace", "--no-build-cache", "--configuration-cache" ); final BuildResult result = gradleRunner.build(); final BuildTask task = result.task( ":" + compileTaskName ); @@ -65,12 +62,9 @@ public void testEnhancementUpToDate(Path projectDir) throws Exception { { System.out.println( "Starting first execution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ); - final GradleRunner gradleRunner = GradleRunner.create() + final GradleRunner gradleRunner = TestHelper.usingGradleRunner() .withProjectDir( projectDir.toFile() ) - .withPluginClasspath() - .withDebug( true ) - .withArguments( compileTaskName, "--stacktrace", "--no-build-cache", "--configuration-cache" ) - .forwardOutput(); + .withArguments( compileTaskName, "--stacktrace", "--no-build-cache", "--configuration-cache" ); final BuildResult result = gradleRunner.build(); final BuildTask task = result.task( ":" + compileTaskName ); @@ -84,12 +78,9 @@ public void testEnhancementUpToDate(Path projectDir) throws Exception { { System.out.println( "Starting second execution ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ); - final GradleRunner gradleRunner = GradleRunner.create() + final GradleRunner gradleRunner = TestHelper.usingGradleRunner() .withProjectDir( projectDir.toFile() ) - .withPluginClasspath() - .withDebug( true ) - .withArguments( compileTaskName, "--stacktrace", "--no-build-cache", "--configuration-cache" ) - .forwardOutput(); + .withArguments( compileTaskName, "--stacktrace", "--no-build-cache", "--configuration-cache" ); final BuildResult result = gradleRunner.build(); final BuildTask task = result.task( ":" + compileTaskName ); assertThat( task ).isNotNull(); 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 e35a870422af..b2ff4c9bad0f 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 @@ -5,7 +5,7 @@ plugins { //NOTE : kotlin version updated for configuration cache support - id 'org.jetbrains.kotlin.jvm' version '1.8.20' + id 'org.jetbrains.kotlin.jvm' version '2.0.20' id 'org.hibernate.orm' }