Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Fixes yarnBuild gradle task with Gradle v7+ and upgrade to Gradle 7.4.2.
Browse files Browse the repository at this point in the history
 - task broken in 845caab
 - moowork plugin no longer maintained resulting in broken gradle task
   - srs/gradle-node-plugin#377
  • Loading branch information
gorhack committed Mar 31, 2022
1 parent 2876244 commit ee7214a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
22 changes: 12 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import com.moowork.gradle.node.yarn.YarnTask
import com.github.gradle.node.yarn.task.YarnTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.springframework.boot") version "2.5.5"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("com.moowork.node") version "1.3.1"
id("com.github.node-gradle.node") version "3.2.1"
id("org.flywaydb.flyway") version "8.0.0"
id("org.sonarqube") version "3.3"

Expand All @@ -23,7 +23,10 @@ version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_15

node {
nodeModulesDir = file("${project.projectDir}/client")
download.set(false)
yarnWorkDir.set(file("${project.projectDir}/client"))
nodeProjectDir.set(file("${project.projectDir}/client"))
yarnWorkDir.set(file("${project.projectDir}/.gradle/yarn"))
}

noArg {
Expand Down Expand Up @@ -108,14 +111,13 @@ tasks.withType<Test> {
}
}

tasks.register("yarnBuild", YarnTask::class) {
setWorkingDir("client")
args = listOf("build")
dependsOn("yarnInstall")
tasks.getByName<YarnTask>("yarn_build") {
dependsOn("yarn_install")
}
tasks.register("yarnInstall", YarnTask::class) {
setWorkingDir("client")
args = listOf("install")

tasks.getByName<YarnTask>("yarn_test") {
dependsOn("yarn_build")
environment.put("CI", "true")
}

tasks.getByName<Jar>("jar") {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion run_jar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ echo ""

if [[ -z ${CI+x} ]]; then
# Not in CI
SPRING_PROFILES_ACTIVE="$env" ./gradlew yarnBuild assemble bootRun --console=plain --args="--server.port=$PORT" &
SPRING_PROFILES_ACTIVE="$env" ./gradlew yarn_build assemble bootRun --console=plain --args="--server.port=$PORT" &
else
# In CI
SPRING_PROFILES_ACTIVE="$env" java -jar -Dserver.port=$PORT ./build/libs/tsr-*.jar &
Expand Down
4 changes: 3 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ set -eou pipefail
(cd client; yarn install;yarn lint:ci; CI=true yarn test;)
./gradlew clean build

(cd client;CI=true yarn build)
# Creates a jar for development/testing only. Not for use in production
# https://stackoverflow.com/questions/16145522/chrome-showing-error-as-refused-to-execute-inline-script-because-of-content-sec
(cd client;CI=true INLINE_RUNTIME_CHUNK=false yarn build)
./gradlew assemble

0 comments on commit ee7214a

Please sign in to comment.