Skip to content

Commit

Permalink
fix gradle test
Browse files Browse the repository at this point in the history
  • Loading branch information
taefi committed Jan 31, 2024
1 parent 54ca380 commit 7171aac
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.vaadin.hilla.engine.EngineConfiguration
import io.swagger.v3.core.util.Json
import io.swagger.v3.oas.models.OpenAPI
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Test
import java.io.File
import java.nio.file.Files
Expand Down Expand Up @@ -84,45 +83,6 @@ class SingleModuleTest : AbstractGradleTest() {
verifyEndpointsTsFileGeneratedProperly()
}

@Test
fun `when productionMode is true in build file then building the project executes vaadinBuildFrontend`() {
createProject(withNpmInstall = true, productionMode = true, disableAllTasksToSimulateDryRun = true)

addHelloReactEndpoint()

val buildResult: BuildResult = testProject.build("build", checkTasksSuccessful = false)

expect(TaskOutcome.SKIPPED, "Building project while hilla.productionMode=true should plan to execute vaadinBuildFrontend task") {
buildResult.task(":vaadinBuildFrontend")?.outcome
}
}

@Test
fun `when productionMode not set in build file then building the project with productionMode commandline arg executes vaadinBuildFrontend`() {
createProject(withNpmInstall = true, productionMode = false, disableAllTasksToSimulateDryRun = true)

addHelloReactEndpoint()

val buildResult: BuildResult = testProject.build("-Philla.productionMode=true", "build", checkTasksSuccessful = false)

expect(TaskOutcome.SKIPPED, "Building project while hilla.productionMode=true should plan to execute vaadinBuildFrontend task") {
buildResult.task(":vaadinBuildFrontend")?.outcome
}
}

@Test
fun `when productionMode is true in build file then building the project with commandline arg productionMode false does not execute vaadinBuildFrontend`() {
createProject(withNpmInstall = true, productionMode = true, disableAllTasksToSimulateDryRun = true)

addHelloReactEndpoint()

val buildResult: BuildResult = testProject.build("-Pvaadin.productionMode=false", "build", checkTasksSuccessful = false)

expect(null, "Building project while hilla.productionMode=true should plan to execute vaadinBuildFrontend task") {
buildResult.task(":vaadinBuildFrontend")
}
}

@Test
fun `check hillaInitApp properly scaffolds project according to framework`() {
createProject()
Expand Down Expand Up @@ -280,7 +240,6 @@ class SingleModuleTest : AbstractGradleTest() {
dependencies {
implementation 'com.vaadin.hilla:hilla-react'
implementation 'com.vaadin:vaadin-spring'
implementation 'com.vaadin.hilla:hilla'
implementation 'org.springframework.boot:spring-boot-starter-web'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
*/
package com.vaadin.hilla.gradle.plugin

import com.vaadin.gradle.VaadinFlowPluginExtension
import com.vaadin.gradle.VaadinPlugin
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.bundling.Jar

/**
* The main class of the Hilla Gradle Plugin
Expand Down Expand Up @@ -54,15 +52,5 @@ public class HillaPlugin : Plugin<Project> {
copyTask.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}

project.afterEvaluate {
val vaadinExtension = VaadinFlowPluginExtension.get(it)
if (vaadinExtension.productionMode.get()) {
// this will also catch the War task since it extends from Jar
project.tasks.withType(Jar::class.java) { task: Jar ->
task.dependsOn("vaadinBuildFrontend")
}
}
}
}
}

0 comments on commit 7171aac

Please sign in to comment.