diff --git a/README.md b/README.md index 5ef3229..109f4c3 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ To use the plugin, include the following snippet on top of your build script: ```kotlin plugins { - id("de.espirit.firstspirit-module") version "6.0.0" + id("de.espirit.firstspirit-module") version "6.1.0" } ``` @@ -105,7 +105,7 @@ To use the plugin, include the following snippet on top of your build script: ```kotlin plugins { - id("de.espirit.firstspirit-module-annotations") version "6.0.0" + id("de.espirit.firstspirit-module-annotations") version "6.1.0" } ``` @@ -117,7 +117,7 @@ Please take a loot at (#dependency-management) for a detailed description of the ```kotlin plugins { - id("de.espirit.firstspirit-module-configurations") version "6.0.0" + id("de.espirit.firstspirit-module-configurations") version "6.1.0" } ``` @@ -447,10 +447,14 @@ fsModuleCompile | Same as the usual `implementation` configuration, but the depe fsWebCompile | Same as the usual `implementation` configuration, but the dependency and all transitive dependencies are added to the web-resources tag in the module-isolated.xml Dependencies with other scopes than these (for example the regular compile scope) are not treated as a resource to be used for module-isolated.xml file generation. -That means if you use compile scope, you can compile your source files against it like in any other project, but the resource won't be listed in the module-isolated.xml. - +That means if you use compile scope, you can compile your source files against it like in any other project, but the resource won't be listed in the module-isolated.xml +or included in the `lib` directory. -In a multi-project build make sure to only use the dependency configurations in the project that assembles the fsm. The dependencies of other subprojects should be defined without using the plugin dependency configurations. The resource entries of these dependencies are created depending on how the respective subproject is referenced from the project executing the assembleFSM task. +In a multi-project build make sure to only use the dependency configurations in the project that assembles the fsm. The dependencies of other subprojects should be defined without using the plugin dependency configurations. The resource entries of these dependencies are created depending on how the respective subproject is referenced from the project executing the assembleFSM task. + +Local Jars which are part of the project directory will not be included when they are defined with one of the three +scopes above because FirstSpirit requires the artifact metadata (like group-id and version) to detect conflicts +between different modules. ### Example @@ -566,7 +570,7 @@ You can use the following snippet as a starting point: // Groovy plugins { - id 'de.espirit.firstspirit-module' version '6.0.0' + id 'de.espirit.firstspirit-module' version '6.1.0' } description = 'Example FSM Gradle build' @@ -601,7 +605,7 @@ firstSpiritModule { // Kotlin plugins { - id("de.espirit.firstspirit-module") version "6.0.0" + id("de.espirit.firstspirit-module") version "6.1.0" } description = "Example FSM Gradle build" diff --git a/UPGRADE.md b/UPGRADE.md index d49d973..e9aa023 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,20 @@ +# Upgrading from 6.0.0 to 6.1.0 + +* Dependencies not defined using fs-configurations like `fsModuleCompile` will no longer be placed in the `lib` +directory. This results in smaller FSM files without any side effects since those files were not visible to the +classloader anyway. +* If a project specifies multiple versions of the same library, this will now result in a build error pointing out that +only a single version is going to be included in the FSM. In case your build fails with an error message like below, +please check the dependency tree of your project to ensure consistent versions. + +``` +* What went wrong: +Execution failed for task ':validateDescriptor'. +> File 'lib/commons-io-2.10.0.jar' specified for resource 'commons-io:commons-io' in component of + type 'web-app' with name 'custom-webapp' but is not found in the FSM. However, the different + version 'lib/commons-io-2.7.jar' was found. Please check your project for inconsistent dependency versions. +``` + # Upgrading from 5.x.x to 6.0.0 * When packaging an FSM file, only `fsm-resources` of the current project and its dependencies will be included. diff --git a/build.gradle.kts b/build.gradle.kts index b8dfcd6..7667a73 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ import java.nio.file.Files import java.util.* plugins { - kotlin("jvm") version "1.9.0" + kotlin("jvm") version "1.9.20" id("maven-publish") id("idea") id("java-gradle-plugin") @@ -66,21 +66,21 @@ val fsRuntimeVersion = "5.2.230909" // FirstSpirit 2023-09 dependencies { implementation(gradleApi()) - implementation("io.github.classgraph:classgraph:4.8.154") + implementation("io.github.classgraph:classgraph:4.8.165") implementation("com.github.jk1:gradle-license-report:2.3") - implementation("org.redundent:kotlin-xml-builder:1.9.0") - implementation("org.json:json:20230618") - implementation("org.apache.maven:maven-artifact:3.9.4") - implementation("org.apache.httpcomponents.client5:httpclient5:5.2.1") + implementation("org.redundent:kotlin-xml-builder:1.9.1") + implementation("org.json:json:20231013") + implementation("org.apache.maven:maven-artifact:3.9.6") + implementation("org.apache.httpcomponents.client5:httpclient5:5.3") implementation("com.espirit.moddev.components:annotations:${fsmAnnotationsVersion}") implementation("de.espirit.firstspirit:fs-isolated-runtime:${fsRuntimeVersion}") testImplementation("de.espirit.firstspirit:fs-isolated-runtime:${fsRuntimeVersion}") - testImplementation(platform("org.junit:junit-bom:5.10.0")) + testImplementation(platform("org.junit:junit-bom:5.10.1")) testImplementation("org.junit.jupiter:junit-jupiter") testRuntimeOnly("org.junit.platform:junit-platform-launcher") - testImplementation("org.assertj:assertj-core:3.24.2") - testImplementation("org.mockito:mockito-junit-jupiter:5.5.0") - testImplementation("org.ow2.asm:asm:9.5") + testImplementation("org.assertj:assertj-core:3.25.1") + testImplementation("org.mockito:mockito-junit-jupiter:5.9.0") + testImplementation("org.ow2.asm:asm:9.6") testImplementation(gradleTestKit()) } diff --git a/gradle.properties b/gradle.properties index 3606d76..065eaba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ #Thu Dec 10 08:28:02 CET 2020 -version=6.0.1-SNAPSHOT +version=6.1.0-SNAPSHOT jira.versionPrefix=FSMGP jira.excludeFromBundleVersion=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7f93135..d64cd49 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 bb5fde6..38a57bd 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\://artifactory.e-spirit.de/artifactory/gradle-distributions/gradle-8.3-all.zip +distributionUrl=https\://artifactory.e-spirit.de/artifactory/gradle-distributions/gradle-8.6-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 0adc8e1..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -202,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..25da30d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,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,11 +57,11 @@ 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 diff --git a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/Components.kt b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/Components.kt index 3cf6edb..08c62ca 100644 --- a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/Components.kt +++ b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/Components.kt @@ -23,16 +23,16 @@ class Components(private val project: Project, private val scanResult: Component init { node = xml("components") { - components(PublicComponent::class, ::nodesForPublicComponent, scanResult).forEach(this::addNode) - components(ScheduleTaskComponent::class, ::nodesForScheduleTaskComponent, scanResult).forEach(this::addNode) - components(GadgetComponent::class, ::nodesForGadgetComponent, scanResult).forEach(this::addNode) - components(UrlFactoryComponent::class, ::nodesForUrlFactoryComponent, scanResult).forEach(this::addNode) - components(ServiceComponent::class, ::nodesForServiceComponent, scanResult).forEach(this::addNode) - ProjectAppComponents(project, scanResult).nodes.forEach(this::addNode) - LibraryComponents(project).nodes.forEach(this::addNode) + components(PublicComponent::class, ::nodesForPublicComponent, scanResult).forEach(this::addElement) + components(ScheduleTaskComponent::class, ::nodesForScheduleTaskComponent, scanResult).forEach(this::addElement) + components(GadgetComponent::class, ::nodesForGadgetComponent, scanResult).forEach(this::addElement) + components(UrlFactoryComponent::class, ::nodesForUrlFactoryComponent, scanResult).forEach(this::addElement) + components(ServiceComponent::class, ::nodesForServiceComponent, scanResult).forEach(this::addElement) + ProjectAppComponents(project, scanResult).nodes.forEach(this::addElement) + LibraryComponents(project).nodes.forEach(this::addElement) val webAppComponents = WebAppComponents(project, scanResult) - webAppComponents.nodes.forEach(this::addNode) + webAppComponents.nodes.forEach(this::addElement) webXmlPaths = webAppComponents.webXmlPaths } } diff --git a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/GradleExtensions.kt b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/GradleExtensions.kt index b57a96f..9c0a4bc 100644 --- a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/GradleExtensions.kt +++ b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/GradleExtensions.kt @@ -4,6 +4,8 @@ import org.gradle.api.Project import org.gradle.api.artifacts.ResolvedArtifact import org.gradle.api.plugins.JavaPlugin import org.gradle.jvm.tasks.Jar +import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin.Companion.FS_MODULE_COMPILE_CONFIGURATION_NAME +import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin.Companion.FS_SERVER_COMPILE_CONFIGURATION_NAME import java.io.File fun ResolvedArtifact.hasSameModuleAs(other: ResolvedArtifact): Boolean { @@ -17,4 +19,34 @@ fun ResolvedArtifact.hasSameModuleAs(other: ResolvedArtifact): Boolean { fun Project.buildJar(): File { val jarTask = tasks.getByName(JavaPlugin.JAR_TASK_NAME) as Jar return jarTask.archiveFile.get().asFile +} + +/** + * Returns all artifacts defined on the server scope, i.e. with `fsServerCompile` + */ +fun Project.serverScopeDependencies(): Set { + val fsModuleCompileConfiguration = configurations.getByName(FS_MODULE_COMPILE_CONFIGURATION_NAME) + val fsServerCompileConfiguration = configurations.getByName(FS_SERVER_COMPILE_CONFIGURATION_NAME) + + // Remove duplicate resolved resources from module scope + val resolvedModuleScopeArtifacts = fsModuleCompileConfiguration.resolvedConfiguration.resolvedArtifacts + val resolvedServerScopeArtifacts = fsServerCompileConfiguration.resolvedConfiguration.resolvedArtifacts + return resolvedModuleScopeArtifacts.filter { + // Module scope configuration extends server scope configuration, so we need to filter duplicates + moduleScoped -> resolvedServerScopeArtifacts.any { it.hasSameModuleAs(moduleScoped) } + }.toSet() +} + + +/** + * Returns all artifacts on the module scope not superseded by server-scoped dependencies + */ +fun Project.moduleScopeDependencies(): Set { + val fsModuleCompileConfiguration = configurations.getByName(FS_MODULE_COMPILE_CONFIGURATION_NAME) + val resolvedModuleScopeArtifacts = fsModuleCompileConfiguration.resolvedConfiguration.resolvedArtifacts + + // Remove duplicate resolved resources from module scope + val cleanedCompileDependenciesModuleScoped = resolvedModuleScopeArtifacts.toMutableSet() + cleanedCompileDependenciesModuleScoped.removeAll(serverScopeDependencies()) + return cleanedCompileDependenciesModuleScoped } \ No newline at end of file diff --git a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/LibraryComponents.kt b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/LibraryComponents.kt index 51f9d01..6f02a9e 100644 --- a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/LibraryComponents.kt +++ b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/LibraryComponents.kt @@ -41,7 +41,7 @@ class LibraryComponents(project: Project): ComponentsWithResources(project) { LOGGER.warn("Library '${library.name}' does not specify any resources.") } - nodes.forEach(::addNode) + nodes.forEach(::addElement) } } } diff --git a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/ModuleDescriptor.kt b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/ModuleDescriptor.kt index 62fe708..b505076 100644 --- a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/ModuleDescriptor.kt +++ b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/ModuleDescriptor.kt @@ -31,11 +31,11 @@ class ModuleDescriptor(private val project: Project) { version = XmlVersion.V10 moduleInformation(this) "dependencies" { - dependencies.forEach(this::addNode) + dependencies.forEach(this::addElement) } - moduleClass.nodes.forEach(this::addNode) - addNode(componentsNode) - addNode(resources.node) + moduleClass.nodes.forEach(this::addElement) + addElement(componentsNode) + addElement(resources.node) } } } diff --git a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/ProjectAppComponents.kt b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/ProjectAppComponents.kt index 10060c4..cd34b61 100644 --- a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/ProjectAppComponents.kt +++ b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/ProjectAppComponents.kt @@ -40,7 +40,7 @@ class ProjectAppComponents(project: Project, private val scanResult: ComponentSc val resources = nodesForResources(annotation) if (resources.isNotEmpty()) { "resources" { - resources.forEach(this::addNode) + resources.forEach(this::addElement) } } } diff --git a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/Resources.kt b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/Resources.kt index 2598048..91e3025 100644 --- a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/Resources.kt +++ b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/Resources.kt @@ -1,14 +1,11 @@ package org.gradle.plugins.fsm.descriptor -import de.espirit.firstspirit.server.module.ModuleInfo.Mode import org.gradle.api.Project import org.gradle.api.artifacts.ProjectDependency -import org.gradle.api.artifacts.ResolvedArtifact import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin.Companion.FS_MODULE_COMPILE_CONFIGURATION_NAME -import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin.Companion.FS_SERVER_COMPILE_CONFIGURATION_NAME import org.redundent.kotlin.xml.Node import org.redundent.kotlin.xml.PrintOptions import org.redundent.kotlin.xml.xml @@ -19,9 +16,9 @@ class Resources(private val project: Project, private val webXmlPaths: List { val dependencies = mutableListOf() - val configurations = project.configurations - val fsModuleCompileConfiguration = configurations.getByName(FS_MODULE_COMPILE_CONFIGURATION_NAME) - val fsServerCompileConfiguration = configurations.getByName(FS_SERVER_COMPILE_CONFIGURATION_NAME) - val uncleanedDependenciesModuleScoped = fsModuleCompileConfiguration.resolvedConfiguration.resolvedArtifacts - val resolvedServerScopeArtifacts = fsServerCompileConfiguration.resolvedConfiguration.resolvedArtifacts - - val compileDependenciesServerScoped = uncleanedDependenciesModuleScoped.filter { - moduleScoped -> resolvedServerScopeArtifacts.any { it.hasSameModuleAs(moduleScoped) } - }.toMutableSet() - val cleanedCompileDependenciesModuleScoped = uncleanedDependenciesModuleScoped.toMutableSet() - cleanedCompileDependenciesModuleScoped.removeAll(compileDependenciesServerScoped) - - logIgnoredModuleScopeDependencies(uncleanedDependenciesModuleScoped, cleanedCompileDependenciesModuleScoped) - - compileDependenciesServerScoped + project.serverScopeDependencies() .map { Resource(project, it, "server").node } .forEach(dependencies::add) - cleanedCompileDependenciesModuleScoped + project.moduleScopeDependencies() .map { Resource(project, it, "module").node } .forEach(dependencies::add) return dependencies } - private fun logIgnoredModuleScopeDependencies(uncleanedDependenciesModuleScoped: Set, compileDependenciesModuleScoped: Set) { - val ignoredDependenciesModuleScoped = uncleanedDependenciesModuleScoped - compileDependenciesModuleScoped - LOGGER.debug("The following dependencies are found on both module and server scope. The scope will be resolved to server.") - ignoredDependenciesModuleScoped.forEach { - LOGGER.debug(it.toString()) - } - } - companion object { val LOGGER: Logger = Logging.getLogger(Resources::class.java) private val PRINT_OPTIONS = PrintOptions(singleLineTextElements = true) diff --git a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/WebAppComponents.kt b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/WebAppComponents.kt index 2bb67ce..8b6c41c 100644 --- a/src/main/kotlin/org/gradle/plugins/fsm/descriptor/WebAppComponents.kt +++ b/src/main/kotlin/org/gradle/plugins/fsm/descriptor/WebAppComponents.kt @@ -161,8 +161,8 @@ class WebAppComponents(project: Project, private val scanResult: ComponentScan): -"lib/${jarFile.name}" } } - nodesForWebResources(annotation).forEach(this::addNode) - webResources.forEach(this::addNode) + nodesForWebResources(annotation).forEach(this::addElement) + webResources.forEach(this::addElement) } }) } diff --git a/src/main/kotlin/org/gradle/plugins/fsm/tasks/bundling/FSM.kt b/src/main/kotlin/org/gradle/plugins/fsm/tasks/bundling/FSM.kt index a903b90..2da4f24 100644 --- a/src/main/kotlin/org/gradle/plugins/fsm/tasks/bundling/FSM.kt +++ b/src/main/kotlin/org/gradle/plugins/fsm/tasks/bundling/FSM.kt @@ -3,6 +3,7 @@ package org.gradle.plugins.fsm.tasks.bundling import org.gradle.api.Project import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.file.FileCollection +import org.gradle.api.plugins.JavaPlugin import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.Internal import org.gradle.api.tasks.TaskAction @@ -10,8 +11,11 @@ import org.gradle.jvm.tasks.Jar import org.gradle.plugins.fsm.FSMPluginExtension import org.gradle.plugins.fsm.compileDependencies import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin +import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin.Companion.FS_WEB_COMPILE_CONFIGURATION_NAME import org.gradle.plugins.fsm.descriptor.LibraryComponents import org.gradle.plugins.fsm.descriptor.ModuleDescriptor +import org.gradle.plugins.fsm.descriptor.moduleScopeDependencies +import org.gradle.plugins.fsm.descriptor.serverScopeDependencies import java.io.File import java.nio.charset.StandardCharsets import java.nio.file.FileSystem @@ -51,7 +55,18 @@ abstract class FSM: Jar() { fun lazyConfiguration() { into("lib") { lib -> - classpath.filter { file -> file.isFile }.forEach { lib.from(it) } + project.serverScopeDependencies().forEach { lib.from(it.file) } + project.moduleScopeDependencies().forEach { lib.from(it.file) } + project.configurations.getByName(FS_WEB_COMPILE_CONFIGURATION_NAME).resolve().forEach { lib.from(it) } + lib.from(project.tasks.named(JavaPlugin.JAR_TASK_NAME)) + pluginExtension.getWebApps().values + .map { project -> project.configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME) } + .forEach { lib.from(it) } + pluginExtension.getWebApps().values + .map { project -> project.tasks.named(JavaPlugin.JAR_TASK_NAME) } + .filter { task -> task.isPresent } + .map { task -> task.map { it.outputs.files.singleFile } } + .forEach { jarFile -> lib.from(jarFile) } pluginExtension.libraries .asSequence().map { it.configuration }.filterNotNull() .flatMap { LibraryComponents.getResolvedDependencies(project, it) } diff --git a/src/main/kotlin/org/gradle/plugins/fsm/tasks/verification/ValidateDescriptor.kt b/src/main/kotlin/org/gradle/plugins/fsm/tasks/verification/ValidateDescriptor.kt index 017973f..7777671 100644 --- a/src/main/kotlin/org/gradle/plugins/fsm/tasks/verification/ValidateDescriptor.kt +++ b/src/main/kotlin/org/gradle/plugins/fsm/tasks/verification/ValidateDescriptor.kt @@ -177,8 +177,12 @@ abstract class ValidateDescriptor: DefaultTask() { val filename = resource.textContent() if (!files.contains(filename) && !files.contains("$filename/")) { + val similarFile = findSimilarFile(files, filename) + val similarMessage = similarFile?.let { " However, the different version '$it' was found. " + + "Please check your project for inconsistent dependency versions." } ?: "" + throw GradleException("File '$filename' specified for resource '$resourceName' in" + - " $source but is not found in the FSM.") + " $source but is not found in the FSM.$similarMessage") } } } @@ -203,6 +207,20 @@ abstract class ValidateDescriptor: DefaultTask() { return "" } + private fun findSimilarFile(files: List, filename: String): String? { + val versionNumber = Regex("\\d\\.") + if (!filename.contains(versionNumber)) { + return null + } + + var filenameWithoutVersion = filename + while (filenameWithoutVersion.contains("-") && filenameWithoutVersion.contains(versionNumber)) { + filenameWithoutVersion = filenameWithoutVersion.substringBeforeLast("-") + } + + return files.first { it.startsWith(filenameWithoutVersion) } + } + companion object { const val NAME_ALLOWED_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789; ,_-" } diff --git a/src/test/kotlin/org/gradle/plugins/fsm/descriptor/ResourcesTest.kt b/src/test/kotlin/org/gradle/plugins/fsm/descriptor/ResourcesTest.kt index 381825e..34f4736 100644 --- a/src/test/kotlin/org/gradle/plugins/fsm/descriptor/ResourcesTest.kt +++ b/src/test/kotlin/org/gradle/plugins/fsm/descriptor/ResourcesTest.kt @@ -1,8 +1,8 @@ package org.gradle.plugins.fsm.descriptor -import de.espirit.firstspirit.server.module.ModuleInfo import org.assertj.core.api.Assertions.assertThat import org.gradle.api.Project +import org.gradle.api.plugins.JavaPlugin import org.gradle.jvm.tasks.Jar import org.gradle.plugins.fsm.FSMPluginExtension import org.gradle.plugins.fsm.annotations.FSMAnnotationsPlugin @@ -12,11 +12,12 @@ import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin.Companion.F import org.gradle.plugins.fsm.configurations.fsDependency import org.gradle.testfixtures.ProjectBuilder import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir import org.redundent.kotlin.xml.Node import org.redundent.kotlin.xml.TextElement import java.nio.file.Files +import java.nio.file.Path class ResourcesTest { @@ -150,7 +151,7 @@ class ResourcesTest { val resource = resources.filter { it.attributes["name"] == "org.slf4j:slf4j-api" }.single() assertThat(resource.attributes["version"]).isEqualTo("1.7.32") assertThat(resource.attributes["minVersion"]).isEqualTo("1.7.32") - assertThat(resource.attributes["mode"]).isEqualTo(ModuleInfo.Mode.ISOLATED.name.lowercase()) + assertThat(resource.attributes["mode"]).isEqualTo("isolated") assertThat(resource.textContent()).isEqualTo("lib/slf4j-api-1.7.32.jar") } @@ -165,7 +166,7 @@ class ResourcesTest { val resource = resources.filter { it.attributes["name"] == "org.slf4j:slf4j-api" }.single() assertThat(resource.attributes["version"]).isEqualTo("1.7.32") assertThat(resource.hasAttribute("minVersion")).isFalse - assertThat(resource.attributes["mode"]).isEqualTo(ModuleInfo.Mode.ISOLATED.name.lowercase()) + assertThat(resource.attributes["mode"]).isEqualTo("isolated") assertThat(resource.textContent()).isEqualTo("lib/slf4j-api-1.7.32.jar") } @@ -181,7 +182,7 @@ class ResourcesTest { assertThat(resource.attributes["version"]).isEqualTo("1.7.32") assertThat(resource.attributes["minVersion"]).isEqualTo("1.7") assertThat(resource.attributes["maxVersion"]).isEqualTo("1.8") - assertThat(resource.attributes["mode"]).isEqualTo(ModuleInfo.Mode.ISOLATED.name.lowercase()) + assertThat(resource.attributes["mode"]).isEqualTo("isolated") assertThat(resource.textContent()).isEqualTo("lib/slf4j-api-1.7.32.jar") } @@ -200,7 +201,7 @@ class ResourcesTest { assertThat(resource.attributes["version"]).isEqualTo("1.7.32") assertThat(resource.attributes["minVersion"]).isEqualTo("1.7") assertThat(resource.attributes["maxVersion"]).isEqualTo("1.8") - assertThat(resource.attributes["mode"]).isEqualTo(ModuleInfo.Mode.ISOLATED.name.lowercase()) + assertThat(resource.attributes["mode"]).isEqualTo("isolated") assertThat(resource.textContent()).isEqualTo("lib/slf4j-api-1.7.32.jar") } @@ -216,6 +217,20 @@ class ResourcesTest { assertThat(resource.textContent()).isEqualTo("lib/fs-api-5.2.221111-javadoc.jar") } + @Test + fun `local jar dependencies`(@TempDir tempDir: Path) { + val localServerJar = Files.createFile(tempDir.resolve("server-lib.jar")) + val localModuleJar = Files.createFile(tempDir.resolve("module-lib-1.0.jar")) + val localImplJar = Files.createFile(tempDir.resolve("lib-1.0.jar")) + project.dependencies.add(FS_SERVER_COMPILE_CONFIGURATION_NAME, project.files(localServerJar)) + project.dependencies.add(FS_MODULE_COMPILE_CONFIGURATION_NAME, project.files(localModuleJar)) + project.dependencies.add(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, project.files(localImplJar)) + + val resources = Resources(project, emptyList()).node + + assertThat(resources.children).hasSize(1) // Contains only project jar resource + } + @Test fun `dependency fsm without classifier`() { val dependency = project.dependencies.create("com.espirit.moddev.basicworkflows:basicworkflows-fsm:1.3.846@fsm") @@ -228,7 +243,6 @@ class ResourcesTest { assertThat(resource.textContent()).isEqualTo("lib/basicworkflows-fsm-1.3.846.fsm") } - @Disabled("DEVEX-497 - Race Condition When Downloading Dependency Twice") @Test fun `resolve scope resource conflict`() { project.dependencies.add(FS_MODULE_COMPILE_CONFIGURATION_NAME, "org.joda:joda-convert:2.1.1") @@ -244,7 +258,6 @@ class ResourcesTest { assertThat(slf4j.attributes["scope"]).isEqualTo("server") } - @Disabled("DEVEX-497 - Race Condition When Downloading Dependency Twice") @Test fun `module scope server scope resolution works correctly`() { // Module and server scope should be resolved together, so the higher version wins, just like normal maven @@ -265,7 +278,6 @@ class ResourcesTest { assertThat(jodaConvert.attributes["version"]).isEqualTo("2.1.1") } - @Disabled("DEVEX-497 - Race Condition When Downloading Dependency Twice") @Test fun `module scope server scope resolution works correctly with server version higher`() { // Module and server scope should be resolved together, so the higher version wins, just like normal maven diff --git a/src/test/kotlin/org/gradle/plugins/fsm/tasks/bundling/FSMTest.kt b/src/test/kotlin/org/gradle/plugins/fsm/tasks/bundling/FSMTest.kt index e1f1a28..b08b6bb 100644 --- a/src/test/kotlin/org/gradle/plugins/fsm/tasks/bundling/FSMTest.kt +++ b/src/test/kotlin/org/gradle/plugins/fsm/tasks/bundling/FSMTest.kt @@ -9,6 +9,7 @@ import org.gradle.plugins.fsm.FSMPlugin import org.gradle.plugins.fsm.FSMPluginExtension import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin.Companion.FS_MODULE_COMPILE_CONFIGURATION_NAME +import org.gradle.plugins.fsm.configurations.FSMConfigurationsPlugin.Companion.FS_SERVER_COMPILE_CONFIGURATION_NAME import org.gradle.plugins.fsm.configurations.MinMaxVersion import org.gradle.plugins.fsm.configurations.fsDependency import org.gradle.plugins.fsm.util.TestProjectUtils.defineArtifactoryForProject @@ -18,8 +19,11 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir import java.io.File import java.nio.file.Files +import java.nio.file.Path import java.nio.file.Paths +import java.util.zip.ZipEntry import java.util.zip.ZipFile +import java.util.zip.ZipOutputStream import kotlin.io.path.writeText class FSMTest { @@ -311,6 +315,68 @@ class FSMTest { } } + @Test + fun `web-app component libraries should be included`() { + project.version = "1.0.0" + + copyTestJar() + + val libProjectDir = testDir.resolve("lib") + libProjectDir.mkdirs() + val libProject = ProjectBuilder.builder().withName("lib").withProjectDir(libProjectDir).withParent(project).build() + libProject.plugins.apply("java") + val libBuildDir = libProjectDir.resolve("build/libs/") + libBuildDir.mkdirs() + libBuildDir.resolve("lib.jar").createNewFile() + + val webProjectDir = testDir.resolve("web") + webProjectDir.mkdirs() + val webProject = ProjectBuilder.builder().withName("web").withProjectDir(webProjectDir).withParent(project).build() + webProject.plugins.apply("java") + webProject.dependencies.add("implementation", project.dependencies.project(mapOf("path" to ":lib"))) + + val fsmPluginExtension = project.extensions.getByType(FSMPluginExtension::class.java) + fsmPluginExtension.webAppComponent("TestWebAppA", webProject) + + fsm.execute() + + assertThat(moduleXml()).contains("""lib/lib.jar""") + + withFsmFile { fsm -> + assertThat(fsm.getEntry("lib/lib.jar")).isNotNull + } + } + + @Test + fun `web-app component jar output should be included`() { + project.version = "1.0.0" + + copyTestJar() + + val webProjectDir = testDir.resolve("web") + webProjectDir.mkdirs() + val webProject = ProjectBuilder.builder().withName("web").withProjectDir(webProjectDir).withParent(project).build() + webProject.plugins.apply("java") + val jarTask = webProject.tasks.getByName(JavaPlugin.JAR_TASK_NAME) + val jarFile = jarTask.outputs.files.toList().single() + Files.createDirectories(jarFile.toPath().parent) + ZipOutputStream(jarFile.outputStream()).use { + it.putNextEntry(ZipEntry("test.txt")) + it.closeEntry() + } + + val fsmPluginExtension = project.extensions.getByType(FSMPluginExtension::class.java) + fsmPluginExtension.webAppComponent("TestWebAppA", webProject) + + fsm.execute() + + assertThat(moduleXml()).contains("""lib/web.jar""") + + withFsmFile { fsm -> + assertThat(fsm.getEntry("lib/web.jar")).isNotNull + } + } + @Test fun testFsmResourceFilesDetectDuplicates() { project.version = "1.0.0" @@ -422,6 +488,28 @@ class FSMTest { } } + + @Test + fun `do not include local jar dependencies`(@TempDir tempDir: Path) { + val localServerJar = Files.createFile(tempDir.resolve("server-lib.jar")) + val localModuleJar = Files.createFile(tempDir.resolve("module-lib-1.0.jar")) + val localImplJar = Files.createFile(tempDir.resolve("lib-1.0.jar")) + project.dependencies.add(FS_SERVER_COMPILE_CONFIGURATION_NAME, project.files(localServerJar)) + project.dependencies.add(FS_MODULE_COMPILE_CONFIGURATION_NAME, project.files(localModuleJar)) + project.dependencies.add(JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME, project.files(localImplJar)) + + fsm.execute() + + assertThat(moduleXml()).contains("") + + withFsmFile { fsm -> + assertThat(fsm.getEntry("lib/server-lib.jar")).isNull() + assertThat(fsm.getEntry("lib/module-lib-1.0.jar")).isNull() + assertThat(fsm.getEntry("lib/lib-1.0.jar")).isNull() + } + } + + private fun copyTestJar() { val testJar = Paths.get(System.getProperty("testJar")) val jar = project.tasks.getByName(JavaPlugin.JAR_TASK_NAME) as Jar diff --git a/src/test/kotlin/org/gradle/plugins/fsm/tasks/verification/ValidateDescriptorTest.kt b/src/test/kotlin/org/gradle/plugins/fsm/tasks/verification/ValidateDescriptorTest.kt index bef68ca..dc4e5ef 100644 --- a/src/test/kotlin/org/gradle/plugins/fsm/tasks/verification/ValidateDescriptorTest.kt +++ b/src/test/kotlin/org/gradle/plugins/fsm/tasks/verification/ValidateDescriptorTest.kt @@ -322,6 +322,35 @@ class ValidateDescriptorTest { } + @Test + fun `different version of web-app resource included`() { + val descriptor = """ + + Test + 1.0 + + + + TestWebApp + + lib/lib-5.0.8.jar + + + + + """.trimIndent() + + val resourcesDir = testDir.resolve("src/main/fsm-resources/lib") + resourcesDir.mkdirs() + resourcesDir.resolve("lib-4.8.2.jar").createNewFile() + + assertThatThrownBy { validate(descriptor) } + .hasMessage(""" + File 'lib/lib-5.0.8.jar' specified for resource 'my.test:lib' in component of type 'web-app' with name 'TestWebApp' but is not found in the FSM. However, the different version 'lib/lib-4.8.2.jar' was found. Please check your project for inconsistent dependency versions. + """.trimIndent()) + } + + @Test fun `web-app resource without file`() { val descriptor = """ diff --git a/test-projects/annotationsplugin-groovy/gradle/wrapper/gradle-wrapper.jar b/test-projects/annotationsplugin-groovy/gradle/wrapper/gradle-wrapper.jar index ccebba7..d64cd49 100644 Binary files a/test-projects/annotationsplugin-groovy/gradle/wrapper/gradle-wrapper.jar and b/test-projects/annotationsplugin-groovy/gradle/wrapper/gradle-wrapper.jar differ diff --git a/test-projects/annotationsplugin-groovy/gradle/wrapper/gradle-wrapper.properties b/test-projects/annotationsplugin-groovy/gradle/wrapper/gradle-wrapper.properties index fc10b60..a80b22c 100644 --- a/test-projects/annotationsplugin-groovy/gradle/wrapper/gradle-wrapper.properties +++ b/test-projects/annotationsplugin-groovy/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-projects/annotationsplugin-groovy/gradlew b/test-projects/annotationsplugin-groovy/gradlew index 79a61d4..1aa94a4 100755 --- a/test-projects/annotationsplugin-groovy/gradlew +++ b/test-projects/annotationsplugin-groovy/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# 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 # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +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, +# 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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/test-projects/annotationsplugin-groovy/gradlew.bat b/test-projects/annotationsplugin-groovy/gradlew.bat index 93e3f59..25da30d 100644 --- a/test-projects/annotationsplugin-groovy/gradlew.bat +++ b/test-projects/annotationsplugin-groovy/gradlew.bat @@ -43,11 +43,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,11 +57,11 @@ 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 diff --git a/test-projects/annotationsplugin-kotlin/gradle/wrapper/gradle-wrapper.jar b/test-projects/annotationsplugin-kotlin/gradle/wrapper/gradle-wrapper.jar index ccebba7..d64cd49 100644 Binary files a/test-projects/annotationsplugin-kotlin/gradle/wrapper/gradle-wrapper.jar and b/test-projects/annotationsplugin-kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/test-projects/annotationsplugin-kotlin/gradle/wrapper/gradle-wrapper.properties b/test-projects/annotationsplugin-kotlin/gradle/wrapper/gradle-wrapper.properties index fc10b60..a80b22c 100644 --- a/test-projects/annotationsplugin-kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/test-projects/annotationsplugin-kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-projects/annotationsplugin-kotlin/gradlew b/test-projects/annotationsplugin-kotlin/gradlew index 79a61d4..1aa94a4 100755 --- a/test-projects/annotationsplugin-kotlin/gradlew +++ b/test-projects/annotationsplugin-kotlin/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# 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 # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +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, +# 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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/test-projects/annotationsplugin-kotlin/gradlew.bat b/test-projects/annotationsplugin-kotlin/gradlew.bat index 93e3f59..25da30d 100644 --- a/test-projects/annotationsplugin-kotlin/gradlew.bat +++ b/test-projects/annotationsplugin-kotlin/gradlew.bat @@ -43,11 +43,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,11 +57,11 @@ 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 diff --git a/test-projects/configurationsplugin-groovy/gradle/wrapper/gradle-wrapper.jar b/test-projects/configurationsplugin-groovy/gradle/wrapper/gradle-wrapper.jar index ccebba7..d64cd49 100644 Binary files a/test-projects/configurationsplugin-groovy/gradle/wrapper/gradle-wrapper.jar and b/test-projects/configurationsplugin-groovy/gradle/wrapper/gradle-wrapper.jar differ diff --git a/test-projects/configurationsplugin-groovy/gradle/wrapper/gradle-wrapper.properties b/test-projects/configurationsplugin-groovy/gradle/wrapper/gradle-wrapper.properties index fc10b60..a80b22c 100644 --- a/test-projects/configurationsplugin-groovy/gradle/wrapper/gradle-wrapper.properties +++ b/test-projects/configurationsplugin-groovy/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-projects/configurationsplugin-groovy/gradlew b/test-projects/configurationsplugin-groovy/gradlew index 79a61d4..1aa94a4 100755 --- a/test-projects/configurationsplugin-groovy/gradlew +++ b/test-projects/configurationsplugin-groovy/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# 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 # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +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, +# 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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/test-projects/configurationsplugin-groovy/gradlew.bat b/test-projects/configurationsplugin-groovy/gradlew.bat index 93e3f59..25da30d 100644 --- a/test-projects/configurationsplugin-groovy/gradlew.bat +++ b/test-projects/configurationsplugin-groovy/gradlew.bat @@ -43,11 +43,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,11 +57,11 @@ 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 diff --git a/test-projects/configurationsplugin-kotlin/gradle/wrapper/gradle-wrapper.jar b/test-projects/configurationsplugin-kotlin/gradle/wrapper/gradle-wrapper.jar index ccebba7..d64cd49 100644 Binary files a/test-projects/configurationsplugin-kotlin/gradle/wrapper/gradle-wrapper.jar and b/test-projects/configurationsplugin-kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/test-projects/configurationsplugin-kotlin/gradle/wrapper/gradle-wrapper.properties b/test-projects/configurationsplugin-kotlin/gradle/wrapper/gradle-wrapper.properties index fc10b60..a80b22c 100644 --- a/test-projects/configurationsplugin-kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/test-projects/configurationsplugin-kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-projects/configurationsplugin-kotlin/gradlew b/test-projects/configurationsplugin-kotlin/gradlew index 79a61d4..1aa94a4 100755 --- a/test-projects/configurationsplugin-kotlin/gradlew +++ b/test-projects/configurationsplugin-kotlin/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# 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 # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +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, +# 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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/test-projects/configurationsplugin-kotlin/gradlew.bat b/test-projects/configurationsplugin-kotlin/gradlew.bat index 93e3f59..25da30d 100644 --- a/test-projects/configurationsplugin-kotlin/gradlew.bat +++ b/test-projects/configurationsplugin-kotlin/gradlew.bat @@ -43,11 +43,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,11 +57,11 @@ 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 diff --git a/test-projects/fsmplugin-groovy/gradle/wrapper/gradle-wrapper.jar b/test-projects/fsmplugin-groovy/gradle/wrapper/gradle-wrapper.jar index ccebba7..d64cd49 100644 Binary files a/test-projects/fsmplugin-groovy/gradle/wrapper/gradle-wrapper.jar and b/test-projects/fsmplugin-groovy/gradle/wrapper/gradle-wrapper.jar differ diff --git a/test-projects/fsmplugin-groovy/gradle/wrapper/gradle-wrapper.properties b/test-projects/fsmplugin-groovy/gradle/wrapper/gradle-wrapper.properties index fc10b60..a80b22c 100644 --- a/test-projects/fsmplugin-groovy/gradle/wrapper/gradle-wrapper.properties +++ b/test-projects/fsmplugin-groovy/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-projects/fsmplugin-groovy/gradlew b/test-projects/fsmplugin-groovy/gradlew index 79a61d4..1aa94a4 100755 --- a/test-projects/fsmplugin-groovy/gradlew +++ b/test-projects/fsmplugin-groovy/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# 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 # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +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, +# 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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/test-projects/fsmplugin-groovy/gradlew.bat b/test-projects/fsmplugin-groovy/gradlew.bat index 93e3f59..25da30d 100644 --- a/test-projects/fsmplugin-groovy/gradlew.bat +++ b/test-projects/fsmplugin-groovy/gradlew.bat @@ -43,11 +43,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,11 +57,11 @@ 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 diff --git a/test-projects/fsmplugin-kotlin/gradle/wrapper/gradle-wrapper.jar b/test-projects/fsmplugin-kotlin/gradle/wrapper/gradle-wrapper.jar index ccebba7..d64cd49 100644 Binary files a/test-projects/fsmplugin-kotlin/gradle/wrapper/gradle-wrapper.jar and b/test-projects/fsmplugin-kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/test-projects/fsmplugin-kotlin/gradle/wrapper/gradle-wrapper.properties b/test-projects/fsmplugin-kotlin/gradle/wrapper/gradle-wrapper.properties index fc10b60..a80b22c 100644 --- a/test-projects/fsmplugin-kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/test-projects/fsmplugin-kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-projects/fsmplugin-kotlin/gradlew b/test-projects/fsmplugin-kotlin/gradlew index 79a61d4..1aa94a4 100755 --- a/test-projects/fsmplugin-kotlin/gradlew +++ b/test-projects/fsmplugin-kotlin/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# 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 # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +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, +# 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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/test-projects/fsmplugin-kotlin/gradlew.bat b/test-projects/fsmplugin-kotlin/gradlew.bat index 93e3f59..25da30d 100644 --- a/test-projects/fsmplugin-kotlin/gradlew.bat +++ b/test-projects/fsmplugin-kotlin/gradlew.bat @@ -43,11 +43,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,11 +57,11 @@ 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 diff --git a/test-projects/multiple-webapps-groovy/gradle/wrapper/gradle-wrapper.jar b/test-projects/multiple-webapps-groovy/gradle/wrapper/gradle-wrapper.jar index ccebba7..d64cd49 100644 Binary files a/test-projects/multiple-webapps-groovy/gradle/wrapper/gradle-wrapper.jar and b/test-projects/multiple-webapps-groovy/gradle/wrapper/gradle-wrapper.jar differ diff --git a/test-projects/multiple-webapps-groovy/gradle/wrapper/gradle-wrapper.properties b/test-projects/multiple-webapps-groovy/gradle/wrapper/gradle-wrapper.properties index fc10b60..a80b22c 100644 --- a/test-projects/multiple-webapps-groovy/gradle/wrapper/gradle-wrapper.properties +++ b/test-projects/multiple-webapps-groovy/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-projects/multiple-webapps-groovy/gradlew b/test-projects/multiple-webapps-groovy/gradlew index 79a61d4..1aa94a4 100755 --- a/test-projects/multiple-webapps-groovy/gradlew +++ b/test-projects/multiple-webapps-groovy/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# 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 # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +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, +# 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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/test-projects/multiple-webapps-groovy/gradlew.bat b/test-projects/multiple-webapps-groovy/gradlew.bat index 93e3f59..25da30d 100644 --- a/test-projects/multiple-webapps-groovy/gradlew.bat +++ b/test-projects/multiple-webapps-groovy/gradlew.bat @@ -43,11 +43,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,11 +57,11 @@ 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 diff --git a/test-projects/multiple-webapps-kotlin/gradle/wrapper/gradle-wrapper.jar b/test-projects/multiple-webapps-kotlin/gradle/wrapper/gradle-wrapper.jar index ccebba7..d64cd49 100644 Binary files a/test-projects/multiple-webapps-kotlin/gradle/wrapper/gradle-wrapper.jar and b/test-projects/multiple-webapps-kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/test-projects/multiple-webapps-kotlin/gradle/wrapper/gradle-wrapper.properties b/test-projects/multiple-webapps-kotlin/gradle/wrapper/gradle-wrapper.properties index fc10b60..a80b22c 100644 --- a/test-projects/multiple-webapps-kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/test-projects/multiple-webapps-kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-projects/multiple-webapps-kotlin/gradlew b/test-projects/multiple-webapps-kotlin/gradlew index 79a61d4..1aa94a4 100755 --- a/test-projects/multiple-webapps-kotlin/gradlew +++ b/test-projects/multiple-webapps-kotlin/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# 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 # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +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, +# 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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/test-projects/multiple-webapps-kotlin/gradlew.bat b/test-projects/multiple-webapps-kotlin/gradlew.bat index 93e3f59..25da30d 100644 --- a/test-projects/multiple-webapps-kotlin/gradlew.bat +++ b/test-projects/multiple-webapps-kotlin/gradlew.bat @@ -43,11 +43,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,11 +57,11 @@ 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