From db88ec11710c55133b0101ca2cb4e0a506066eae Mon Sep 17 00:00:00 2001 From: v1nc3n4 <5869062+v1nc3n4@users.noreply.github.com> Date: Sun, 9 Jun 2024 14:26:42 +0200 Subject: [PATCH] feat: added task to install a specific version of Corepack Fixes #212 --- .github/workflows/build.yml | 6 +- CONTRIBUTING.md | 4 +- README.md | 1 + .../frontend/build.gradle.kts | 2 +- .../node-subproject/build.gradle.kts | 2 +- examples/npm-application/build.gradle.kts | 2 +- examples/pnpm-application/build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- plugin/build.gradle.kts | 110 ++++----- .../gradle/MultiProjectsFuncTest.java | 171 -------------- ...esWithDownloadedDistributionsFuncTest.java | 212 ------------------ .../gradle/AssembleFrontedTaskFuncTest.java | 32 +-- .../AuthenticationAndProxyFuncTest.java | 54 +++-- .../gradle/CheckFrontendTaskFuncTest.java | 32 +-- .../gradle/CleanFrontendTaskFuncTest.java | 32 +-- .../gradle/InstallCorepackTaskFuncTest.java | 75 +++++++ .../gradle/InstallFrontendTaskFuncTest.java | 24 +- .../gradle/InstallNodeTaskFuncTest.java | 40 ++-- .../InstallPackageManagerTaskFuncTest.java | 26 +-- .../gradle/MultiProjectsFuncTest.java | 151 +++++++++++++ .../gradle/PublishFrontendTaskFuncTest.java | 32 +-- .../ResolvePackageManagerTaskFuncTest.java | 17 +- ...esWithDownloadedDistributionsFuncTest.java | 150 +++++++++++++ ...ypesWithProvidedDistributionsFuncTest.java | 130 ++++++++--- .../test/FrontendMapBuilder.java | 10 + .../test/GradleBuildAssertions.java | 170 ++++++++------ .../test/GradleBuildFiles.java | 0 .../test/GradleHelper.java | 0 .../test/GradleSettingsFiles.java | 0 .../test/PluginTaskOutcome.java | 0 .../test/ServerConfigurator.java | 2 +- .../frontendgradleplugin/test/TaskTypes.java | 19 +- .../resources/SHASUMS256.txt | 2 +- .../resources/node-dist-provided/bin/corepack | 0 .../resources/node-dist-provided/bin/node | 0 .../resources/node-dist-provided/bin/npm | 0 .../resources/node-dist-provided/bin/npx | 0 .../resources/node-dist-provided/bin/pnpm | 0 .../resources/node-dist-provided/bin/pnpx | 0 .../resources/node-dist-provided/bin/yarn | 0 .../resources/node-dist-provided/corepack.cmd | 0 .../resources/node-dist-provided/node.exe | Bin .../resources/node-dist-provided/npm.cmd | 0 .../resources/node-dist-provided/npx.cmd | 0 .../resources/node-dist-provided/pnpm.cmd | 0 .../resources/node-dist-provided/pnpx.cmd | 0 .../resources/node-dist-provided/yarn.cmd | 0 .../node-dist-without-node/bin/corepack | 0 .../resources/node-dist-without-node/bin/npm | 0 .../resources/node-dist-without-node/bin/npx | 0 .../resources/node-dist-without-node/bin/pnpm | 0 .../resources/node-dist-without-node/bin/pnpx | 0 .../resources/node-dist-without-node/bin/yarn | 0 .../node-dist-without-node/corepack.cmd | 0 .../resources/node-dist-without-node/npm.cmd | 0 .../resources/node-dist-without-node/npx.cmd | 0 .../resources/node-dist-without-node/pnpm.cmd | 0 .../resources/node-dist-without-node/pnpx.cmd | 0 .../resources/node-dist-without-node/yarn.cmd | 0 .../resources/node-v20.14.0.zip} | Bin .../resources/package-any-manager.json | 0 .../resources/package-invalid-manager.json | 0 .../resources/package-no-manager.json | 0 .../resources/package-npm.json | 0 .../resources/package-pnpm.json | 0 .../resources/package-yarn.json | 0 .../FrontendGradlePlugin.java | 43 +++- .../domain/GetExecutablePath.java | 20 +- .../domain/installer/HashFile.java | 2 +- .../gradle/AbstractRunCommandTask.java | 5 +- .../gradle/FrontendExtension.java | 8 + .../gradle/InstallCorepackTask.java | 82 +++++++ .../FrontendGradlePluginTest.java | 22 +- ...=> ResolveCorepackExecutablePathTest.java} | 0 ...ava => ResolveNodeExecutablePathTest.java} | 0 ...java => ResolveNpmExecutablePathTest.java} | 0 .../domain/ResolvePackageManagerTest.java | 30 ++- ...ava => ResolvePnpmExecutablePathTest.java} | 0 ...ava => ResolveYarnExecutablePathTest.java} | 0 .../property/corepack-version-property.vue | 27 +++ ...distribution-url-path-pattern-property.vue | 2 +- .../property/node-version-property.vue | 2 +- site/src/components/task/dependency-tree.vue | 22 +- .../components/task/install-corepack-task.vue | 64 ++++++ .../task/install-package-manager-task.vue | 2 +- .../task/run-corepack-task-type.vue | 4 +- .../components/task/task-property-type.vue | 5 + site/src/pages/configuration.vue | 7 +- .../node-corepack-npm-pnpm-yarn-tasks.vue | 1 + site/src/utils/task-property.ts | 5 +- 91 files changed, 1120 insertions(+), 747 deletions(-) delete mode 100644 plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/MultiProjectsFuncTest.java delete mode 100644 plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithDownloadedDistributionsFuncTest.java rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AssembleFrontedTaskFuncTest.java (76%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AuthenticationAndProxyFuncTest.java (79%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CheckFrontendTaskFuncTest.java (74%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CleanFrontendTaskFuncTest.java (74%) create mode 100644 plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallCorepackTaskFuncTest.java rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallFrontendTaskFuncTest.java (79%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallNodeTaskFuncTest.java (67%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallPackageManagerTaskFuncTest.java (81%) create mode 100644 plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/MultiProjectsFuncTest.java rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/PublishFrontendTaskFuncTest.java (77%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/ResolvePackageManagerTaskFuncTest.java (92%) create mode 100644 plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithDownloadedDistributionsFuncTest.java rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithProvidedDistributionsFuncTest.java (56%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/test/FrontendMapBuilder.java (95%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/test/GradleBuildAssertions.java (55%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/test/GradleBuildFiles.java (100%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/test/GradleHelper.java (100%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/test/GradleSettingsFiles.java (100%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/test/PluginTaskOutcome.java (100%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/test/ServerConfigurator.java (98%) rename plugin/src/{intTest => integrationTest}/java/org/siouan/frontendgradleplugin/test/TaskTypes.java (85%) rename plugin/src/{intTest => integrationTest}/resources/SHASUMS256.txt (88%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/bin/corepack (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/bin/node (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/bin/npm (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/bin/npx (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/bin/pnpm (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/bin/pnpx (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/bin/yarn (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/corepack.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/node.exe (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/npm.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/npx.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/pnpm.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/pnpx.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-provided/yarn.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/bin/corepack (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/bin/npm (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/bin/npx (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/bin/pnpm (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/bin/pnpx (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/bin/yarn (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/corepack.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/npm.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/npx.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/pnpm.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/pnpx.cmd (100%) rename plugin/src/{intTest => integrationTest}/resources/node-dist-without-node/yarn.cmd (100%) rename plugin/src/{intTest/resources/node-v18.17.1.zip => integrationTest/resources/node-v20.14.0.zip} (100%) rename plugin/src/{intTest => integrationTest}/resources/package-any-manager.json (100%) rename plugin/src/{intTest => integrationTest}/resources/package-invalid-manager.json (100%) rename plugin/src/{intTest => integrationTest}/resources/package-no-manager.json (100%) rename plugin/src/{intTest => integrationTest}/resources/package-npm.json (100%) rename plugin/src/{intTest => integrationTest}/resources/package-pnpm.json (100%) rename plugin/src/{intTest => integrationTest}/resources/package-yarn.json (100%) create mode 100644 plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallCorepackTask.java rename plugin/src/test/java/org/siouan/frontendgradleplugin/domain/{ResolveGlobalCorepackExecutablePathTest.java => ResolveCorepackExecutablePathTest.java} (100%) rename plugin/src/test/java/org/siouan/frontendgradleplugin/domain/{ResolveGlobalNodeExecutablePathTest.java => ResolveNodeExecutablePathTest.java} (100%) rename plugin/src/test/java/org/siouan/frontendgradleplugin/domain/{ResolveGlobalNpmExecutablePathTest.java => ResolveNpmExecutablePathTest.java} (100%) rename plugin/src/test/java/org/siouan/frontendgradleplugin/domain/{ResolveGlobalPnpmExecutablePathTest.java => ResolvePnpmExecutablePathTest.java} (100%) rename plugin/src/test/java/org/siouan/frontendgradleplugin/domain/{ResolveGlobalYarnExecutablePathTest.java => ResolveYarnExecutablePathTest.java} (100%) create mode 100644 site/src/components/property/corepack-version-property.vue create mode 100644 site/src/components/task/install-corepack-task.vue diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 008eb06c..7c34d0cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, macos-14, windows-2022] + os: [ubuntu-22.04] steps: - name: Init Ubuntu environment @@ -68,7 +68,7 @@ jobs: key: ${{ runner.os }}-sonar-${{ hashFiles('**/*.gradle*') }} - name: Grant executable permission - run: chmod +x gradlew plugin/src/intTest/resources/*/bin/* + run: chmod +x gradlew plugin/src/integrationTest/resources/*/bin/* - name: Build plugin on Linux (with test coverage) if: matrix.os == 'ubuntu-22.04' @@ -89,4 +89,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: ./gradlew :plugin:sonar --console=plain -Dorg.gradle.jvmargs=-Xmx512m -Dsonar.verbose=true + run: ./gradlew :plugin:sonar --console=plain -Dorg.gradle.jvmargs=-Xmx512m diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a484297d..068c7d4d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,8 +113,8 @@ The project relies on [GitHub Actions][github-actions] to integrate continuously repository. The configuration actually allows to build and test the plugin with Adoptium Temurin JDK 17 64 bits, on the environments below: -- Linux Ubuntu 22.04.2 -- Mac OS 12.6.5 +- Linux Ubuntu 22.04.4 +- Mac OS 14.5 - Windows Server 2022 Ubuntu is the reference O/S, used to analyze the source code with SonarCloud. Developments are frequently done on a diff --git a/README.md b/README.md index 56b7be99..58c652e9 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ With their feedback, plugin improvement is possible. Special thanks to: @[joschi](https://github.com/joschi), @[jorgheymans](https://github.com/jorgheymans), @[ludik0](https://github.com/ludik0), +@[marcospereira](https://github.com/marcospereira), @[mhalbritter](https://github.com/mhalbritter), @[mike-howell](https://github.com/mike-howell), @[napstr](https://github.com/napstr), diff --git a/examples/fullstack-war-application/frontend/build.gradle.kts b/examples/fullstack-war-application/frontend/build.gradle.kts index bb27de70..c363b01f 100644 --- a/examples/fullstack-war-application/frontend/build.gradle.kts +++ b/examples/fullstack-war-application/frontend/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } frontend { - nodeVersion.set("18.17.1") + nodeVersion.set("20.14.0") assembleScript.set("run build") cleanScript.set("run clean") checkScript.set("run check") diff --git a/examples/multiple-package-managers-with-shared-nodejs-distribution/node-subproject/build.gradle.kts b/examples/multiple-package-managers-with-shared-nodejs-distribution/node-subproject/build.gradle.kts index dfaef9ef..1fd4a360 100644 --- a/examples/multiple-package-managers-with-shared-nodejs-distribution/node-subproject/build.gradle.kts +++ b/examples/multiple-package-managers-with-shared-nodejs-distribution/node-subproject/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } frontend { - nodeVersion.set("18.17.1") + nodeVersion.set("20.14.0") nodeInstallDirectory.set(file(rootProject.ext.get("nodeInstallDirectory")!!)) } diff --git a/examples/npm-application/build.gradle.kts b/examples/npm-application/build.gradle.kts index d498b2d9..827c8fd1 100644 --- a/examples/npm-application/build.gradle.kts +++ b/examples/npm-application/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } frontend { - nodeVersion.set("18.17.1") + nodeVersion.set("20.14.0") assembleScript.set("run build") cleanScript.set("run clean") checkScript.set("run check") diff --git a/examples/pnpm-application/build.gradle.kts b/examples/pnpm-application/build.gradle.kts index f0be4bce..d9e748cb 100644 --- a/examples/pnpm-application/build.gradle.kts +++ b/examples/pnpm-application/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } frontend { - nodeVersion.set("18.17.1") + nodeVersion.set("20.14.0") assembleScript.set("run build") cleanScript.set("run clean") checkScript.set("run check") diff --git a/examples/yarn-application-with-node-modules-linker/build.gradle.kts b/examples/yarn-application-with-node-modules-linker/build.gradle.kts index 970c4cb4..88fcf497 100644 --- a/examples/yarn-application-with-node-modules-linker/build.gradle.kts +++ b/examples/yarn-application-with-node-modules-linker/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } frontend { - nodeVersion.set("18.17.1") + nodeVersion.set("20.14.0") assembleScript.set("run build") cleanScript.set("run clean") checkScript.set("run check") diff --git a/examples/yarn-application-with-pnp-linker/build.gradle.kts b/examples/yarn-application-with-pnp-linker/build.gradle.kts index 04f96683..80248b4c 100644 --- a/examples/yarn-application-with-pnp-linker/build.gradle.kts +++ b/examples/yarn-application-with-pnp-linker/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } frontend { - nodeVersion.set("18.17.1") + nodeVersion.set("20.14.0") assembleScript.set("run build") cleanScript.set("run clean") checkScript.set("run check") diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index e99230dc..03733c66 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -35,18 +35,18 @@ java { } sourceSets { - create("intTest") { + create("integrationTest") { compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output runtimeClasspath += sourceSets.main.get().output + sourceSets.test.get().output } } -val intTestImplementation: Configuration by configurations.getting { +val integrationTestImplementation: Configuration by configurations.getting { extendsFrom(configurations.implementation.get()) extendsFrom(configurations.testImplementation.get()) } -configurations["intTestRuntimeOnly"] +configurations["integrationTestRuntimeOnly"] .extendsFrom(configurations.runtimeOnly.get()) .extendsFrom(configurations.testRuntimeOnly.get()) @@ -69,56 +69,14 @@ dependencies { testCompileOnly("org.projectlombok:lombok:1.18.32") testAnnotationProcessor("org.projectlombok:lombok:1.18.32") - intTestImplementation("org.wiremock:wiremock:3.6.0") + integrationTestImplementation("org.wiremock:wiremock:3.6.0") } -tasks.named("wrapper") { - distributionType = Wrapper.DistributionType.ALL -} - -tasks.withType { - useJUnitPlatform() - jvmArgs( - "--add-opens", "java.base/java.lang=ALL-UNNAMED", - "--add-opens", "java.base/java.util=ALL-UNNAMED" - ) - outputs.upToDateWhen { false } -} - -tasks.register("integrationTest") { - description = "Runs integration tests." - group = "verification" - testClassesDirs = sourceSets["intTest"].output.classesDirs - classpath = sourceSets["intTest"].runtimeClasspath - // Yarn immutable installs prevents failures in integration tests due to missing yarn.lock file. - environment["YARN_ENABLE_IMMUTABLE_INSTALLS"] = "false" - shouldRunAfter("test") - outputs.upToDateWhen { false } -} - -tasks.named("check") { - dependsOn(tasks.named("integrationTest")) -} - -tasks.named("jacocoTestReport") { - dependsOn(tasks.named("test"), tasks.named("integrationTest")) - executionData.setFrom( - file("${project.layout.buildDirectory}/jacoco/test.exec"), - file("${project.layout.buildDirectory}/jacoco/integrationTest.exec") - ) - reports { - xml.required.set(true) - xml.outputLocation.set(file("${project.layout.buildDirectory}/reports/jacoco/report.xml")) - } -} - -gradle.addListener(GradleTestListener(logger)) - idea { module { // Force integration test source set as test folder - testSources.from(project.sourceSets.getByName("intTest").java.srcDirs) - testResources.from(project.sourceSets.getByName("intTest").resources.srcDirs) + testSources.from(project.sourceSets.getByName("integrationTest").java.srcDirs) + testResources.from(project.sourceSets.getByName("integrationTest").resources.srcDirs) isDownloadJavadoc = true isDownloadSources = true } @@ -151,24 +109,68 @@ sonarqube { property("sonar.projectVersion", "${fgpVersion}-jdk17") property("sonar.links.homepage", "https://github.com/siouan/frontend-gradle-plugin") - property("sonar.links.ci", "https://travis-ci.com/siouan/frontend-gradle-plugin") + property("sonar.links.ci", "https://github.com/siouan/frontend-gradle-plugin/actions") property("sonar.links.scm", "https://github.com/siouan/frontend-gradle-plugin") property("sonar.links.issue", "https://github.com/siouan/frontend-gradle-plugin/issues") property("sonar.sources", "src/main") - property("sonar.tests", "src/test,src/intTest") + property("sonar.tests", "src/test,src/integrationTest") property("sonar.java.binaries", "build/classes/java/main") - property("sonar.java.test.binaries", "build/classes/java/test,build/classes/java/intTest") + property("sonar.java.test.binaries", "build/classes/java/test,build/classes/java/integrationTest") property("sonar.junit.reportPaths", "build/test-results/test/,build/test-results/integrationTest/") - property("sonar.jacoco.xmlReportPaths", "${project.layout.buildDirectory}/reports/jacoco/report.xml") - property("sonar.java.test.binaries", "build/classes/java/test,build/classes/java/intTest") + property("sonar.jacoco.xmlReportPaths", "build/reports/jacoco/report.xml") property("sonar.verbose", true) // Irrelevant duplications detected on task inputs property( "sonar.cpd.exclusions", - "**/org/siouan/frontendgradleplugin/domain/model/*.java,**/org/siouan/frontendgradleplugin/domain/usecase/Resolve*ExecutablePath.java,**/org/siouan/frontendgradleplugin/infrastructure/gradle/FrontendExtension.java" + "**/org/siouan/frontendgradleplugin/domain/Resolve*ExecutablePath.java,**/org/siouan/frontendgradleplugin/infrastructure/gradle/FrontendExtension.java" ) } } + +tasks.named("wrapper") { + distributionType = Wrapper.DistributionType.ALL +} + +tasks.withType() { + useJUnitPlatform() +} + +tasks.named("test") { + jvmArgs( + "--add-opens", "java.base/java.lang=ALL-UNNAMED", + "--add-opens", "java.base/java.util=ALL-UNNAMED" + ) + outputs.upToDateWhen { false } +} + +tasks.register("integrationTest") { + description = "Runs integration tests." + group = "verification" + testClassesDirs = sourceSets["integrationTest"].output.classesDirs + classpath = sourceSets["integrationTest"].runtimeClasspath + // Yarn immutable installs prevents failures in integration tests due to missing yarn.lock file. + environment["YARN_ENABLE_IMMUTABLE_INSTALLS"] = "false" + shouldRunAfter("test") + outputs.upToDateWhen { false } +} + +tasks.named("check") { + dependsOn(tasks.named("integrationTest")) +} + +tasks.named("jacocoTestReport") { +// dependsOn(tasks.named("test")) + dependsOn(tasks.named("test"), tasks.named("integrationTest")) + executionData.setFrom( + project.layout.buildDirectory.files("jacoco/test.exec", "jacoco/integrationTest.exec"), + ) + reports { + xml.required.set(true) + xml.outputLocation.set(project.layout.buildDirectory.file("reports/jacoco/report.xml")) + } +} + +gradle.addListener(GradleTestListener(logger)) diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/MultiProjectsFuncTest.java b/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/MultiProjectsFuncTest.java deleted file mode 100644 index 3e504055..00000000 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/MultiProjectsFuncTest.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.siouan.frontendgradleplugin.infrastructure.gradle; - -import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskOutcomes; -import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile; -import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle; -import static org.siouan.frontendgradleplugin.test.GradleSettingsFiles.createSettingsFile; -import static org.siouan.frontendgradleplugin.test.Resources.getResourcePath; -import static org.siouan.frontendgradleplugin.test.Resources.getResourceUrl; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.gradle.language.base.plugins.LifecycleBasePlugin; -import org.gradle.testkit.runner.BuildResult; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import org.siouan.frontendgradleplugin.FrontendGradlePlugin; -import org.siouan.frontendgradleplugin.test.FrontendMapBuilder; -import org.siouan.frontendgradleplugin.test.PluginTaskOutcome; - -/** - * This test suite verifies task execution in a multi-projects build, where Node and Yarn distributions are downloaded - * and installed by one sub-project, and used as provided distributions by a second sub-project. The project layout is: - *
- * node/                        Node install directory, shall be created by sub-project-1
- * yarn-project-1/              Yarn sub-project
- *      build.gradle            Installs Node and Yarn distributions
- * npm-project-2/               NPM sub-project
- *      build.gradle            Uses distributions provided by sub-project-1
- * pnpm-project-3/              PNPM sub-project
- *      build.gradle            Uses distributions provided by sub-project-1
- * build.gradle                 Declares plugin, but doesn't apply it
- * settings.gradle
- * 
- */ -class MultiProjectsFuncTest { - - private static final String YARN_SUB_PROJECT_NAME = "yarn-project-1"; - - private static final String NPM_SUB_PROJECT_NAME = "npm-project-2"; - - private static final String PNPM_SUB_PROJECT_NAME = "pnpm-project-3"; - - @TempDir - Path temporaryDirectorypath; - - @Test - void should_run_tasks_in_sub_projects() throws IOException { - // Root project - final Path projectDirectoryPath = temporaryDirectorypath; - createSettingsFile(projectDirectoryPath, "multi-projects-test", YARN_SUB_PROJECT_NAME, NPM_SUB_PROJECT_NAME, - PNPM_SUB_PROJECT_NAME); - createBuildFile(projectDirectoryPath, true, false); - final Path nodeInstallDirectory = Paths.get("${rootProject.projectDir}/node"); - - // Sub-project 1 - final Path yarnSubProjectPath = Files.createDirectory(projectDirectoryPath.resolve(YARN_SUB_PROJECT_NAME)); - Files.copy(getResourcePath("package-yarn.json"), yarnSubProjectPath.resolve("package.json")); - final FrontendMapBuilder yarnSubProjectFrontendProperties = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeInstallDirectory(nodeInstallDirectory) - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) - .installScript("run install") - .cleanScript("run clean") - .assembleScript("run assemble") - .checkScript("run check") - .publishScript("run publish"); - createBuildFile(yarnSubProjectPath, yarnSubProjectFrontendProperties.toMap()); - - // Sub-project 2 - final Path npmSubProjectPath = Files.createDirectory(projectDirectoryPath.resolve(NPM_SUB_PROJECT_NAME)); - Files.copy(getResourcePath("package-npm.json"), npmSubProjectPath.resolve("package.json")); - final FrontendMapBuilder npmSubProjectFrontendProperties = new FrontendMapBuilder() - .nodeDistributionProvided(true) - .nodeInstallDirectory(nodeInstallDirectory) - .installScript("run install") - .cleanScript("run clean") - .assembleScript("run assemble") - .checkScript("run check") - .publishScript("run publish"); - createBuildFile(npmSubProjectPath, npmSubProjectFrontendProperties.toMap(), - "tasks.named('installPackageManager').configure {" + "dependsOn project(':" + YARN_SUB_PROJECT_NAME - + "').installNode\n}"); - - // Sub-project 3 - final Path pnpmSubProjectPath = Files.createDirectory(projectDirectoryPath.resolve(PNPM_SUB_PROJECT_NAME)); - Files.copy(getResourcePath("package-pnpm.json"), pnpmSubProjectPath.resolve("package.json")); - final FrontendMapBuilder pnpmSubProjectFrontendProperties = new FrontendMapBuilder() - .nodeDistributionProvided(true) - .nodeInstallDirectory(nodeInstallDirectory) - .installScript("run install") - .cleanScript("run clean") - .assembleScript("run assemble") - .checkScript("run check") - .publishScript("run publish"); - createBuildFile(pnpmSubProjectPath, pnpmSubProjectFrontendProperties.toMap(), - "tasks.named('installPackageManager').configure {" + "dependsOn project(':" + YARN_SUB_PROJECT_NAME - + "').installNode\n}"); - - final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME, - LifecycleBasePlugin.BUILD_TASK_NAME, FrontendGradlePlugin.GRADLE_PUBLISH_TASK_NAME); - - assertTaskOutcomes(result1, YARN_SUB_PROJECT_NAME, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS); - - assertTaskOutcomes(result1, NPM_SUB_PROJECT_NAME, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS); - - assertTaskOutcomes(result1, PNPM_SUB_PROJECT_NAME, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS); - - assertTaskOutcomes(result1, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.IGNORED); - - final BuildResult result2 = runGradle(projectDirectoryPath, LifecycleBasePlugin.BUILD_TASK_NAME, - FrontendGradlePlugin.GRADLE_PUBLISH_TASK_NAME); - - assertTaskOutcomes(result2, YARN_SUB_PROJECT_NAME, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS); - - assertTaskOutcomes(result2, NPM_SUB_PROJECT_NAME, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS); - - assertTaskOutcomes(result2, PNPM_SUB_PROJECT_NAME, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS); - - assertTaskOutcomes(result2, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.IGNORED); - - final BuildResult result3 = runGradle(projectDirectoryPath, LifecycleBasePlugin.BUILD_TASK_NAME, - FrontendGradlePlugin.GRADLE_PUBLISH_TASK_NAME); - - assertTaskOutcomes(result3, YARN_SUB_PROJECT_NAME, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS); - - assertTaskOutcomes(result3, NPM_SUB_PROJECT_NAME, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS); - - assertTaskOutcomes(result3, PNPM_SUB_PROJECT_NAME, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS); - - assertTaskOutcomes(result3, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, PluginTaskOutcome.IGNORED, - PluginTaskOutcome.IGNORED); - } -} diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithDownloadedDistributionsFuncTest.java b/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithDownloadedDistributionsFuncTest.java deleted file mode 100644 index 46fad3b3..00000000 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithDownloadedDistributionsFuncTest.java +++ /dev/null @@ -1,212 +0,0 @@ -package org.siouan.frontendgradleplugin.infrastructure.gradle; - -import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskFailed; -import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskOutcomes; -import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile; -import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle; -import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradleAndExpectFailure; -import static org.siouan.frontendgradleplugin.test.Resources.getResourcePath; -import static org.siouan.frontendgradleplugin.test.TaskTypes.buildCorepackTaskDefinition; -import static org.siouan.frontendgradleplugin.test.TaskTypes.buildNodeTaskDefinition; -import static org.siouan.frontendgradleplugin.test.TaskTypes.buildNpmTaskDefinition; -import static org.siouan.frontendgradleplugin.test.TaskTypes.buildPnpmTaskDefinition; -import static org.siouan.frontendgradleplugin.test.TaskTypes.buildYarnTaskDefinition; -import static org.siouan.frontendgradleplugin.test.TaskTypes.createJavascriptFile; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.Set; - -import org.gradle.testkit.runner.BuildResult; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import org.siouan.frontendgradleplugin.FrontendGradlePlugin; -import org.siouan.frontendgradleplugin.test.FrontendMapBuilder; -import org.siouan.frontendgradleplugin.test.PluginTaskOutcome; - -/** - * Functional tests to verify task types {@link RunNode}, {@link RunNpm}, {@link RunPnpm}, {@link RunYarn} in a Gradle - * build, with a downloaded Node.js distribution. - */ -class TaskTypesWithDownloadedDistributionsFuncTest { - - private static final String RUN_COREPACK_TASK_NAME = "customCorepackTask"; - - private static final String RUN_NODE_TASK_NAME = "customNodeTask"; - - private static final String RUN_NPM_TASK_NAME = "customNpmTask"; - - private static final String RUN_PNPM_TASK_NAME = "customPnpmTask"; - - private static final String RUN_YARN_TASK_NAME = "customYarnTask"; - - @TempDir - Path temporaryDirectoryPath; - - private Path projectDirectoryPath; - - @BeforeEach - void setUp() { - projectDirectoryPath = temporaryDirectoryPath; - } - - @Test - void should_fail_running_custom_corepack_task_when_script_is_undefined() throws IOException { - final String runCorepackTaskDefinition = buildCorepackTaskDefinition(RUN_COREPACK_TASK_NAME, null); - createBuildFile(projectDirectoryPath, runCorepackTaskDefinition); - - final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_COREPACK_TASK_NAME); - - assertTaskFailed(result, RUN_COREPACK_TASK_NAME); - } - - @Test - void should_fail_running_custom_node_task_when_script_is_undefined() throws IOException { - final String runNodeTaskDefinition = buildNodeTaskDefinition(RUN_NODE_TASK_NAME, null, null); - createBuildFile(projectDirectoryPath, runNodeTaskDefinition); - - final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_NODE_TASK_NAME); - - assertTaskFailed(result, RUN_NODE_TASK_NAME); - } - - @Test - void should_fail_running_custom_npm_task_when_script_is_undefined() throws IOException { - final String runNpmTaskDefinition = buildNpmTaskDefinition(RUN_NPM_TASK_NAME, null); - createBuildFile(projectDirectoryPath, runNpmTaskDefinition); - - final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_NPM_TASK_NAME); - - assertTaskFailed(result, RUN_NPM_TASK_NAME); - } - - @Test - void should_fail_running_custom_pnpm_task_when_script_is_undefined() throws IOException { - final String runPnpmTaskDefinition = buildPnpmTaskDefinition(RUN_PNPM_TASK_NAME, null); - createBuildFile(projectDirectoryPath, runPnpmTaskDefinition); - - final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_PNPM_TASK_NAME); - - assertTaskFailed(result, RUN_PNPM_TASK_NAME); - } - - @Test - void should_fail_running_custom_yarn_task_when_script_is_undefined() throws IOException { - final String customTaskDefinition = buildYarnTaskDefinition(RUN_YARN_TASK_NAME, null); - createBuildFile(projectDirectoryPath, customTaskDefinition); - - final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_YARN_TASK_NAME); - - assertTaskFailed(result, RUN_YARN_TASK_NAME); - } - - @Test - void should_run_custom_tasks() throws IOException { - final Path packageJsonDirectoryPath = Files.createDirectory(projectDirectoryPath.resolve("frontend")); - Files.copy(getResourcePath("package-npm.json"), packageJsonDirectoryPath.resolve("package.json")); - final Path temporaryScriptPath = createJavascriptFile(temporaryDirectoryPath.resolve("script.js")); - final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeInstallDirectory(projectDirectoryPath.resolve("node-dist")) - .packageJsonDirectory(packageJsonDirectoryPath) - .verboseModeEnabled(false); - final String runCorepackTaskDefinition = buildCorepackTaskDefinition(RUN_COREPACK_TASK_NAME, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, "-v"); - final String runNodeTaskDefinition = buildNodeTaskDefinition(RUN_NODE_TASK_NAME, - temporaryScriptPath.toString().replace("\\", "\\\\")); - final String runNpmTaskDefinition = buildNpmTaskDefinition(RUN_NPM_TASK_NAME, - FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME, "run another-script"); - final String runPnpmTaskDefinition = buildPnpmTaskDefinition(RUN_PNPM_TASK_NAME, - FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME, "run another-script"); - final String runYarnTaskDefinition = buildYarnTaskDefinition(RUN_YARN_TASK_NAME, - Set.of(FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME), - "run another-script"); - final String additionalContent = String.join("\n", runCorepackTaskDefinition, runNodeTaskDefinition, - runNpmTaskDefinition, runPnpmTaskDefinition, runYarnTaskDefinition); - createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), additionalContent); - - final BuildResult runNodeTaskResult1 = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); - - assertTaskOutcomes(runNodeTaskResult1, PluginTaskOutcome.SUCCESS, RUN_NODE_TASK_NAME, - PluginTaskOutcome.SUCCESS); - - final BuildResult runNodeTaskResult2 = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); - - assertTaskOutcomes(runNodeTaskResult2, PluginTaskOutcome.UP_TO_DATE, RUN_NODE_TASK_NAME, - PluginTaskOutcome.SUCCESS); - - final BuildResult runCorepackTaskResult1 = runGradle(projectDirectoryPath, RUN_COREPACK_TASK_NAME); - - assertTaskOutcomes(runCorepackTaskResult1, PluginTaskOutcome.UP_TO_DATE, RUN_COREPACK_TASK_NAME, - PluginTaskOutcome.SUCCESS); - - final BuildResult runNpmTaskResult1 = runGradle(projectDirectoryPath, RUN_NPM_TASK_NAME); - - assertTaskOutcomes(runNpmTaskResult1, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, RUN_NPM_TASK_NAME, PluginTaskOutcome.SUCCESS); - - final BuildResult runNpmTaskResult2 = runGradle(projectDirectoryPath, RUN_NPM_TASK_NAME); - - assertTaskOutcomes(runNpmTaskResult2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, RUN_NPM_TASK_NAME, PluginTaskOutcome.SUCCESS); - - Files.deleteIfExists(projectDirectoryPath.resolve("package-lock.json")); - Files.copy(getResourcePath("package-pnpm.json"), packageJsonDirectoryPath.resolve("package.json"), - StandardCopyOption.REPLACE_EXISTING); - createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), additionalContent); - - final BuildResult runNodeTaskResult3 = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); - - assertTaskOutcomes(runNodeTaskResult3, PluginTaskOutcome.UP_TO_DATE, RUN_NODE_TASK_NAME, - PluginTaskOutcome.SUCCESS); - - final BuildResult runCorepackTaskResult2 = runGradle(projectDirectoryPath, RUN_COREPACK_TASK_NAME); - - assertTaskOutcomes(runCorepackTaskResult2, PluginTaskOutcome.UP_TO_DATE, RUN_COREPACK_TASK_NAME, - PluginTaskOutcome.SUCCESS); - - final BuildResult runPnpmTaskResult3 = runGradle(projectDirectoryPath, RUN_PNPM_TASK_NAME); - - assertTaskOutcomes(runPnpmTaskResult3, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, RUN_PNPM_TASK_NAME, PluginTaskOutcome.SUCCESS); - - final BuildResult runPnpmTaskResult4 = runGradle(projectDirectoryPath, RUN_PNPM_TASK_NAME); - - assertTaskOutcomes(runPnpmTaskResult4, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, RUN_PNPM_TASK_NAME, PluginTaskOutcome.SUCCESS); - - Files.deleteIfExists(packageJsonDirectoryPath.resolve("package-lock.json")); - Files.copy(getResourcePath("package-yarn.json"), packageJsonDirectoryPath.resolve("package.json"), - StandardCopyOption.REPLACE_EXISTING); - frontendMapBuilder.verboseModeEnabled(false); - createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), additionalContent); - - final BuildResult runNodeTaskResult5 = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); - - assertTaskOutcomes(runNodeTaskResult5, PluginTaskOutcome.UP_TO_DATE, RUN_NODE_TASK_NAME, - PluginTaskOutcome.SUCCESS); - - final BuildResult runNodeTaskResult6 = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); - - assertTaskOutcomes(runNodeTaskResult6, PluginTaskOutcome.UP_TO_DATE, RUN_NODE_TASK_NAME, - PluginTaskOutcome.SUCCESS); - - final BuildResult runCorepackTaskResult3 = runGradle(projectDirectoryPath, RUN_COREPACK_TASK_NAME); - - assertTaskOutcomes(runCorepackTaskResult3, PluginTaskOutcome.UP_TO_DATE, RUN_COREPACK_TASK_NAME, - PluginTaskOutcome.SUCCESS); - - final BuildResult runYarnTaskResult1 = runGradle(projectDirectoryPath, RUN_YARN_TASK_NAME); - - assertTaskOutcomes(runYarnTaskResult1, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, RUN_YARN_TASK_NAME, PluginTaskOutcome.SUCCESS); - - final BuildResult runYarnTaskResult2 = runGradle(projectDirectoryPath, RUN_YARN_TASK_NAME); - - assertTaskOutcomes(runYarnTaskResult2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, RUN_YARN_TASK_NAME, PluginTaskOutcome.SUCCESS); - } -} diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AssembleFrontedTaskFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AssembleFrontedTaskFuncTest.java similarity index 76% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AssembleFrontedTaskFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AssembleFrontedTaskFuncTest.java index 1e41bead..bbb732e8 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AssembleFrontedTaskFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AssembleFrontedTaskFuncTest.java @@ -41,73 +41,73 @@ void setUp() throws IOException { @Test void should_skip_task_when_package_json_file_does_not_exist() throws IOException { final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .assembleScript("run assemble") .packageJsonDirectory(packageJsonDirectoryPath); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, ASSEMBLE_TASK_NAME); - assertAssembleTaskOutcomes(result1, SUCCESS, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null); + assertAssembleTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null); final BuildResult result2 = runGradle(projectDirectoryPath, ASSEMBLE_TASK_NAME); - assertAssembleTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null); + assertAssembleTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null); } @Test void should_skip_task_when_script_is_not_defined() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), packageJsonDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .packageJsonDirectory(packageJsonDirectoryPath); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, ASSEMBLE_TASK_NAME); - assertAssembleTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null); + assertAssembleTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null); final BuildResult result2 = runGradle(projectDirectoryPath, ASSEMBLE_TASK_NAME); - assertAssembleTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null); + assertAssembleTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null); } @Test void should_skip_task_when_running_gradle_task_and_script_is_not_defined() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), packageJsonDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .packageJsonDirectory(packageJsonDirectoryPath); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_ASSEMBLE_TASK_NAME); - assertAssembleTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, UP_TO_DATE); + assertAssembleTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SKIPPED, UP_TO_DATE); final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_ASSEMBLE_TASK_NAME); - assertAssembleTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE); + assertAssembleTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE); } @Test void should_assemble_frontend() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), packageJsonDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .packageJsonDirectory(packageJsonDirectoryPath) .assembleScript("run assemble"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_ASSEMBLE_TASK_NAME); - assertAssembleTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS); + assertAssembleTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS); final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_ASSEMBLE_TASK_NAME); - assertAssembleTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS); + assertAssembleTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS); } } diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AuthenticationAndProxyFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AuthenticationAndProxyFuncTest.java similarity index 79% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AuthenticationAndProxyFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AuthenticationAndProxyFuncTest.java index 775cf809..61fc7ee8 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AuthenticationAndProxyFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AuthenticationAndProxyFuncTest.java @@ -1,7 +1,13 @@ package org.siouan.frontendgradleplugin.infrastructure.gradle; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_NODE_TASK_NAME; import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskOutcome; +import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile; +import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle; +import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradleAndExpectFailure; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.FAILED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SUCCESS; import java.io.IOException; import java.net.URL; @@ -14,11 +20,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import org.siouan.frontendgradleplugin.FrontendGradlePlugin; import org.siouan.frontendgradleplugin.test.FrontendMapBuilder; -import org.siouan.frontendgradleplugin.test.GradleBuildFiles; -import org.siouan.frontendgradleplugin.test.GradleHelper; -import org.siouan.frontendgradleplugin.test.PluginTaskOutcome; import org.siouan.frontendgradleplugin.test.ServerConfigurator; /** @@ -81,12 +83,11 @@ void should_fail_installing_node_when_authentication_fails_on_distribution_serve // We use a HTTP address because proxying through HTTPS is not supported with WireMock. final FrontendMapBuilder frontendMapBuilder = configureNodeServerAndPluginWithDirectConnection("AYr2n{VF"); - GradleBuildFiles.createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); - final BuildResult result = GradleHelper.runGradleAndExpectFailure(projectDirectoryPath, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.FAILED); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, FAILED); } // Same test as above, just use the exact password. @@ -97,12 +98,11 @@ void should_install_node_when_authentication_succeeds_on_distribution_server() t // We use a HTTP address because proxying through HTTPS is not supported with WireMock. final FrontendMapBuilder frontendMapBuilder = configureNodeServerAndPluginWithDirectConnection( DISTRIBUTION_SERVER_PASSWORD); - GradleBuildFiles.createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); - final BuildResult result = GradleHelper.runGradle(projectDirectoryPath, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradle(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.SUCCESS); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, SUCCESS); } @Test @@ -115,13 +115,12 @@ void should_fail_installing_node_when_proxy_server_is_not_reachable() throws IOE // the proxy server, and the build shall succeed. final FrontendMapBuilder frontendMapBuilder = configureNodeServerAndPluginWithProxyConnection( DISTRIBUTION_SERVER_PORT + 10); - GradleBuildFiles.createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); // The build should fail with a java.net.ConnectException because the proxy server is not reachable. - final BuildResult result = GradleHelper.runGradleAndExpectFailure(projectDirectoryPath, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.FAILED); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, FAILED); } // Same test as above, just use the exact proxy server port. @@ -131,12 +130,11 @@ void should_install_node_through_proxy_server() throws IOException { // We use a HTTP address because proxying through HTTPS is not supported with WireMock. final FrontendMapBuilder frontendMapBuilder = configureNodeServerAndPluginWithProxyConnection(); - GradleBuildFiles.createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); - final BuildResult result = GradleHelper.runGradle(projectDirectoryPath, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradle(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.SUCCESS); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, SUCCESS); } @Test @@ -145,12 +143,11 @@ void should_fail_installing_node_when_authentication_fails_on_proxy_server() thr // We use a HTTP address because proxying through HTTPS is not supported with WireMock. final FrontendMapBuilder frontendMapBuilder = configureNodeServerAndPluginWithProxyConnection("xE!s67O?"); - GradleBuildFiles.createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); - final BuildResult result = GradleHelper.runGradleAndExpectFailure(projectDirectoryPath, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.FAILED); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, FAILED); } // Same test as above, just use the exact password. @@ -161,12 +158,11 @@ void should_install_node_when_authentication_succeeds_on_proxy_server() throws I // We use a HTTP address because proxying through HTTPS is not supported with WireMock. final FrontendMapBuilder frontendMapBuilder = configureNodeServerAndPluginWithProxyConnection( PROXY_SERVER_PASSWORD); - GradleBuildFiles.createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); - final BuildResult result = GradleHelper.runGradle(projectDirectoryPath, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradle(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.SUCCESS); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, SUCCESS); } private FrontendMapBuilder configureNodeServerAndPluginWithDirectConnection(final String distributionServerPassword) @@ -207,7 +203,7 @@ private FrontendMapBuilder configureServerAndPlugin(final String nodeDistributio final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder().verboseModeEnabled(false); if (nodeDistributionUrlRoot != null) { frontendMapBuilder - .nodeVersion("18.17.1") + .nodeVersion("20.14.0") .nodeDistributionUrlRoot(nodeDistributionUrlRoot) .nodeDistributionUrlPathPattern(nodeDistributionUrlPathPattern); distributionServerConfigurator.withNodeDistribution(); diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CheckFrontendTaskFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CheckFrontendTaskFuncTest.java similarity index 74% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CheckFrontendTaskFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CheckFrontendTaskFuncTest.java index 65407a24..15f6928e 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CheckFrontendTaskFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CheckFrontendTaskFuncTest.java @@ -33,69 +33,69 @@ class CheckFrontendTaskFuncTest { @Test void should_skip_task_when_package_json_file_does_not_exist() throws IOException { final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .checkScript("run check"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, CHECK_TASK_NAME); - assertCheckTaskOutcomes(result1, SUCCESS, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null); + assertCheckTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null); final BuildResult result2 = runGradle(projectDirectoryPath, CHECK_TASK_NAME); - assertCheckTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null); + assertCheckTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null); } @Test void should_skip_task_when_script_is_not_defined() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")); + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, CHECK_TASK_NAME); - assertCheckTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null); + assertCheckTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null); final BuildResult result2 = runGradle(projectDirectoryPath, CHECK_TASK_NAME); - assertCheckTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null); + assertCheckTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null); } @Test void should_skip_task_when_running_gradle_task_and_script_is_not_defined() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")); + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_CHECK_TASK_NAME); - assertCheckTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, UP_TO_DATE); + assertCheckTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SKIPPED, UP_TO_DATE); final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_CHECK_TASK_NAME); - assertCheckTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE); + assertCheckTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE); } @Test void should_check_frontend() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .checkScript("run check"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_CHECK_TASK_NAME); - assertCheckTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS); + assertCheckTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS); final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_CHECK_TASK_NAME); - assertCheckTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS); + assertCheckTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS); } } diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CleanFrontendTaskFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CleanFrontendTaskFuncTest.java similarity index 74% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CleanFrontendTaskFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CleanFrontendTaskFuncTest.java index 8c7d8c3d..113aa4dd 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CleanFrontendTaskFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/CleanFrontendTaskFuncTest.java @@ -33,69 +33,69 @@ class CleanFrontendTaskFuncTest { @Test void should_skip_task_when_package_json_file_does_not_exist() throws IOException { final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .cleanScript("run clean"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, CLEAN_TASK_NAME); - assertCleanTaskOutcomes(result1, SUCCESS, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null); + assertCleanTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null); final BuildResult result2 = runGradle(projectDirectoryPath, CLEAN_TASK_NAME); - assertCleanTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null); + assertCleanTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null); } @Test void should_skip_task_when_script_is_not_defined() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")); + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, CLEAN_TASK_NAME); - assertCleanTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null); + assertCleanTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null); final BuildResult result2 = runGradle(projectDirectoryPath, CLEAN_TASK_NAME); - assertCleanTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null); + assertCleanTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null); } @Test void should_skip_task_when_running_gradle_task_and_script_is_not_defined() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")); + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_CLEAN_TASK_NAME); - assertCleanTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, SUCCESS); + assertCleanTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SKIPPED, SUCCESS); final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_CLEAN_TASK_NAME); - assertCleanTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE); + assertCleanTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE); } @Test void should_clean_frontend() throws IOException { Files.copy(getResourcePath("package-npm.json"), projectDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .cleanScript("run clean"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_CLEAN_TASK_NAME); - assertCleanTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS); + assertCleanTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS); final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_CLEAN_TASK_NAME); - assertCleanTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, UP_TO_DATE); + assertCleanTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, UP_TO_DATE); } } diff --git a/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallCorepackTaskFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallCorepackTaskFuncTest.java new file mode 100644 index 00000000..21c1d8ea --- /dev/null +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallCorepackTaskFuncTest.java @@ -0,0 +1,75 @@ +package org.siouan.frontendgradleplugin.infrastructure.gradle; + +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_COREPACK_TASK_NAME; +import static org.siouan.frontendgradleplugin.infrastructure.gradle.InstallCorepackTask.LATEST_VERSION_ARGUMENT; +import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskOutcomes; +import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile; +import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle; +import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradleAndExpectFailure; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.FAILED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SKIPPED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SUCCESS; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.UP_TO_DATE; +import static org.siouan.frontendgradleplugin.test.Resources.getResourcePath; +import static org.siouan.frontendgradleplugin.test.Resources.getResourceUrl; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.gradle.testkit.runner.BuildResult; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.siouan.frontendgradleplugin.test.FrontendMapBuilder; + +/** + * Functional tests to verify the {@link InstallCorepackTask} integration in a Gradle build. Test cases uses a fake Node + * distribution, to avoid the download overhead. All executables in these distributions simply call the 'node' + * executable with the same arguments. + */ +class InstallCorepackTaskFuncTest { + + @TempDir + Path projectDirectoryPath; + + @Test + void should_skip_task_when_corepack_version_property_is_null() throws IOException { + final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); + + final BuildResult result = runGradle(projectDirectoryPath, INSTALL_COREPACK_TASK_NAME); + + assertTaskOutcomes(result, SUCCESS, SKIPPED); + } + + @Test + void should_fail_when_node_install_directory_is_not_a_directory() throws IOException { + Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); + createBuildFile(projectDirectoryPath, + new FrontendMapBuilder().nodeDistributionProvided(true).corepackVersion(LATEST_VERSION_ARGUMENT).toMap()); + + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, INSTALL_COREPACK_TASK_NAME); + + assertTaskOutcomes(result, SKIPPED, FAILED); + } + + @Test + void should_install_corepack() throws IOException { + Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); + final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() + .nodeVersion("20.14.0") + .corepackVersion(LATEST_VERSION_ARGUMENT) + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); + + final BuildResult result1 = runGradle(projectDirectoryPath, INSTALL_COREPACK_TASK_NAME); + + assertTaskOutcomes(result1, SUCCESS, SUCCESS); + + final BuildResult result2 = runGradle(projectDirectoryPath, INSTALL_COREPACK_TASK_NAME); + + assertTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE); + } +} diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallFrontendTaskFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallFrontendTaskFuncTest.java similarity index 79% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallFrontendTaskFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallFrontendTaskFuncTest.java index c9530bb3..fde86bda 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallFrontendTaskFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallFrontendTaskFuncTest.java @@ -32,51 +32,51 @@ class InstallFrontendTaskFuncTest { @Test void should_skip_task_when_package_json_file_does_not_exist() throws IOException { final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")); + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, INSTALL_FRONTEND_TASK_NAME); - assertTaskOutcomes(result1, SUCCESS, SUCCESS, SKIPPED, SKIPPED); + assertTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SKIPPED, SKIPPED); final BuildResult result2 = runGradle(projectDirectoryPath, INSTALL_FRONTEND_TASK_NAME); - assertTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, SKIPPED, SKIPPED); + assertTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, SKIPPED, SKIPPED); } @Test void should_succeed_with_default_script() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")); + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, INSTALL_FRONTEND_TASK_NAME); - assertTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS); + assertTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS); final BuildResult result2 = runGradle(projectDirectoryPath, INSTALL_FRONTEND_TASK_NAME); - assertTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS); + assertTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS); } @Test void should_succeed_with_custom_script() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .installScript("ci"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, INSTALL_FRONTEND_TASK_NAME); - assertTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS); + assertTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS); final BuildResult result2 = runGradle(projectDirectoryPath, INSTALL_FRONTEND_TASK_NAME); - assertTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS); + assertTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS); } } diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallNodeTaskFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallNodeTaskFuncTest.java similarity index 67% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallNodeTaskFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallNodeTaskFuncTest.java index cc820949..83da0ecb 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallNodeTaskFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallNodeTaskFuncTest.java @@ -1,9 +1,14 @@ package org.siouan.frontendgradleplugin.infrastructure.gradle; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_NODE_TASK_NAME; import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskOutcome; import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile; import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle; import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradleAndExpectFailure; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.FAILED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SKIPPED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SUCCESS; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.UP_TO_DATE; import static org.siouan.frontendgradleplugin.test.Resources.getResourceUrl; import java.io.IOException; @@ -13,9 +18,7 @@ import org.gradle.testkit.runner.BuildResult; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import org.siouan.frontendgradleplugin.FrontendGradlePlugin; import org.siouan.frontendgradleplugin.test.FrontendMapBuilder; -import org.siouan.frontendgradleplugin.test.PluginTaskOutcome; /** * Functional tests to verify the {@link InstallNodeTask} integration in a Gradle build. Test cases uses a fake Node @@ -30,57 +33,54 @@ class InstallNodeTaskFuncTest { void should_be_skipped_when_distribution_is_provided() throws IOException { createBuildFile(projectDirectoryPath, new FrontendMapBuilder().nodeDistributionProvided(true).toMap()); - final BuildResult result = runGradle(projectDirectoryPath, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradle(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.SKIPPED); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, SKIPPED); } @Test void should_fail_when_node_version_is_not_set() throws IOException { createBuildFile(projectDirectoryPath, Map.of()); - final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.FAILED); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, FAILED); } @Test void should_fail_when_distribution_cannot_be_downloaded_due_to_an_unknown_version() throws IOException { createBuildFile(projectDirectoryPath, Map.of("nodeVersion", "0.76.34")); - final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.FAILED); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, FAILED); } @Test void should_fail_when_distribution_download_url_is_invalid() throws IOException { final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") + .nodeVersion("20.14.0") .nodeDistributionUrlRoot("protocol://domain/unknown"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); - final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.FAILED); + assertTaskOutcome(result, INSTALL_NODE_TASK_NAME, FAILED); } @Test void should_succeed_first_time_and_be_up_to_date_next_time() throws IOException { final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")); + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); - final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result1 = runGradle(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.SUCCESS); + assertTaskOutcome(result1, INSTALL_NODE_TASK_NAME, SUCCESS); - final BuildResult result2 = runGradle(projectDirectoryPath, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME); + final BuildResult result2 = runGradle(projectDirectoryPath, INSTALL_NODE_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, PluginTaskOutcome.UP_TO_DATE); + assertTaskOutcome(result2, INSTALL_NODE_TASK_NAME, UP_TO_DATE); } } diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallPackageManagerTaskFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallPackageManagerTaskFuncTest.java similarity index 81% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallPackageManagerTaskFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallPackageManagerTaskFuncTest.java index 263d4211..9787de9b 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallPackageManagerTaskFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallPackageManagerTaskFuncTest.java @@ -35,17 +35,17 @@ class InstallPackageManagerTaskFuncTest { @Test void should_skip_task_when_package_json_file_does_not_exist() throws IOException { final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")); + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, INSTALL_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(result1, SUCCESS, SUCCESS, SKIPPED); + assertTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SKIPPED); final BuildResult result2 = runGradle(projectDirectoryPath, INSTALL_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, SKIPPED); + assertTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, SKIPPED); } @Test @@ -55,24 +55,24 @@ void should_fail_when_node_install_directory_is_not_a_directory() throws IOExcep final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, INSTALL_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(result, SKIPPED, SUCCESS, FAILED); + assertTaskOutcomes(result, SKIPPED, SKIPPED, SUCCESS, FAILED); } @Test void should_install_package_managers() throws IOException { Files.copy(getResourcePath("package-npm.json"), projectDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")); + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult installNpmResult1 = runGradle(projectDirectoryPath, INSTALL_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(installNpmResult1, SUCCESS, SUCCESS, SUCCESS); + assertTaskOutcomes(installNpmResult1, SUCCESS, SKIPPED, SUCCESS, SUCCESS); final BuildResult installNpmResult2 = runGradle(projectDirectoryPath, INSTALL_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(installNpmResult2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE); + assertTaskOutcomes(installNpmResult2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE); Files.copy(getResourcePath("package-pnpm.json"), projectDirectoryPath.resolve("package.json"), StandardCopyOption.REPLACE_EXISTING); @@ -80,11 +80,11 @@ void should_install_package_managers() throws IOException { final BuildResult installPnpmResult1 = runGradle(projectDirectoryPath, INSTALL_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(installPnpmResult1, UP_TO_DATE, SUCCESS, SUCCESS); + assertTaskOutcomes(installPnpmResult1, UP_TO_DATE, SKIPPED, SUCCESS, SUCCESS); final BuildResult installPnpmResult2 = runGradle(projectDirectoryPath, INSTALL_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(installPnpmResult2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE); + assertTaskOutcomes(installPnpmResult2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE); Files.copy(getResourcePath("package-yarn.json"), projectDirectoryPath.resolve("package.json"), StandardCopyOption.REPLACE_EXISTING); @@ -92,10 +92,10 @@ void should_install_package_managers() throws IOException { final BuildResult installYarnResult1 = runGradle(projectDirectoryPath, INSTALL_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(installYarnResult1, UP_TO_DATE, SUCCESS, SUCCESS); + assertTaskOutcomes(installYarnResult1, UP_TO_DATE, SKIPPED, SUCCESS, SUCCESS); final BuildResult installYarnResult2 = runGradle(projectDirectoryPath, INSTALL_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(installYarnResult2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE); + assertTaskOutcomes(installYarnResult2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE); } } diff --git a/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/MultiProjectsFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/MultiProjectsFuncTest.java new file mode 100644 index 00000000..b4dc778c --- /dev/null +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/MultiProjectsFuncTest.java @@ -0,0 +1,151 @@ +package org.siouan.frontendgradleplugin.infrastructure.gradle; + +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.GRADLE_PUBLISH_TASK_NAME; +import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskOutcomes; +import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile; +import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle; +import static org.siouan.frontendgradleplugin.test.GradleSettingsFiles.createSettingsFile; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.IGNORED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SKIPPED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SUCCESS; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.UP_TO_DATE; +import static org.siouan.frontendgradleplugin.test.Resources.getResourcePath; +import static org.siouan.frontendgradleplugin.test.Resources.getResourceUrl; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.gradle.language.base.plugins.LifecycleBasePlugin; +import org.gradle.testkit.runner.BuildResult; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.siouan.frontendgradleplugin.test.FrontendMapBuilder; + +/** + * This test suite verifies task execution in a multi-projects build, where Node is downloaded and installed by one + * sub-project, and used as a provided distribution by a other sub-projects. The project layout is: + *
+ * node/                        Node install directory, shall be created by sub-project-1
+ * yarn-project-1/              Yarn sub-project
+ *      build.gradle            Installs Node and Yarn distributions
+ * npm-project-2/               NPM sub-project
+ *      build.gradle            Uses distributions provided by sub-project-1
+ * pnpm-project-3/              PNPM sub-project
+ *      build.gradle            Uses distributions provided by sub-project-1
+ * build.gradle                 Declares plugin, but doesn't apply it
+ * settings.gradle
+ * 
+ */ +class MultiProjectsFuncTest { + + private static final String YARN_SUB_PROJECT_NAME = "yarn-project-1"; + + private static final String NPM_SUB_PROJECT_NAME = "npm-project-2"; + + private static final String PNPM_SUB_PROJECT_NAME = "pnpm-project-3"; + + @TempDir + Path temporaryDirectorypath; + + @Test + void should_run_tasks_in_sub_projects() throws IOException { + // Root project + final Path projectDirectoryPath = temporaryDirectorypath; + createSettingsFile(projectDirectoryPath, "multi-projects-test", YARN_SUB_PROJECT_NAME, NPM_SUB_PROJECT_NAME, + PNPM_SUB_PROJECT_NAME); + createBuildFile(projectDirectoryPath, true, false); + final Path nodeInstallDirectory = Paths.get("${rootProject.projectDir}/node"); + + // Sub-project 1 + final Path yarnSubProjectPath = Files.createDirectory(projectDirectoryPath.resolve(YARN_SUB_PROJECT_NAME)); + Files.copy(getResourcePath("package-yarn.json"), yarnSubProjectPath.resolve("package.json")); + final FrontendMapBuilder yarnSubProjectFrontendProperties = new FrontendMapBuilder() + .nodeVersion("20.14.0") + .nodeInstallDirectory(nodeInstallDirectory) + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) + .installScript("run install") + .cleanScript("run clean") + .assembleScript("run assemble") + .checkScript("run check") + .publishScript("run publish"); + createBuildFile(yarnSubProjectPath, yarnSubProjectFrontendProperties.toMap()); + + // Sub-project 2 + final Path npmSubProjectPath = Files.createDirectory(projectDirectoryPath.resolve(NPM_SUB_PROJECT_NAME)); + Files.copy(getResourcePath("package-npm.json"), npmSubProjectPath.resolve("package.json")); + final FrontendMapBuilder npmSubProjectFrontendProperties = new FrontendMapBuilder() + .nodeDistributionProvided(true) + .nodeInstallDirectory(nodeInstallDirectory) + .installScript("run install") + .cleanScript("run clean") + .assembleScript("run assemble") + .checkScript("run check") + .publishScript("run publish"); + createBuildFile(npmSubProjectPath, npmSubProjectFrontendProperties.toMap(), + "tasks.named('installPackageManager').configure {" + "dependsOn project(':" + YARN_SUB_PROJECT_NAME + + "').installNode\n}"); + + // Sub-project 3 + final Path pnpmSubProjectPath = Files.createDirectory(projectDirectoryPath.resolve(PNPM_SUB_PROJECT_NAME)); + Files.copy(getResourcePath("package-pnpm.json"), pnpmSubProjectPath.resolve("package.json")); + final FrontendMapBuilder pnpmSubProjectFrontendProperties = new FrontendMapBuilder() + .nodeDistributionProvided(true) + .nodeInstallDirectory(nodeInstallDirectory) + .installScript("run install") + .cleanScript("run clean") + .assembleScript("run assemble") + .checkScript("run check") + .publishScript("run publish"); + createBuildFile(pnpmSubProjectPath, pnpmSubProjectFrontendProperties.toMap(), + "tasks.named('installPackageManager').configure {" + "dependsOn project(':" + YARN_SUB_PROJECT_NAME + + "').installNode\n}"); + + final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_CLEAN_TASK_NAME, + LifecycleBasePlugin.BUILD_TASK_NAME, GRADLE_PUBLISH_TASK_NAME); + + assertTaskOutcomes(result1, YARN_SUB_PROJECT_NAME, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SUCCESS, + SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS); + + assertTaskOutcomes(result1, NPM_SUB_PROJECT_NAME, SKIPPED, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS, + SUCCESS, SUCCESS, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS); + + assertTaskOutcomes(result1, PNPM_SUB_PROJECT_NAME, SKIPPED, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SUCCESS, + SUCCESS, SUCCESS, SUCCESS, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS); + + assertTaskOutcomes(result1, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, + IGNORED, IGNORED, IGNORED, IGNORED); + + final BuildResult result2 = runGradle(projectDirectoryPath, LifecycleBasePlugin.BUILD_TASK_NAME, + GRADLE_PUBLISH_TASK_NAME); + + assertTaskOutcomes(result2, YARN_SUB_PROJECT_NAME, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, + IGNORED, SUCCESS, SUCCESS, SUCCESS, IGNORED, SUCCESS, SUCCESS, SUCCESS); + + assertTaskOutcomes(result2, NPM_SUB_PROJECT_NAME, SKIPPED, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, IGNORED, + SUCCESS, SUCCESS, SUCCESS, IGNORED, SUCCESS, SUCCESS, SUCCESS); + + assertTaskOutcomes(result2, PNPM_SUB_PROJECT_NAME, SKIPPED, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, IGNORED, + SUCCESS, SUCCESS, SUCCESS, IGNORED, SUCCESS, SUCCESS, SUCCESS); + + assertTaskOutcomes(result2, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, + IGNORED, IGNORED, IGNORED, IGNORED); + + final BuildResult result3 = runGradle(projectDirectoryPath, LifecycleBasePlugin.BUILD_TASK_NAME, + GRADLE_PUBLISH_TASK_NAME); + + assertTaskOutcomes(result3, YARN_SUB_PROJECT_NAME, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, + IGNORED, SUCCESS, SUCCESS, SUCCESS, IGNORED, SUCCESS, SUCCESS, SUCCESS); + + assertTaskOutcomes(result3, NPM_SUB_PROJECT_NAME, SKIPPED, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, IGNORED, + SUCCESS, SUCCESS, SUCCESS, IGNORED, SUCCESS, SUCCESS, SUCCESS); + + assertTaskOutcomes(result3, PNPM_SUB_PROJECT_NAME, SKIPPED, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, IGNORED, + SUCCESS, SUCCESS, SUCCESS, IGNORED, SUCCESS, SUCCESS, SUCCESS); + + assertTaskOutcomes(result3, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, IGNORED, + IGNORED, IGNORED, IGNORED, IGNORED); + } +} diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/PublishFrontendTaskFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/PublishFrontendTaskFuncTest.java similarity index 77% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/PublishFrontendTaskFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/PublishFrontendTaskFuncTest.java index ddc369bf..9316a3e2 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/PublishFrontendTaskFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/PublishFrontendTaskFuncTest.java @@ -43,8 +43,8 @@ void setUp() throws IOException { @Test void should_skip_plugin_task_when_package_json_file_does_not_exist() throws IOException { final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .assembleScript("run assemble") .publishScript("run publish") .packageJsonDirectory(packageJsonDirectoryPath); @@ -52,55 +52,55 @@ void should_skip_plugin_task_when_package_json_file_does_not_exist() throws IOEx final BuildResult result1 = runGradle(projectDirectoryPath, PUBLISH_TASK_NAME); - assertPublishTaskOutcomes(result1, SUCCESS, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null); + assertPublishTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null); final BuildResult result2 = runGradle(projectDirectoryPath, PUBLISH_TASK_NAME); - assertPublishTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null); + assertPublishTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null); } @Test void should_skip_plugin_task_when_script_is_not_defined() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), packageJsonDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .packageJsonDirectory(packageJsonDirectoryPath); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, PUBLISH_TASK_NAME); - assertPublishTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null); + assertPublishTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null); final BuildResult result2 = runGradle(projectDirectoryPath, PUBLISH_TASK_NAME); - assertPublishTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null); + assertPublishTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null); } @Test void should_skip_plugin_task_when_running_gradle_task_and_script_is_not_defined() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), packageJsonDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .packageJsonDirectory(packageJsonDirectoryPath); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_PUBLISH_TASK_NAME); - assertPublishTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, UP_TO_DATE); + assertPublishTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SKIPPED, UP_TO_DATE); final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_PUBLISH_TASK_NAME); - assertPublishTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE); + assertPublishTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE); } @Test void should_publish_frontend() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), packageJsonDirectoryPath.resolve("package.json")); final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .packageJsonDirectory(packageJsonDirectoryPath) .assembleScript("run assemble") .publishScript("run publish"); @@ -108,10 +108,10 @@ void should_publish_frontend() throws IOException { final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_PUBLISH_TASK_NAME); - assertPublishTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS); + assertPublishTaskOutcomes(result1, SUCCESS, SKIPPED, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS); final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_PUBLISH_TASK_NAME); - assertPublishTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS); + assertPublishTaskOutcomes(result2, UP_TO_DATE, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS); } } diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/ResolvePackageManagerTaskFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/ResolvePackageManagerTaskFuncTest.java similarity index 92% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/ResolvePackageManagerTaskFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/ResolvePackageManagerTaskFuncTest.java index b53b993e..ada47290 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/ResolvePackageManagerTaskFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/ResolvePackageManagerTaskFuncTest.java @@ -11,6 +11,7 @@ import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle; import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradleAndExpectFailure; import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.FAILED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.IGNORED; import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SKIPPED; import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SUCCESS; import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.UP_TO_DATE; @@ -54,13 +55,13 @@ void should_delete_output_files_when_package_json_file_does_not_exist() throws I final BuildResult result1 = runGradle(projectDirectoryPath, RESOLVE_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(result1, SKIPPED, SUCCESS); + assertTaskOutcomes(result1, SKIPPED, IGNORED, SUCCESS); assertThat(packageManagerSpecificationFilePath).doesNotExist(); assertThat(packageManagerExecutablePathFilePath).doesNotExist(); final BuildResult result2 = runGradle(projectDirectoryPath, RESOLVE_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(result2, SKIPPED, UP_TO_DATE); + assertTaskOutcomes(result2, SKIPPED, IGNORED, UP_TO_DATE); assertThat(packageManagerSpecificationFilePath).doesNotExist(); assertThat(packageManagerExecutablePathFilePath).doesNotExist(); } @@ -75,7 +76,7 @@ void should_fail_when_package_manager_property_is_not_set_in_package_json_file() final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RESOLVE_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(result, SKIPPED, FAILED); + assertTaskOutcomes(result, SKIPPED, IGNORED, FAILED); assertThat(projectDirectoryPath.resolve( Paths.get(DEFAULT_CACHE_DIRECTORY_NAME, RESOLVE_PACKAGE_MANAGER_TASK_NAME, PACKAGE_MANAGER_SPECIFICATION_FILE_NAME))).doesNotExist(); @@ -94,7 +95,7 @@ void should_fail_when_package_manager_property_is_invalid_in_package_json_file() final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RESOLVE_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(result, SKIPPED, FAILED); + assertTaskOutcomes(result, SKIPPED, IGNORED, FAILED); assertThat(projectDirectoryPath.resolve( Paths.get(DEFAULT_CACHE_DIRECTORY_NAME, RESOLVE_PACKAGE_MANAGER_TASK_NAME, PACKAGE_MANAGER_SPECIFICATION_FILE_NAME))).doesNotExist(); @@ -107,13 +108,13 @@ void should_fail_when_package_manager_property_is_invalid_in_package_json_file() void should_pass_when_package_manager_property_is_valid() throws IOException { Files.copy(getResourcePath("package-any-manager.json"), projectDirectoryPath.resolve("package.json")); createBuildFile(projectDirectoryPath, new FrontendMapBuilder() - .nodeVersion("18.17.1") - .nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip")) + .nodeVersion("20.14.0") + .nodeDistributionUrl(getResourceUrl("node-v20.14.0.zip")) .toMap()); final BuildResult result1 = runGradle(projectDirectoryPath, RESOLVE_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(result1, SUCCESS, SUCCESS); + assertTaskOutcomes(result1, SUCCESS, IGNORED, SUCCESS); final Path packageManagerNameFilePath = projectDirectoryPath.resolve( Paths.get(DEFAULT_CACHE_DIRECTORY_NAME, RESOLVE_PACKAGE_MANAGER_TASK_NAME, PACKAGE_MANAGER_SPECIFICATION_FILE_NAME)); @@ -125,7 +126,7 @@ void should_pass_when_package_manager_property_is_valid() throws IOException { final BuildResult result2 = runGradle(projectDirectoryPath, RESOLVE_PACKAGE_MANAGER_TASK_NAME); - assertTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE); + assertTaskOutcomes(result2, UP_TO_DATE, IGNORED, UP_TO_DATE); assertThat(packageManagerNameFilePath).content(StandardCharsets.UTF_8).isEqualTo("npm@9.6.7"); assertThat(packageManagerExecutablePathFilePath).exists(); } diff --git a/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithDownloadedDistributionsFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithDownloadedDistributionsFuncTest.java new file mode 100644 index 00000000..06d5c9dd --- /dev/null +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithDownloadedDistributionsFuncTest.java @@ -0,0 +1,150 @@ +package org.siouan.frontendgradleplugin.infrastructure.gradle; + +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_NODE_TASK_NAME; +import static org.siouan.frontendgradleplugin.infrastructure.gradle.InstallCorepackTask.LATEST_VERSION_ARGUMENT; +import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskOutcomes; +import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile; +import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SUCCESS; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.UP_TO_DATE; +import static org.siouan.frontendgradleplugin.test.Resources.getResourcePath; +import static org.siouan.frontendgradleplugin.test.TaskTypes.buildCorepackTaskDefinition; +import static org.siouan.frontendgradleplugin.test.TaskTypes.buildNodeTaskDefinition; +import static org.siouan.frontendgradleplugin.test.TaskTypes.buildNpmTaskDefinition; +import static org.siouan.frontendgradleplugin.test.TaskTypes.buildPnpmTaskDefinition; +import static org.siouan.frontendgradleplugin.test.TaskTypes.buildYarnTaskDefinition; +import static org.siouan.frontendgradleplugin.test.TaskTypes.createJavascriptFile; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.Set; + +import org.gradle.testkit.runner.BuildResult; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.siouan.frontendgradleplugin.test.FrontendMapBuilder; + +/** + * Functional tests to verify task types {@link RunNode}, {@link RunNpm}, {@link RunPnpm}, {@link RunYarn} in a Gradle + * build, with a downloaded Node.js distribution. + */ +class TaskTypesWithDownloadedDistributionsFuncTest { + + private static final String RUN_COREPACK_TASK_NAME = "customCorepackTask"; + + private static final String RUN_NODE_TASK_NAME = "customNodeTask"; + + private static final String RUN_NPM_TASK_NAME = "customNpmTask"; + + private static final String RUN_PNPM_TASK_NAME = "customPnpmTask"; + + private static final String RUN_YARN_TASK_NAME = "customYarnTask"; + + @TempDir + Path temporaryDirectoryPath; + + private Path projectDirectoryPath; + + @BeforeEach + void setUp() { + projectDirectoryPath = temporaryDirectoryPath; + } + + @Test + void should_run_custom_tasks() throws IOException { + final Path packageJsonDirectoryPath = Files.createDirectory(projectDirectoryPath.resolve("frontend")); + Files.copy(getResourcePath("package-npm.json"), packageJsonDirectoryPath.resolve("package.json")); + final Path temporaryScriptPath = createJavascriptFile(temporaryDirectoryPath.resolve("script.js")); + final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() + .nodeVersion("20.14.0") + .nodeInstallDirectory(projectDirectoryPath.resolve("node-dist")) + .corepackVersion(LATEST_VERSION_ARGUMENT) + .packageJsonDirectory(packageJsonDirectoryPath) + .verboseModeEnabled(false); + final String runCorepackTaskDefinition = buildCorepackTaskDefinition(RUN_COREPACK_TASK_NAME, "-v"); + final String runNodeTaskDefinition = buildNodeTaskDefinition(RUN_NODE_TASK_NAME, + temporaryScriptPath.toString().replace("\\", "\\\\")); + final String runNpmTaskDefinition = buildNpmTaskDefinition(RUN_NPM_TASK_NAME, INSTALL_FRONTEND_TASK_NAME, + "run another-script"); + final String runPnpmTaskDefinition = buildPnpmTaskDefinition(RUN_PNPM_TASK_NAME, INSTALL_FRONTEND_TASK_NAME, + "run another-script"); + final String runYarnTaskDefinition = buildYarnTaskDefinition(RUN_YARN_TASK_NAME, + Set.of(INSTALL_NODE_TASK_NAME, INSTALL_FRONTEND_TASK_NAME), "run another-script"); + final String additionalContent = String.join("\n", runCorepackTaskDefinition, runNodeTaskDefinition, + runNpmTaskDefinition, runPnpmTaskDefinition, runYarnTaskDefinition); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), additionalContent); + + final BuildResult runNodeTaskResult1 = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); + + assertTaskOutcomes(runNodeTaskResult1, SUCCESS, RUN_NODE_TASK_NAME, SUCCESS); + + final BuildResult runNodeTaskResult2 = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); + + assertTaskOutcomes(runNodeTaskResult2, UP_TO_DATE, RUN_NODE_TASK_NAME, SUCCESS); + + final BuildResult runCorepackTaskResult1 = runGradle(projectDirectoryPath, RUN_COREPACK_TASK_NAME); + + assertTaskOutcomes(runCorepackTaskResult1, UP_TO_DATE, SUCCESS, RUN_COREPACK_TASK_NAME, SUCCESS); + + final BuildResult runNpmTaskResult1 = runGradle(projectDirectoryPath, RUN_NPM_TASK_NAME); + + assertTaskOutcomes(runNpmTaskResult1, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS, RUN_NPM_TASK_NAME, + SUCCESS); + + final BuildResult runNpmTaskResult2 = runGradle(projectDirectoryPath, RUN_NPM_TASK_NAME); + + assertTaskOutcomes(runNpmTaskResult2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, + RUN_NPM_TASK_NAME, SUCCESS); + + Files.deleteIfExists(projectDirectoryPath.resolve("package-lock.json")); + Files.copy(getResourcePath("package-pnpm.json"), packageJsonDirectoryPath.resolve("package.json"), + StandardCopyOption.REPLACE_EXISTING); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), additionalContent); + + final BuildResult runNodeTaskResult3 = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); + + assertTaskOutcomes(runNodeTaskResult3, UP_TO_DATE, RUN_NODE_TASK_NAME, SUCCESS); + + final BuildResult runCorepackTaskResult2 = runGradle(projectDirectoryPath, RUN_COREPACK_TASK_NAME); + + assertTaskOutcomes(runCorepackTaskResult2, UP_TO_DATE, UP_TO_DATE, RUN_COREPACK_TASK_NAME, SUCCESS); + + final BuildResult runPnpmTaskResult3 = runGradle(projectDirectoryPath, RUN_PNPM_TASK_NAME); + + assertTaskOutcomes(runPnpmTaskResult3, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS, RUN_PNPM_TASK_NAME, + SUCCESS); + + final BuildResult runPnpmTaskResult4 = runGradle(projectDirectoryPath, RUN_PNPM_TASK_NAME); + + assertTaskOutcomes(runPnpmTaskResult4, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, + RUN_PNPM_TASK_NAME, SUCCESS); + + Files.deleteIfExists(packageJsonDirectoryPath.resolve("package-lock.json")); + Files.copy(getResourcePath("package-yarn.json"), packageJsonDirectoryPath.resolve("package.json"), + StandardCopyOption.REPLACE_EXISTING); + frontendMapBuilder.verboseModeEnabled(false); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), additionalContent); + + final BuildResult runNodeTaskResult4 = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); + + assertTaskOutcomes(runNodeTaskResult4, UP_TO_DATE, RUN_NODE_TASK_NAME, SUCCESS); + + final BuildResult runCorepackTaskResult3 = runGradle(projectDirectoryPath, RUN_COREPACK_TASK_NAME); + + assertTaskOutcomes(runCorepackTaskResult3, UP_TO_DATE, UP_TO_DATE, RUN_COREPACK_TASK_NAME, SUCCESS); + + final BuildResult runYarnTaskResult1 = runGradle(projectDirectoryPath, RUN_YARN_TASK_NAME); + + assertTaskOutcomes(runYarnTaskResult1, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS, RUN_YARN_TASK_NAME, + SUCCESS); + + final BuildResult runYarnTaskResult2 = runGradle(projectDirectoryPath, RUN_YARN_TASK_NAME); + + assertTaskOutcomes(runYarnTaskResult2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, + RUN_YARN_TASK_NAME, SUCCESS); + } +} diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithProvidedDistributionsFuncTest.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithProvidedDistributionsFuncTest.java similarity index 56% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithProvidedDistributionsFuncTest.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithProvidedDistributionsFuncTest.java index 0279c4c6..416e720f 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithProvidedDistributionsFuncTest.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/infrastructure/gradle/TaskTypesWithProvidedDistributionsFuncTest.java @@ -1,9 +1,17 @@ package org.siouan.frontendgradleplugin.infrastructure.gradle; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_PACKAGE_MANAGER_TASK_NAME; +import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskFailed; import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertTaskOutcomes; import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile; import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle; import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradleAndExpectFailure; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.FAILED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.IGNORED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SKIPPED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SUCCESS; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.UP_TO_DATE; import static org.siouan.frontendgradleplugin.test.Resources.getResourcePath; import static org.siouan.frontendgradleplugin.test.TaskTypes.buildCorepackTaskDefinition; import static org.siouan.frontendgradleplugin.test.TaskTypes.buildNodeTaskDefinition; @@ -19,9 +27,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -import org.siouan.frontendgradleplugin.FrontendGradlePlugin; import org.siouan.frontendgradleplugin.test.FrontendMapBuilder; -import org.siouan.frontendgradleplugin.test.PluginTaskOutcome; /** * Functional tests to verify task types {@link RunNode}, {@link RunNpm}, {@link RunYarn} in a Gradle build, with a @@ -59,13 +65,25 @@ void should_fail_running_custom_corepack_task_when_node_executable_does_not_exis final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() .nodeDistributionProvided(true) .nodeInstallDirectory(getResourcePath("node-dist-without-node")); - final String runCorepackTaskDefinition = buildCorepackTaskDefinition(RUN_COREPACK_TASK_NAME, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, "disable"); + final String runCorepackTaskDefinition = buildCorepackTaskDefinition(RUN_COREPACK_TASK_NAME, "disable"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), runCorepackTaskDefinition); final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_COREPACK_TASK_NAME); - assertTaskOutcomes(result, PluginTaskOutcome.SKIPPED, RUN_COREPACK_TASK_NAME, PluginTaskOutcome.FAILED); + assertTaskOutcomes(result, SKIPPED, RUN_COREPACK_TASK_NAME, FAILED); + } + + @Test + void should_fail_running_custom_corepack_task_when_script_is_undefined() throws IOException { + final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() + .nodeDistributionProvided(true) + .nodeInstallDirectory(getResourcePath("node-dist-provided")); + final String runCorepackTaskDefinition = buildCorepackTaskDefinition(RUN_COREPACK_TASK_NAME, null); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), runCorepackTaskDefinition); + + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_COREPACK_TASK_NAME); + + assertTaskOutcomes(result, SKIPPED, RUN_COREPACK_TASK_NAME, FAILED); } @Test @@ -79,7 +97,20 @@ void should_fail_running_custom_node_task_when_node_executable_does_not_exist() final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_NODE_TASK_NAME); - assertTaskOutcomes(result, PluginTaskOutcome.SKIPPED, RUN_NODE_TASK_NAME, PluginTaskOutcome.FAILED); + assertTaskOutcomes(result, SKIPPED, RUN_NODE_TASK_NAME, FAILED); + } + + @Test + void should_fail_running_custom_node_task_when_script_is_undefined() throws IOException { + final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() + .nodeDistributionProvided(true) + .nodeInstallDirectory(getResourcePath("node-dist-provided")); + final String runNodeTaskDefinition = buildNodeTaskDefinition(RUN_NODE_TASK_NAME, null); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), runNodeTaskDefinition); + + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_NODE_TASK_NAME); + + assertTaskFailed(result, RUN_NODE_TASK_NAME); } @Test @@ -88,14 +119,26 @@ void should_fail_running_custom_npm_task_when_node_executable_does_not_exist() t final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() .nodeDistributionProvided(true) .nodeInstallDirectory(getResourcePath("node-dist-without-node")); - final String runNpmTaskDefinition = buildNpmTaskDefinition(RUN_NPM_TASK_NAME, - FrontendGradlePlugin.INSTALL_PACKAGE_MANAGER_TASK_NAME, "run npm-script"); + final String runNpmTaskDefinition = buildNpmTaskDefinition(RUN_NPM_TASK_NAME, INSTALL_PACKAGE_MANAGER_TASK_NAME, + "run npm-script"); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), runNpmTaskDefinition); + + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_NPM_TASK_NAME); + + assertTaskOutcomes(result, SKIPPED, SKIPPED, SUCCESS, FAILED, RUN_NPM_TASK_NAME, IGNORED); + } + + @Test + void should_fail_running_custom_npm_task_when_script_is_undefined() throws IOException { + final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() + .nodeDistributionProvided(true) + .nodeInstallDirectory(getResourcePath("node-dist-provided")); + final String runNpmTaskDefinition = buildNpmTaskDefinition(RUN_NPM_TASK_NAME, null); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), runNpmTaskDefinition); final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_NPM_TASK_NAME); - assertTaskOutcomes(result, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.FAILED, - RUN_NPM_TASK_NAME, PluginTaskOutcome.IGNORED); + assertTaskFailed(result, RUN_NPM_TASK_NAME); } @Test @@ -105,13 +148,25 @@ void should_fail_running_custom_pnpm_task_when_node_executable_does_not_exist() .nodeDistributionProvided(true) .nodeInstallDirectory(getResourcePath("node-dist-without-node")); final String runNpmTaskDefinition = buildPnpmTaskDefinition(RUN_PNPM_TASK_NAME, - FrontendGradlePlugin.INSTALL_PACKAGE_MANAGER_TASK_NAME, "run pnpm-script"); + INSTALL_PACKAGE_MANAGER_TASK_NAME, "run pnpm-script"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), runNpmTaskDefinition); final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_PNPM_TASK_NAME); - assertTaskOutcomes(result, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.FAILED, - RUN_PNPM_TASK_NAME, PluginTaskOutcome.IGNORED); + assertTaskOutcomes(result, SKIPPED, SKIPPED, SUCCESS, FAILED, RUN_PNPM_TASK_NAME, IGNORED); + } + + @Test + void should_fail_running_custom_pnpm_task_when_script_is_undefined() throws IOException { + final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() + .nodeDistributionProvided(true) + .nodeInstallDirectory(getResourcePath("node-dist-provided")); + final String runPnpmTaskDefinition = buildPnpmTaskDefinition(RUN_PNPM_TASK_NAME, null); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), runPnpmTaskDefinition); + + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_PNPM_TASK_NAME); + + assertTaskFailed(result, RUN_PNPM_TASK_NAME); } @Test @@ -121,13 +176,25 @@ void should_fail_running_custom_yarn_task_when_node_executable_does_not_exist() .nodeDistributionProvided(true) .nodeInstallDirectory(getResourcePath("node-dist-without-node")); final String runNpmTaskDefinition = buildYarnTaskDefinition(RUN_YARN_TASK_NAME, - FrontendGradlePlugin.INSTALL_PACKAGE_MANAGER_TASK_NAME, "run yarn-script"); + INSTALL_PACKAGE_MANAGER_TASK_NAME, "run yarn-script"); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), runNpmTaskDefinition); final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_YARN_TASK_NAME); - assertTaskOutcomes(result, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.FAILED, - RUN_YARN_TASK_NAME, PluginTaskOutcome.IGNORED); + assertTaskOutcomes(result, SKIPPED, SKIPPED, SUCCESS, FAILED, RUN_YARN_TASK_NAME, IGNORED); + } + + @Test + void should_fail_running_custom_yarn_task_when_script_is_undefined() throws IOException { + final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder() + .nodeDistributionProvided(true) + .nodeInstallDirectory(getResourcePath("node-dist-provided")); + final String customTaskDefinition = buildYarnTaskDefinition(RUN_YARN_TASK_NAME, null); + createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), customTaskDefinition); + + final BuildResult result = runGradleAndExpectFailure(projectDirectoryPath, RUN_YARN_TASK_NAME); + + assertTaskFailed(result, RUN_YARN_TASK_NAME); } @Test @@ -138,40 +205,37 @@ void should_run_custom_tasks() throws IOException { .nodeInstallDirectory(getResourcePath("node-dist-provided")); final String runNodeTaskDefinition = buildNodeTaskDefinition(RUN_NODE_TASK_NAME, temporaryScriptPath.toString().replace("\\", "\\\\")); - final String runCorepackTaskDefinition = buildCorepackTaskDefinition(RUN_COREPACK_TASK_NAME, - FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, "disable"); - final String runNpmTaskDefinition = buildNpmTaskDefinition(RUN_NPM_TASK_NAME, - FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME, "run npm-script"); - final String runPnpmTaskDefinition = buildPnpmTaskDefinition(RUN_PNPM_TASK_NAME, - FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME, "run pnpm-script"); - final String runYarnTaskDefinition = buildYarnTaskDefinition(RUN_YARN_TASK_NAME, - FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME, "run yarn-script"); + final String runCorepackTaskDefinition = buildCorepackTaskDefinition(RUN_COREPACK_TASK_NAME, "disable"); + final String runNpmTaskDefinition = buildNpmTaskDefinition(RUN_NPM_TASK_NAME, INSTALL_FRONTEND_TASK_NAME, + "run npm-script"); + final String runPnpmTaskDefinition = buildPnpmTaskDefinition(RUN_PNPM_TASK_NAME, INSTALL_FRONTEND_TASK_NAME, + "run pnpm-script"); + final String runYarnTaskDefinition = buildYarnTaskDefinition(RUN_YARN_TASK_NAME, INSTALL_FRONTEND_TASK_NAME, + "run yarn-script"); final String additionalContent = String.join("\n", runNodeTaskDefinition, runCorepackTaskDefinition, runNpmTaskDefinition, runPnpmTaskDefinition, runYarnTaskDefinition); createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap(), additionalContent); final BuildResult nodeTaskResult = runGradle(projectDirectoryPath, RUN_NODE_TASK_NAME); - assertTaskOutcomes(nodeTaskResult, PluginTaskOutcome.SKIPPED, RUN_NODE_TASK_NAME, PluginTaskOutcome.SUCCESS); + assertTaskOutcomes(nodeTaskResult, SKIPPED, RUN_NODE_TASK_NAME, SUCCESS); final BuildResult corepackTaskResult = runGradle(projectDirectoryPath, RUN_COREPACK_TASK_NAME); - assertTaskOutcomes(corepackTaskResult, PluginTaskOutcome.SKIPPED, RUN_COREPACK_TASK_NAME, - PluginTaskOutcome.SUCCESS); + assertTaskOutcomes(corepackTaskResult, SKIPPED, SKIPPED, RUN_COREPACK_TASK_NAME, SUCCESS); final BuildResult npmTaskResult = runGradle(projectDirectoryPath, RUN_NPM_TASK_NAME); - assertTaskOutcomes(npmTaskResult, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SUCCESS, - PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, RUN_NPM_TASK_NAME, PluginTaskOutcome.SUCCESS); + assertTaskOutcomes(npmTaskResult, SKIPPED, SKIPPED, SUCCESS, SUCCESS, SUCCESS, RUN_NPM_TASK_NAME, SUCCESS); final BuildResult pnpmTaskResult = runGradle(projectDirectoryPath, RUN_PNPM_TASK_NAME); - assertTaskOutcomes(pnpmTaskResult, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, RUN_PNPM_TASK_NAME, PluginTaskOutcome.SUCCESS); + assertTaskOutcomes(pnpmTaskResult, SKIPPED, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, RUN_PNPM_TASK_NAME, + SUCCESS); final BuildResult yarnTaskResult = runGradle(projectDirectoryPath, RUN_YARN_TASK_NAME); - assertTaskOutcomes(yarnTaskResult, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.UP_TO_DATE, - PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, RUN_YARN_TASK_NAME, PluginTaskOutcome.SUCCESS); + assertTaskOutcomes(yarnTaskResult, SKIPPED, SKIPPED, UP_TO_DATE, UP_TO_DATE, SUCCESS, RUN_YARN_TASK_NAME, + SUCCESS); } } diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/FrontendMapBuilder.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/FrontendMapBuilder.java similarity index 95% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/FrontendMapBuilder.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/FrontendMapBuilder.java index 76ba60ed..92d00f9c 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/FrontendMapBuilder.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/FrontendMapBuilder.java @@ -24,6 +24,8 @@ public final class FrontendMapBuilder { private Path nodeInstallDirectory; + private String corepackVersion; + private String installScript; private String cleanScript; @@ -88,6 +90,11 @@ public FrontendMapBuilder nodeInstallDirectory(final Path nodeInstallDirectory) return this; } + public FrontendMapBuilder corepackVersion(final String corepackVersion) { + this.corepackVersion = corepackVersion; + return this; + } + public FrontendMapBuilder installScript(final String installScript) { this.installScript = installScript; return this; @@ -166,6 +173,9 @@ public Map toMap() { if (nodeInstallDirectory != null) { properties.put("nodeInstallDirectory", nodeInstallDirectory); } + if (corepackVersion != null) { + properties.put("corepackVersion", corepackVersion); + } if (installScript != null) { properties.put("installScript", installScript); } diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/GradleBuildAssertions.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/GradleBuildAssertions.java similarity index 55% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/GradleBuildAssertions.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/GradleBuildAssertions.java index c8cf749e..bcc8e03f 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/GradleBuildAssertions.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/GradleBuildAssertions.java @@ -1,6 +1,21 @@ package org.siouan.frontendgradleplugin.test; import static org.assertj.core.api.Assertions.assertThat; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.ASSEMBLE_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.CHECK_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.CLEAN_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.GRADLE_PUBLISH_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_COREPACK_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_NODE_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_PACKAGE_MANAGER_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.PUBLISH_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.RESOLVE_PACKAGE_MANAGER_TASK_NAME; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.FAILED; +import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.IGNORED; import java.util.HashMap; import java.util.List; @@ -11,144 +26,158 @@ import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.BuildTask; import org.gradle.testkit.runner.TaskOutcome; -import org.siouan.frontendgradleplugin.FrontendGradlePlugin; /** * Class providing assertions for Gradle builds. */ public final class GradleBuildAssertions { - private static final List TASK_NAMES = List.of(FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, - FrontendGradlePlugin.RESOLVE_PACKAGE_MANAGER_TASK_NAME, FrontendGradlePlugin.INSTALL_PACKAGE_MANAGER_TASK_NAME, - FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME, FrontendGradlePlugin.CLEAN_TASK_NAME, - FrontendGradlePlugin.ASSEMBLE_TASK_NAME, FrontendGradlePlugin.CHECK_TASK_NAME, - FrontendGradlePlugin.PUBLISH_TASK_NAME, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME, - FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME, - FrontendGradlePlugin.GRADLE_PUBLISH_TASK_NAME); + private static final List TASK_NAMES = List.of(INSTALL_NODE_TASK_NAME, INSTALL_COREPACK_TASK_NAME, + RESOLVE_PACKAGE_MANAGER_TASK_NAME, INSTALL_PACKAGE_MANAGER_TASK_NAME, INSTALL_FRONTEND_TASK_NAME, + CLEAN_TASK_NAME, ASSEMBLE_TASK_NAME, CHECK_TASK_NAME, PUBLISH_TASK_NAME, GRADLE_CLEAN_TASK_NAME, + GRADLE_ASSEMBLE_TASK_NAME, GRADLE_CHECK_TASK_NAME, GRADLE_PUBLISH_TASK_NAME); private GradleBuildAssertions() { } public static void assertAssembleTaskOutcomes(final BuildResult result, - final PluginTaskOutcome installNodeTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installNodeTaskOutcome, final PluginTaskOutcome installCorepackTaskOutcome, + final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final PluginTaskOutcome installFrontendTaskOutcome, final PluginTaskOutcome assembleTaskOutcome, final PluginTaskOutcome gradleAssembleTaskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, assembleTaskOutcome, null, null, null, - gradleAssembleTaskOutcome, null, null, null, null); + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, + assembleTaskOutcome, null, null, null, gradleAssembleTaskOutcome, null, null, null, null); } public static void assertCheckTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, - final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installCorepackTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final PluginTaskOutcome installFrontendTaskOutcome, final PluginTaskOutcome checkTaskOutcome, final PluginTaskOutcome gradleCheckTaskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, null, checkTaskOutcome, null, null, - null, gradleCheckTaskOutcome, null, null, null); + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, null, + checkTaskOutcome, null, null, null, gradleCheckTaskOutcome, null, null, null); } public static void assertCleanTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, - final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installCorepackTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final PluginTaskOutcome installFrontendTaskOutcome, final PluginTaskOutcome cleanTaskOutcome, final PluginTaskOutcome gradleCleanTaskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, installFrontendTaskOutcome, cleanTaskOutcome, null, null, null, - gradleCleanTaskOutcome, null, null, null, null, null); + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, installFrontendTaskOutcome, + cleanTaskOutcome, null, null, null, gradleCleanTaskOutcome, null, null, null, null, null); } public static void assertPublishTaskOutcomes(final BuildResult result, - final PluginTaskOutcome installNodeTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installNodeTaskOutcome, final PluginTaskOutcome installCorepackTaskOutcome, + final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final PluginTaskOutcome installFrontendTaskOutcome, final PluginTaskOutcome publishTaskOutcome, final PluginTaskOutcome gradlePublishTaskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, null, null, publishTaskOutcome, null, - null, null, gradlePublishTaskOutcome, null, null); + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, null, + null, publishTaskOutcome, null, null, null, gradlePublishTaskOutcome, null, null); } public static void assertTaskFailed(final BuildResult result, final String taskName) { - assertTaskOutcomes(result, null, null, null, null, null, null, null, null, null, null, null, null, null, - taskName, PluginTaskOutcome.FAILED); + assertTaskOutcomes(result, null, null, null, null, null, null, null, null, null, null, null, null, null, null, + taskName, FAILED); } public static void assertTaskOutcome(final BuildResult result, final String taskName, final PluginTaskOutcome taskOutcome) { - assertTaskOutcomes(result, null, null, null, null, null, null, null, null, null, null, null, null, null, + assertTaskOutcomes(result, null, null, null, null, null, null, null, null, null, null, null, null, null, null, taskName, taskOutcome); } public static void assertTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, final String taskName, final PluginTaskOutcome taskOutcome) { assertTaskOutcomes(result, null, installNodeTaskOutcome, null, null, null, null, null, null, null, null, null, - null, null, taskName, taskOutcome); + null, null, null, taskName, taskOutcome); } public static void assertTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, - final PluginTaskOutcome resolvePackageManagerTaskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, null, null, null, + final PluginTaskOutcome installCorepackTaskOutcome, final String taskName, + final PluginTaskOutcome taskOutcome) { + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, null, null, null, null, + null, null, null, null, null, null, null, taskName, taskOutcome); + } + + public static void assertTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, + final PluginTaskOutcome installCorepackTaskOutcome) { + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, null, null, null, null, null, null, null, null, null, null, null, null, null); } public static void assertTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, - final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installCorepackTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome) { + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, null, null, null, null, null, null, null, null, null, null, null, null); + } + + public static void assertTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, + final PluginTaskOutcome installCorepackTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, null, null, null, null, null, null, null, null, null, null, null); + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, null, null, null, null, null, null, + null, null, null, null, null); } public static void assertTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, - final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installCorepackTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final String taskName, final PluginTaskOutcome taskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, null, null, null, null, null, null, null, null, null, taskName, - taskOutcome); + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, null, null, null, null, null, null, + null, null, null, taskName, taskOutcome); } public static void assertTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, - final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installCorepackTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final PluginTaskOutcome installFrontendTaskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, null, null, null, null, null, null, - null, null, null); + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, null, + null, null, null, null, null, null, null, null); } public static void assertTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, - final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installCorepackTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final PluginTaskOutcome installFrontendTaskOutcome, final String taskName, final PluginTaskOutcome taskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, null, null, null, null, null, null, - null, taskName, taskOutcome); + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, installFrontendTaskOutcome, null, null, + null, null, null, null, null, null, taskName, taskOutcome); } public static void assertTaskOutcomes(final BuildResult result, final PluginTaskOutcome installNodeTaskOutcome, - final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installCorepackTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final PluginTaskOutcome installFrontendTaskOutcome, final PluginTaskOutcome cleanTaskOutcome, final PluginTaskOutcome assembleTaskOutcome, final PluginTaskOutcome checkTaskOutcome, final PluginTaskOutcome publishTaskOutcome, final PluginTaskOutcome gradleCleanTaskOutcome, final PluginTaskOutcome gradleAssembleTaskOutcome, final PluginTaskOutcome gradleCheckTaskOutcome, final PluginTaskOutcome gradlePublishTaskOutcome) { - assertTaskOutcomes(result, null, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, installFrontendTaskOutcome, cleanTaskOutcome, assembleTaskOutcome, - checkTaskOutcome, publishTaskOutcome, gradleCleanTaskOutcome, gradleAssembleTaskOutcome, - gradleCheckTaskOutcome, gradlePublishTaskOutcome, null, null); + assertTaskOutcomes(result, null, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, installFrontendTaskOutcome, + cleanTaskOutcome, assembleTaskOutcome, checkTaskOutcome, publishTaskOutcome, gradleCleanTaskOutcome, + gradleAssembleTaskOutcome, gradleCheckTaskOutcome, gradlePublishTaskOutcome, null, null); } public static void assertTaskOutcomes(final BuildResult result, final String projectName, - final PluginTaskOutcome installNodeTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installNodeTaskOutcome, final PluginTaskOutcome installCorepackTaskOutcome, + final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final PluginTaskOutcome installFrontendTaskOutcome, final PluginTaskOutcome cleanTaskOutcome, final PluginTaskOutcome assembleTaskOutcome, final PluginTaskOutcome checkTaskOutcome, final PluginTaskOutcome publishTaskOutcome, final PluginTaskOutcome gradleCleanTaskOutcome, final PluginTaskOutcome gradleAssembleTaskOutcome, final PluginTaskOutcome gradleCheckTaskOutcome, final PluginTaskOutcome gradlePublishTaskOutcome) { - assertTaskOutcomes(result, projectName, installNodeTaskOutcome, resolvePackageManagerTaskOutcome, - installPackageManagerTaskOutcome, installFrontendTaskOutcome, cleanTaskOutcome, assembleTaskOutcome, - checkTaskOutcome, publishTaskOutcome, gradleCleanTaskOutcome, gradleAssembleTaskOutcome, - gradleCheckTaskOutcome, gradlePublishTaskOutcome, null, null); + assertTaskOutcomes(result, projectName, installNodeTaskOutcome, installCorepackTaskOutcome, + resolvePackageManagerTaskOutcome, installPackageManagerTaskOutcome, installFrontendTaskOutcome, + cleanTaskOutcome, assembleTaskOutcome, checkTaskOutcome, publishTaskOutcome, gradleCleanTaskOutcome, + gradleAssembleTaskOutcome, gradleCheckTaskOutcome, gradlePublishTaskOutcome, null, null); } public static void assertTaskOutcomes(final BuildResult result, final String projectName, - final PluginTaskOutcome installNodeTaskOutcome, final PluginTaskOutcome resolvePackageManagerTaskOutcome, + final PluginTaskOutcome installNodeTaskOutcome, final PluginTaskOutcome installCorepackTaskOutcome, + final PluginTaskOutcome resolvePackageManagerTaskOutcome, final PluginTaskOutcome installPackageManagerTaskOutcome, final PluginTaskOutcome installFrontendTaskOutcome, final PluginTaskOutcome cleanTaskOutcome, final PluginTaskOutcome assembleTaskOutcome, final PluginTaskOutcome checkTaskOutcome, final PluginTaskOutcome publishTaskOutcome, @@ -156,27 +185,26 @@ public static void assertTaskOutcomes(final BuildResult result, final String pro final PluginTaskOutcome gradleCheckTaskOutcome, final PluginTaskOutcome gradlePublishTaskOutcome, final String taskName, final PluginTaskOutcome taskOutcome) { final Map outcomeByTaskNames = new HashMap<>(); - outcomeByTaskNames.put(FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, installNodeTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.RESOLVE_PACKAGE_MANAGER_TASK_NAME, - resolvePackageManagerTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.INSTALL_PACKAGE_MANAGER_TASK_NAME, - installPackageManagerTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.INSTALL_FRONTEND_TASK_NAME, installFrontendTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.CLEAN_TASK_NAME, cleanTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.ASSEMBLE_TASK_NAME, assembleTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.CHECK_TASK_NAME, checkTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.PUBLISH_TASK_NAME, publishTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME, gradleCleanTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME, gradleAssembleTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME, gradleCheckTaskOutcome); - outcomeByTaskNames.put(FrontendGradlePlugin.GRADLE_PUBLISH_TASK_NAME, gradlePublishTaskOutcome); + outcomeByTaskNames.put(INSTALL_NODE_TASK_NAME, installNodeTaskOutcome); + outcomeByTaskNames.put(INSTALL_COREPACK_TASK_NAME, installCorepackTaskOutcome); + outcomeByTaskNames.put(RESOLVE_PACKAGE_MANAGER_TASK_NAME, resolvePackageManagerTaskOutcome); + outcomeByTaskNames.put(INSTALL_PACKAGE_MANAGER_TASK_NAME, installPackageManagerTaskOutcome); + outcomeByTaskNames.put(INSTALL_FRONTEND_TASK_NAME, installFrontendTaskOutcome); + outcomeByTaskNames.put(CLEAN_TASK_NAME, cleanTaskOutcome); + outcomeByTaskNames.put(ASSEMBLE_TASK_NAME, assembleTaskOutcome); + outcomeByTaskNames.put(CHECK_TASK_NAME, checkTaskOutcome); + outcomeByTaskNames.put(PUBLISH_TASK_NAME, publishTaskOutcome); + outcomeByTaskNames.put(GRADLE_CLEAN_TASK_NAME, gradleCleanTaskOutcome); + outcomeByTaskNames.put(GRADLE_ASSEMBLE_TASK_NAME, gradleAssembleTaskOutcome); + outcomeByTaskNames.put(GRADLE_CHECK_TASK_NAME, gradleCheckTaskOutcome); + outcomeByTaskNames.put(GRADLE_PUBLISH_TASK_NAME, gradlePublishTaskOutcome); if (taskName != null) { outcomeByTaskNames.put(taskName, taskOutcome); } Stream.concat(TASK_NAMES.stream(), Stream.ofNullable(taskName)).forEach(aTaskName -> { final PluginTaskOutcome anOutcome = outcomeByTaskNames.get(aTaskName); if (anOutcome != null) { - if (anOutcome == PluginTaskOutcome.IGNORED) { + if (anOutcome == IGNORED) { assertTaskIgnored(result, aTaskName); } else { assertTaskOutcome(result, projectName, aTaskName, anOutcome.getNativeOutcome()); diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/GradleBuildFiles.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/GradleBuildFiles.java similarity index 100% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/GradleBuildFiles.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/GradleBuildFiles.java diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/GradleHelper.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/GradleHelper.java similarity index 100% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/GradleHelper.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/GradleHelper.java diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/GradleSettingsFiles.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/GradleSettingsFiles.java similarity index 100% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/GradleSettingsFiles.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/GradleSettingsFiles.java diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/PluginTaskOutcome.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/PluginTaskOutcome.java similarity index 100% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/PluginTaskOutcome.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/PluginTaskOutcome.java diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/ServerConfigurator.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/ServerConfigurator.java similarity index 98% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/ServerConfigurator.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/ServerConfigurator.java index 72fe4fef..4b18084a 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/ServerConfigurator.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/ServerConfigurator.java @@ -52,7 +52,7 @@ public void configure() throws IOException { mappingBuilder = get(urlPathMatching("^.*/node-v[^/]+$")); withAuth(mappingBuilder); server.stubFor(mappingBuilder.willReturn( - aResponse().withBody(Files.readAllBytes(getResourcePath("node-v18.17.1.zip"))))); + aResponse().withBody(Files.readAllBytes(getResourcePath("node-v20.14.0.zip"))))); mappingBuilder = get(urlPathMatching("^.*/SHASUMS256.txt$")); withAuth(mappingBuilder); diff --git a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/TaskTypes.java b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/TaskTypes.java similarity index 85% rename from plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/TaskTypes.java rename to plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/TaskTypes.java index fbc386e4..e97af167 100644 --- a/plugin/src/intTest/java/org/siouan/frontendgradleplugin/test/TaskTypes.java +++ b/plugin/src/integrationTest/java/org/siouan/frontendgradleplugin/test/TaskTypes.java @@ -1,12 +1,14 @@ package org.siouan.frontendgradleplugin.test; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_COREPACK_TASK_NAME; +import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.INSTALL_NODE_TASK_NAME; + import java.io.IOException; import java.io.Writer; import java.nio.file.Files; import java.nio.file.Path; import java.util.Set; -import org.siouan.frontendgradleplugin.FrontendGradlePlugin; import org.siouan.frontendgradleplugin.infrastructure.gradle.RunCorepack; import org.siouan.frontendgradleplugin.infrastructure.gradle.RunNode; import org.siouan.frontendgradleplugin.infrastructure.gradle.RunNpm; @@ -22,22 +24,11 @@ private TaskTypes() { } public static String buildCorepackTaskDefinition(final String taskName, final String script) { - return buildTaskDefinition(taskName, RunCorepack.class, Set.of(), script); - } - - public static String buildCorepackTaskDefinition(final String taskName, final String dependsOnTaskName, - final String script) { - return buildTaskDefinition(taskName, RunCorepack.class, Set.of(dependsOnTaskName), script); + return buildTaskDefinition(taskName, RunCorepack.class, Set.of(INSTALL_COREPACK_TASK_NAME), script); } public static String buildNodeTaskDefinition(final String taskName, final String script) { - return buildNodeTaskDefinition(taskName, FrontendGradlePlugin.INSTALL_NODE_TASK_NAME, script); - } - - public static String buildNodeTaskDefinition(final String taskName, final String dependsOnTaskName, - final String script) { - return buildTaskDefinition(taskName, RunNode.class, - (dependsOnTaskName == null) ? Set.of() : Set.of(dependsOnTaskName), script); + return buildTaskDefinition(taskName, RunNode.class, Set.of(INSTALL_NODE_TASK_NAME), script); } public static String buildNpmTaskDefinition(final String taskName, final String script) { diff --git a/plugin/src/intTest/resources/SHASUMS256.txt b/plugin/src/integrationTest/resources/SHASUMS256.txt similarity index 88% rename from plugin/src/intTest/resources/SHASUMS256.txt rename to plugin/src/integrationTest/resources/SHASUMS256.txt index 36c74754..7de72267 100644 --- a/plugin/src/intTest/resources/SHASUMS256.txt +++ b/plugin/src/integrationTest/resources/SHASUMS256.txt @@ -1,2 +1,2 @@ 8739c76e681f900923b900c9df0ef75cf421d39cabb54650c4b9ad19b6a76d85 node-v10.15.1.txt -c5b1eab3577b2b060caeedfb041098c9febddd6168164ace02845e6151710f30 node-v18.17.1.zip +c5b1eab3577b2b060caeedfb041098c9febddd6168164ace02845e6151710f30 node-v20.14.0.zip diff --git a/plugin/src/intTest/resources/node-dist-provided/bin/corepack b/plugin/src/integrationTest/resources/node-dist-provided/bin/corepack similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/bin/corepack rename to plugin/src/integrationTest/resources/node-dist-provided/bin/corepack diff --git a/plugin/src/intTest/resources/node-dist-provided/bin/node b/plugin/src/integrationTest/resources/node-dist-provided/bin/node similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/bin/node rename to plugin/src/integrationTest/resources/node-dist-provided/bin/node diff --git a/plugin/src/intTest/resources/node-dist-provided/bin/npm b/plugin/src/integrationTest/resources/node-dist-provided/bin/npm similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/bin/npm rename to plugin/src/integrationTest/resources/node-dist-provided/bin/npm diff --git a/plugin/src/intTest/resources/node-dist-provided/bin/npx b/plugin/src/integrationTest/resources/node-dist-provided/bin/npx similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/bin/npx rename to plugin/src/integrationTest/resources/node-dist-provided/bin/npx diff --git a/plugin/src/intTest/resources/node-dist-provided/bin/pnpm b/plugin/src/integrationTest/resources/node-dist-provided/bin/pnpm similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/bin/pnpm rename to plugin/src/integrationTest/resources/node-dist-provided/bin/pnpm diff --git a/plugin/src/intTest/resources/node-dist-provided/bin/pnpx b/plugin/src/integrationTest/resources/node-dist-provided/bin/pnpx similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/bin/pnpx rename to plugin/src/integrationTest/resources/node-dist-provided/bin/pnpx diff --git a/plugin/src/intTest/resources/node-dist-provided/bin/yarn b/plugin/src/integrationTest/resources/node-dist-provided/bin/yarn similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/bin/yarn rename to plugin/src/integrationTest/resources/node-dist-provided/bin/yarn diff --git a/plugin/src/intTest/resources/node-dist-provided/corepack.cmd b/plugin/src/integrationTest/resources/node-dist-provided/corepack.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/corepack.cmd rename to plugin/src/integrationTest/resources/node-dist-provided/corepack.cmd diff --git a/plugin/src/intTest/resources/node-dist-provided/node.exe b/plugin/src/integrationTest/resources/node-dist-provided/node.exe similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/node.exe rename to plugin/src/integrationTest/resources/node-dist-provided/node.exe diff --git a/plugin/src/intTest/resources/node-dist-provided/npm.cmd b/plugin/src/integrationTest/resources/node-dist-provided/npm.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/npm.cmd rename to plugin/src/integrationTest/resources/node-dist-provided/npm.cmd diff --git a/plugin/src/intTest/resources/node-dist-provided/npx.cmd b/plugin/src/integrationTest/resources/node-dist-provided/npx.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/npx.cmd rename to plugin/src/integrationTest/resources/node-dist-provided/npx.cmd diff --git a/plugin/src/intTest/resources/node-dist-provided/pnpm.cmd b/plugin/src/integrationTest/resources/node-dist-provided/pnpm.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/pnpm.cmd rename to plugin/src/integrationTest/resources/node-dist-provided/pnpm.cmd diff --git a/plugin/src/intTest/resources/node-dist-provided/pnpx.cmd b/plugin/src/integrationTest/resources/node-dist-provided/pnpx.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/pnpx.cmd rename to plugin/src/integrationTest/resources/node-dist-provided/pnpx.cmd diff --git a/plugin/src/intTest/resources/node-dist-provided/yarn.cmd b/plugin/src/integrationTest/resources/node-dist-provided/yarn.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-provided/yarn.cmd rename to plugin/src/integrationTest/resources/node-dist-provided/yarn.cmd diff --git a/plugin/src/intTest/resources/node-dist-without-node/bin/corepack b/plugin/src/integrationTest/resources/node-dist-without-node/bin/corepack similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/bin/corepack rename to plugin/src/integrationTest/resources/node-dist-without-node/bin/corepack diff --git a/plugin/src/intTest/resources/node-dist-without-node/bin/npm b/plugin/src/integrationTest/resources/node-dist-without-node/bin/npm similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/bin/npm rename to plugin/src/integrationTest/resources/node-dist-without-node/bin/npm diff --git a/plugin/src/intTest/resources/node-dist-without-node/bin/npx b/plugin/src/integrationTest/resources/node-dist-without-node/bin/npx similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/bin/npx rename to plugin/src/integrationTest/resources/node-dist-without-node/bin/npx diff --git a/plugin/src/intTest/resources/node-dist-without-node/bin/pnpm b/plugin/src/integrationTest/resources/node-dist-without-node/bin/pnpm similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/bin/pnpm rename to plugin/src/integrationTest/resources/node-dist-without-node/bin/pnpm diff --git a/plugin/src/intTest/resources/node-dist-without-node/bin/pnpx b/plugin/src/integrationTest/resources/node-dist-without-node/bin/pnpx similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/bin/pnpx rename to plugin/src/integrationTest/resources/node-dist-without-node/bin/pnpx diff --git a/plugin/src/intTest/resources/node-dist-without-node/bin/yarn b/plugin/src/integrationTest/resources/node-dist-without-node/bin/yarn similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/bin/yarn rename to plugin/src/integrationTest/resources/node-dist-without-node/bin/yarn diff --git a/plugin/src/intTest/resources/node-dist-without-node/corepack.cmd b/plugin/src/integrationTest/resources/node-dist-without-node/corepack.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/corepack.cmd rename to plugin/src/integrationTest/resources/node-dist-without-node/corepack.cmd diff --git a/plugin/src/intTest/resources/node-dist-without-node/npm.cmd b/plugin/src/integrationTest/resources/node-dist-without-node/npm.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/npm.cmd rename to plugin/src/integrationTest/resources/node-dist-without-node/npm.cmd diff --git a/plugin/src/intTest/resources/node-dist-without-node/npx.cmd b/plugin/src/integrationTest/resources/node-dist-without-node/npx.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/npx.cmd rename to plugin/src/integrationTest/resources/node-dist-without-node/npx.cmd diff --git a/plugin/src/intTest/resources/node-dist-without-node/pnpm.cmd b/plugin/src/integrationTest/resources/node-dist-without-node/pnpm.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/pnpm.cmd rename to plugin/src/integrationTest/resources/node-dist-without-node/pnpm.cmd diff --git a/plugin/src/intTest/resources/node-dist-without-node/pnpx.cmd b/plugin/src/integrationTest/resources/node-dist-without-node/pnpx.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/pnpx.cmd rename to plugin/src/integrationTest/resources/node-dist-without-node/pnpx.cmd diff --git a/plugin/src/intTest/resources/node-dist-without-node/yarn.cmd b/plugin/src/integrationTest/resources/node-dist-without-node/yarn.cmd similarity index 100% rename from plugin/src/intTest/resources/node-dist-without-node/yarn.cmd rename to plugin/src/integrationTest/resources/node-dist-without-node/yarn.cmd diff --git a/plugin/src/intTest/resources/node-v18.17.1.zip b/plugin/src/integrationTest/resources/node-v20.14.0.zip similarity index 100% rename from plugin/src/intTest/resources/node-v18.17.1.zip rename to plugin/src/integrationTest/resources/node-v20.14.0.zip diff --git a/plugin/src/intTest/resources/package-any-manager.json b/plugin/src/integrationTest/resources/package-any-manager.json similarity index 100% rename from plugin/src/intTest/resources/package-any-manager.json rename to plugin/src/integrationTest/resources/package-any-manager.json diff --git a/plugin/src/intTest/resources/package-invalid-manager.json b/plugin/src/integrationTest/resources/package-invalid-manager.json similarity index 100% rename from plugin/src/intTest/resources/package-invalid-manager.json rename to plugin/src/integrationTest/resources/package-invalid-manager.json diff --git a/plugin/src/intTest/resources/package-no-manager.json b/plugin/src/integrationTest/resources/package-no-manager.json similarity index 100% rename from plugin/src/intTest/resources/package-no-manager.json rename to plugin/src/integrationTest/resources/package-no-manager.json diff --git a/plugin/src/intTest/resources/package-npm.json b/plugin/src/integrationTest/resources/package-npm.json similarity index 100% rename from plugin/src/intTest/resources/package-npm.json rename to plugin/src/integrationTest/resources/package-npm.json diff --git a/plugin/src/intTest/resources/package-pnpm.json b/plugin/src/integrationTest/resources/package-pnpm.json similarity index 100% rename from plugin/src/intTest/resources/package-pnpm.json rename to plugin/src/integrationTest/resources/package-pnpm.json diff --git a/plugin/src/intTest/resources/package-yarn.json b/plugin/src/integrationTest/resources/package-yarn.json similarity index 100% rename from plugin/src/intTest/resources/package-yarn.json rename to plugin/src/integrationTest/resources/package-yarn.json diff --git a/plugin/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java b/plugin/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java index f7872f90..bf64a2af 100644 --- a/plugin/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java +++ b/plugin/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java @@ -41,6 +41,7 @@ import org.siouan.frontendgradleplugin.infrastructure.gradle.FrontendExtension; import org.siouan.frontendgradleplugin.infrastructure.gradle.GradleLoggerAdapter; import org.siouan.frontendgradleplugin.infrastructure.gradle.GradleSettings; +import org.siouan.frontendgradleplugin.infrastructure.gradle.InstallCorepackTask; import org.siouan.frontendgradleplugin.infrastructure.gradle.InstallFrontendTask; import org.siouan.frontendgradleplugin.infrastructure.gradle.InstallNodeTask; import org.siouan.frontendgradleplugin.infrastructure.gradle.InstallPackageManagerTask; @@ -163,6 +164,13 @@ public class FrontendGradlePlugin implements Plugin { */ public static final String PACKAGE_JSON_FILE_NAME = "package.json"; + /** + * Name of the task that installs a specific version of Corepack. + * + * @since 8.1.0 + */ + public static final String INSTALL_COREPACK_TASK_NAME = "installCorepack"; + /** * Name of the task that installs a Node distribution. */ @@ -255,7 +263,8 @@ protected Provider configureBeanRegistry(final Project return project .getGradle() .getSharedServices() - .registerIfAbsent(BEAN_REGISTRY_BUILD_SERVICE_NAME_PREFIX + project.getLayout().getProjectDirectory(), BeanRegistryBuildService.class, + .registerIfAbsent(BEAN_REGISTRY_BUILD_SERVICE_NAME_PREFIX + project.getLayout().getProjectDirectory(), + BeanRegistryBuildService.class, buildServiceSpec -> buildServiceSpec.getParameters().getBeanRegistry().set(beanRegistry)); } @@ -274,6 +283,9 @@ protected void configureTasks(final Project project, taskContainer.register(INSTALL_NODE_TASK_NAME, InstallNodeTask.class, task -> configureInstallNodeTask(task, beanRegistryBuildServiceProvider, frontendExtension, systemProviders)); + taskContainer.register(INSTALL_COREPACK_TASK_NAME, InstallCorepackTask.class, + task -> configureInstallCorepackTask(task, taskContainer, beanRegistryBuildServiceProvider, + frontendExtension, systemProviders)); taskContainer.register(RESOLVE_PACKAGE_MANAGER_TASK_NAME, ResolvePackageManagerTask.class, task -> configureResolvePackageManagerTask(task, taskContainer, beanRegistryBuildServiceProvider, frontendExtension, systemProviders)); @@ -386,6 +398,33 @@ protected void configureInstallNodeTask(final InstallNodeTask task, task.setOnlyIf(t -> !frontendExtension.getNodeDistributionProvided().get()); } + /** + * Configures the given task with the plugin extension. + * + * @param task Task. + * @param taskContainer Gradle task container. + * @param beanRegistryBuildServiceProvider Bean registry build service provider. + * @param frontendExtension Plugin extension. + */ + protected void configureInstallCorepackTask(final InstallCorepackTask task, final TaskContainer taskContainer, + final Provider beanRegistryBuildServiceProvider, + final FrontendExtension frontendExtension, final SystemProviders systemProviders) { + task.setGroup(TASK_GROUP); + task.setDescription( + "Installs a specific version of Corepack, overriding the one provided by default in Node.js distribution."); + task.getBeanRegistryBuildService().set(beanRegistryBuildServiceProvider); + task.usesService(beanRegistryBuildServiceProvider); + + task.getPackageJsonDirectory().set(frontendExtension.getPackageJsonDirectory().getAsFile()); + task.getNodeInstallDirectory().set(frontendExtension.getNodeInstallDirectory().getAsFile()); + task.getCorepackVersion().set(frontendExtension.getCorepackVersion()); + task.getVerboseModeEnabled().set(frontendExtension.getVerboseModeEnabled()); + bindSystemArchPropertiesToTaskInputs(systemProviders, task.getSystemJvmArch(), task.getSystemOsName()); + task.setOnlyIf(t -> frontendExtension.getCorepackVersion().isPresent()); + + configureDependency(taskContainer, task, INSTALL_NODE_TASK_NAME, InstallNodeTask.class); + } + /** * Configures the given task with the plugin extension. * @@ -480,6 +519,8 @@ protected void configureInstallPackageManagerTask(final InstallPackageManagerTas // The task is skipped when there's no package.json file. It allows to define a project that installs only a // Node.js distribution. task.setOnlyIf(t -> packageJsonFileExists(frontendExtension)); + + configureDependency(taskContainer, task, INSTALL_COREPACK_TASK_NAME, InstallCorepackTask.class); } /** diff --git a/plugin/src/main/java/org/siouan/frontendgradleplugin/domain/GetExecutablePath.java b/plugin/src/main/java/org/siouan/frontendgradleplugin/domain/GetExecutablePath.java index 405b44e9..2df33521 100644 --- a/plugin/src/main/java/org/siouan/frontendgradleplugin/domain/GetExecutablePath.java +++ b/plugin/src/main/java/org/siouan/frontendgradleplugin/domain/GetExecutablePath.java @@ -12,15 +12,15 @@ @RequiredArgsConstructor public class GetExecutablePath { - private final ResolveCorepackExecutablePath getCorepackExecutablePath; + private final ResolveCorepackExecutablePath resolveCorepackExecutablePath; - private final ResolveNodeExecutablePath getNodeExecutablePath; + private final ResolveNodeExecutablePath resolveNodeExecutablePath; - private final ResolveNpmExecutablePath getNpmExecutablePath; + private final ResolveNpmExecutablePath resolveNpmExecutablePath; - private final ResolvePnpmExecutablePath getPnpmExecutablePath; + private final ResolvePnpmExecutablePath resolvePnpmExecutablePath; - private final ResolveYarnExecutablePath getYarnExecutablePath; + private final ResolveYarnExecutablePath resolveYarnExecutablePath; /** * Resolves the path of the executable. @@ -36,11 +36,11 @@ public Path execute(final GetExecutablePathCommand command) { .nodeInstallDirectoryPath(command.getNodeInstallDirectoryPath()) .build(); return switch (command.getExecutableType()) { - case COREPACK -> getCorepackExecutablePath.execute(resolveExecutablePathCommand); - case NODE -> getNodeExecutablePath.execute(resolveExecutablePathCommand); - case NPM -> getNpmExecutablePath.execute(resolveExecutablePathCommand); - case PNPM -> getPnpmExecutablePath.execute(resolveExecutablePathCommand); - case YARN -> getYarnExecutablePath.execute(resolveExecutablePathCommand); + case COREPACK -> resolveCorepackExecutablePath.execute(resolveExecutablePathCommand); + case NODE -> resolveNodeExecutablePath.execute(resolveExecutablePathCommand); + case NPM -> resolveNpmExecutablePath.execute(resolveExecutablePathCommand); + case PNPM -> resolvePnpmExecutablePath.execute(resolveExecutablePathCommand); + case YARN -> resolveYarnExecutablePath.execute(resolveExecutablePathCommand); }; } } diff --git a/plugin/src/main/java/org/siouan/frontendgradleplugin/domain/installer/HashFile.java b/plugin/src/main/java/org/siouan/frontendgradleplugin/domain/installer/HashFile.java index d7084c5a..57e3f543 100644 --- a/plugin/src/main/java/org/siouan/frontendgradleplugin/domain/installer/HashFile.java +++ b/plugin/src/main/java/org/siouan/frontendgradleplugin/domain/installer/HashFile.java @@ -32,7 +32,7 @@ public class HashFile { private final MessageDigest messageDigest; /** - * Builds a hasher using the SHA-256 algorithm. + * Builds a hash service using the SHA-256 algorithm. * * @param channelProvider Channel provider. * @param convertToHexadecimalString Converter of byte buffer to hexadecimal string. diff --git a/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AbstractRunCommandTask.java b/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AbstractRunCommandTask.java index eed1b694..0eb4a2e6 100644 --- a/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AbstractRunCommandTask.java +++ b/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/AbstractRunCommandTask.java @@ -30,12 +30,13 @@ public abstract class AbstractRunCommandTask extends DefaultTask { protected final Property beanRegistryBuildService; /** - * Directory where the 'package.json' file is located. + * Directory where the 'package.json' file is located, and used as the working directory when the command is + * executed. */ protected final Property packageJsonDirectory; /** - * Directory where the Node.js distribution is installed. + * Directory where the Node.js distribution is installed, and used to find the executables. */ protected final Property nodeInstallDirectory; diff --git a/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/FrontendExtension.java b/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/FrontendExtension.java index a448457a..9040691d 100644 --- a/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/FrontendExtension.java +++ b/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/FrontendExtension.java @@ -87,6 +87,13 @@ public class FrontendExtension { */ private final DirectoryProperty packageJsonDirectory; + /** + * Version of Corepack. + * + * @since 8.1.0 + */ + private final Property corepackVersion; + /** * Proxy host used to download resources with HTTP protocol. * @@ -206,6 +213,7 @@ public FrontendExtension(final ObjectFactory objectFactory) { checkScript = objectFactory.property(String.class); publishScript = objectFactory.property(String.class); packageJsonDirectory = objectFactory.directoryProperty(); + corepackVersion = objectFactory.property(String.class); httpProxyHost = objectFactory.property(String.class); httpProxyPort = objectFactory.property(Integer.class); httpProxyUsername = objectFactory.property(String.class); diff --git a/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallCorepackTask.java b/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallCorepackTask.java new file mode 100644 index 00000000..72034780 --- /dev/null +++ b/plugin/src/main/java/org/siouan/frontendgradleplugin/infrastructure/gradle/InstallCorepackTask.java @@ -0,0 +1,82 @@ +package org.siouan.frontendgradleplugin.infrastructure.gradle; + +import javax.inject.Inject; + +import org.gradle.api.file.DirectoryProperty; +import org.gradle.api.model.ObjectFactory; +import org.gradle.api.provider.Property; +import org.gradle.api.tasks.Input; +import org.gradle.api.tasks.OutputDirectory; +import org.gradle.process.ExecOperations; +import org.siouan.frontendgradleplugin.domain.ExecutableType; +import org.siouan.frontendgradleplugin.infrastructure.bean.BeanRegistryException; + +/** + * This task installs a specific version of Corepack, which will override the default version embedded in the Node.js + * distribution (by executing command {@code node -g install corepack[@]}). + * + * @since 8.1.0 + */ +public class InstallCorepackTask extends AbstractRunCommandTask { + + /** + * NPM command to install globally Corepack. + */ + private static final String INSTALL_COREPACK_COMMAND = "install -g corepack"; + + /** + * Value for the {@link #corepackVersion} property that will lead to the installation of the latest version of + * Corepack. + */ + public static final String LATEST_VERSION_ARGUMENT = "latest"; + + /** + * Path to the Corepack distribution file relative to the Node.js root directory. + */ + public static final String COREPACK_MODULE_PATH = "node_modules/corepack"; + + /** + * Version of Corepack that should be installed: may be a specific version number such as {@code X.Y.Z} or the + * {@link #LATEST_VERSION_ARGUMENT} keyword to install the latest version available. + */ + private final Property corepackVersion; + + /** + * Directory containing the Corepack module for Node.js. + */ + private final DirectoryProperty corepackModuleDirectory; + + @Inject + public InstallCorepackTask(final ObjectFactory objectFactory, final ExecOperations execOperations) { + super(objectFactory, execOperations); + executableType.set(ExecutableType.NPM); + corepackVersion = objectFactory.property(String.class); + corepackModuleDirectory = objectFactory.directoryProperty(); + corepackModuleDirectory.set(getProject() + .getLayout() + .dir(getNodeInstallDirectory().map(f -> f.toPath().resolve(COREPACK_MODULE_PATH).toFile()))); + } + + @Input + public Property getCorepackVersion() { + return corepackVersion; + } + + @OutputDirectory + public DirectoryProperty getCorepackModuleDirectory() { + return corepackModuleDirectory; + } + + @Override + public void execute() throws NonRunnableTaskException, BeanRegistryException { + final StringBuilder scriptBuilder = new StringBuilder(INSTALL_COREPACK_COMMAND); + final String version = corepackVersion.get(); + if (!version.equals(LATEST_VERSION_ARGUMENT)) { + scriptBuilder.append("@"); + scriptBuilder.append(version); + } + this.script.set(scriptBuilder.toString()); + + super.execute(); + } +} diff --git a/plugin/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java b/plugin/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java index 28ec2958..701131b4 100644 --- a/plugin/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java +++ b/plugin/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java @@ -34,6 +34,7 @@ import org.siouan.frontendgradleplugin.infrastructure.gradle.CheckTask; import org.siouan.frontendgradleplugin.infrastructure.gradle.CleanTask; import org.siouan.frontendgradleplugin.infrastructure.gradle.FrontendExtension; +import org.siouan.frontendgradleplugin.infrastructure.gradle.InstallCorepackTask; import org.siouan.frontendgradleplugin.infrastructure.gradle.InstallFrontendTask; import org.siouan.frontendgradleplugin.infrastructure.gradle.InstallNodeTask; import org.siouan.frontendgradleplugin.infrastructure.gradle.InstallPackageManagerTask; @@ -73,6 +74,7 @@ void should_register_tasks_with_default_extension_values_applied() throws IOExce DEFAULT_NODE_DISTRIBUTION_URL_PATH_PATTERN); assertThat(extension.getNodeDistributionServerUsername().isPresent()).isFalse(); assertThat(extension.getNodeDistributionServerPassword().isPresent()).isFalse(); + assertThat(extension.getCorepackVersion().isPresent()).isFalse(); assertThat(extension.getInstallScript().get()).isEqualTo(DEFAULT_INSTALL_SCRIPT); assertThat(extension.getCleanScript().isPresent()).isFalse(); assertThat(extension.getAssembleScript().isPresent()).isFalse(); @@ -130,6 +132,7 @@ void should_register_tasks_with_custom_extension_values_applied() throws IOExcep extension.getNodeDistributionUrlRoot().set("https://node"); extension.getNodeDistributionUrlPathPattern().set("/node.tar.gz"); extension.getNodeInstallDirectory().set(project.file(nodeInstallDirectoryName)); + extension.getCorepackVersion().set("latest"); extension.getInstallScript().set("run ci"); extension.getCleanScript().set("run clean"); extension.getAssembleScript().set("run build"); @@ -220,6 +223,23 @@ private void assertThatTasksAreConfigured(final Project project, final FrontendE assertThat(installNodeTask.getSystemOsName().get()).isEqualTo(expectedSystemProperties.get(OS_NAME)); assertThat(installNodeTask.getDependsOn()).isEmpty(); + final InstallCorepackTask installCorepackTask = project + .getTasks() + .named(INSTALL_COREPACK_TASK_NAME, InstallCorepackTask.class) + .get(); + assertThat(installCorepackTask.getBeanRegistryBuildService().get().getBeanRegistry()).isNotNull(); + assertThat(installCorepackTask.getPackageJsonDirectory().get()).isEqualTo( + extension.getPackageJsonDirectory().getAsFile().get()); + assertThat(installCorepackTask.getNodeInstallDirectory().get()).isEqualTo( + extension.getNodeInstallDirectory().getAsFile().get()); + assertThat(installCorepackTask.getCorepackVersion().getOrNull()).isEqualTo( + extension.getCorepackVersion().getOrNull()); + assertThat(installCorepackTask.getVerboseModeEnabled().get()).isEqualTo( + extension.getVerboseModeEnabled().get()); + assertThat(installCorepackTask.getSystemJvmArch().get()).isEqualTo(expectedSystemProperties.get(JVM_ARCH)); + assertThat(installCorepackTask.getSystemOsName().get()).isEqualTo(expectedSystemProperties.get(OS_NAME)); + assertThat(installCorepackTask.getDependsOn()).containsExactlyInAnyOrder(INSTALL_NODE_TASK_NAME); + final ResolvePackageManagerTask resolvePackageManagerTask = project .getTasks() .named(RESOLVE_PACKAGE_MANAGER_TASK_NAME, ResolvePackageManagerTask.class) @@ -268,7 +288,7 @@ private void assertThatTasksAreConfigured(final Project project, final FrontendE assertThat(installPackageManagerTask.getSystemJvmArch().get()).isEqualTo( expectedSystemProperties.get(JVM_ARCH)); assertThat(installPackageManagerTask.getSystemOsName().get()).isEqualTo(expectedSystemProperties.get(OS_NAME)); - assertThat(installPackageManagerTask.getDependsOn()).isEmpty(); + assertThat(installPackageManagerTask.getDependsOn()).containsExactlyInAnyOrder(INSTALL_COREPACK_TASK_NAME); final InstallFrontendTask installFrontendTask = project .getTasks() diff --git a/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalCorepackExecutablePathTest.java b/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveCorepackExecutablePathTest.java similarity index 100% rename from plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalCorepackExecutablePathTest.java rename to plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveCorepackExecutablePathTest.java diff --git a/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalNodeExecutablePathTest.java b/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveNodeExecutablePathTest.java similarity index 100% rename from plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalNodeExecutablePathTest.java rename to plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveNodeExecutablePathTest.java diff --git a/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalNpmExecutablePathTest.java b/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveNpmExecutablePathTest.java similarity index 100% rename from plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalNpmExecutablePathTest.java rename to plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveNpmExecutablePathTest.java diff --git a/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolvePackageManagerTest.java b/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolvePackageManagerTest.java index 938121e0..ea48144a 100644 --- a/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolvePackageManagerTest.java +++ b/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolvePackageManagerTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; @@ -36,28 +37,47 @@ class ResolvePackageManagerTest { private ResolvePackageManager usecase; @Test - void should_resolve_package_manager_type_and_store_name_and_executable_file_path_in_cache() + void should_delete_output_files_when_package_json_file_does_not_exist() + throws IOException, InvalidJsonFileException, MalformedPackageManagerSpecification, + UnsupportedPackageManagerException { + final Path nodeInstallDirectoryPath = Paths.get("node"); + final Platform platform = LOCAL_PLATFORM; + final Path packageManagerSpecificationFilePath = Paths.get("name.txt"); + final Path packageManagerExecutablePathFilePath = Paths.get("executable-path.txt"); + + usecase.execute(new ResolvePackageManagerCommand(null, nodeInstallDirectoryPath, platform, + packageManagerSpecificationFilePath, packageManagerExecutablePathFilePath)); + + final ArgumentCaptor pathArgumentCaptor = ArgumentCaptor.forClass(Path.class); + verify(fileManager, times(2)).deleteIfExists(pathArgumentCaptor.capture()); + assertThat(pathArgumentCaptor.getAllValues()).containsExactly(packageManagerSpecificationFilePath, + packageManagerExecutablePathFilePath); + verifyNoMoreInteractions(parsePackageManagerFromPackageJsonFile, getExecutablePath, fileManager); + } + + @Test + void should_resolve_package_manager_and_cache_output_files() throws IOException, InvalidJsonFileException, MalformedPackageManagerSpecification, UnsupportedPackageManagerException { final Path packageJsonFilePath = Paths.get("package.json"); final Path nodeInstallDirectoryPath = Paths.get("node"); final Platform platform = LOCAL_PLATFORM; - final Path packageManagerNameFilePath = Paths.get("name.txt"); + final Path packageManagerSpecificationFilePath = Paths.get("name.txt"); final Path packageManagerExecutablePathFilePath = Paths.get("executable-path.txt"); final PackageManagerType packageManagerType = PackageManagerType.PNPM; final String packageManagerVersion = "5.9.2"; when(parsePackageManagerFromPackageJsonFile.execute(packageJsonFilePath)).thenReturn( PackageManager.builder().type(packageManagerType).version(packageManagerVersion).build()); final Path executablePath = Paths.get("executable"); - when(fileManager.writeString(packageManagerNameFilePath, "pnpm@5.9.2", StandardCharsets.UTF_8, - StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)).thenReturn(packageManagerNameFilePath); + when(fileManager.writeString(packageManagerSpecificationFilePath, "pnpm@5.9.2", StandardCharsets.UTF_8, + StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)).thenReturn(packageManagerSpecificationFilePath); when(getExecutablePath.execute(any(GetExecutablePathCommand.class))).thenReturn(executablePath); when(fileManager.writeString(packageManagerExecutablePathFilePath, executablePath.toString(), StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)).thenReturn( packageManagerExecutablePathFilePath); usecase.execute(new ResolvePackageManagerCommand(packageJsonFilePath, nodeInstallDirectoryPath, platform, - packageManagerNameFilePath, packageManagerExecutablePathFilePath)); + packageManagerSpecificationFilePath, packageManagerExecutablePathFilePath)); final ArgumentCaptor getExecutablePathQueryArgumentCaptor = ArgumentCaptor.forClass( GetExecutablePathCommand.class); diff --git a/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalPnpmExecutablePathTest.java b/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolvePnpmExecutablePathTest.java similarity index 100% rename from plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalPnpmExecutablePathTest.java rename to plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolvePnpmExecutablePathTest.java diff --git a/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalYarnExecutablePathTest.java b/plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveYarnExecutablePathTest.java similarity index 100% rename from plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveGlobalYarnExecutablePathTest.java rename to plugin/src/test/java/org/siouan/frontendgradleplugin/domain/ResolveYarnExecutablePathTest.java diff --git a/site/src/components/property/corepack-version-property.vue b/site/src/components/property/corepack-version-property.vue new file mode 100644 index 00000000..27577d91 --- /dev/null +++ b/site/src/components/property/corepack-version-property.vue @@ -0,0 +1,27 @@ + diff --git a/site/src/components/property/node-distribution-url-path-pattern-property.vue b/site/src/components/property/node-distribution-url-path-pattern-property.vue index 217fb41b..e127c12e 100644 --- a/site/src/components/property/node-distribution-url-path-pattern-property.vue +++ b/site/src/components/property/node-distribution-url-path-pattern-property.vue @@ -9,7 +9,7 @@ This property is used to build the exact URL to download the distribution, by appending its value to the value of the property. This property may be set with a fixed trailing - path part (e.g. dist/node-v18.17.1-win-x64.zip), or take advantage of the automatic + path part (e.g. dist/node-v20.14.0-win-x64.zip), or take advantage of the automatic distribution resolution in the plugin, using specific tokens in the pattern such as VERSION, ARCH, TYPE. Then, the exact URL used by default to download the distribution is diff --git a/site/src/components/property/node-version-property.vue b/site/src/components/property/node-version-property.vue index 6ad5c7c6..f2c69f36 100644 --- a/site/src/components/property/node-version-property.vue +++ b/site/src/components/property/node-version-property.vue @@ -4,7 +4,7 @@ type="java.lang.String" :required="false" :default-value="null" - example="18.17.1" + example="20.14.0" :task-names="['installNode']" >

diff --git a/site/src/components/task/dependency-tree.vue b/site/src/components/task/dependency-tree.vue index 9b376c68..3aa4a82e 100644 --- a/site/src/components/task/dependency-tree.vue +++ b/site/src/components/task/dependency-tree.vue @@ -33,6 +33,12 @@ installNode + + + + installCorepack + + @@ -153,8 +159,11 @@ + + + - + @@ -191,13 +200,18 @@ + + - - - + + + + + + diff --git a/site/src/components/task/install-corepack-task.vue b/site/src/components/task/install-corepack-task.vue new file mode 100644 index 00000000..ca342172 --- /dev/null +++ b/site/src/components/task/install-corepack-task.vue @@ -0,0 +1,64 @@ + + + diff --git a/site/src/components/task/install-package-manager-task.vue b/site/src/components/task/install-package-manager-task.vue index a976eb31..249ff1b0 100644 --- a/site/src/components/task/install-package-manager-task.vue +++ b/site/src/components/task/install-package-manager-task.vue @@ -1,7 +1,7 @@