From 1082641b47cdf3b9bb5dc8063b874f00fd3e61ed Mon Sep 17 00:00:00 2001 From: Vincent Bories-Azeau <5869062+vboriesazeau@users.noreply.github.com> Date: Thu, 12 Mar 2020 14:59:36 +0100 Subject: [PATCH 1/7] Initialized release 1.3.1. --- README.md | 6 +++--- build.gradle | 2 +- gradlew | 0 sonar-project.properties | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) mode change 100755 => 100644 gradlew diff --git a/README.md b/README.md index cce38b63..46b2d1aa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Frontend Gradle plugin -[![Latest release 1.3.0](https://img.shields.io/badge/Latest%20release-1.3.0-blue.svg)](https://github.com/Siouan/frontend-gradle-plugin/releases/tag/v1.3.0) +[![Latest release 1.3.1](https://img.shields.io/badge/Latest%20release-1.3.1-blue.svg)](https://github.com/Siouan/frontend-gradle-plugin/releases/tag/v1.3.1) [![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0) [![Build status](https://travis-ci.com/Siouan/frontend-gradle-plugin.svg?branch=1.3)](https://travis-ci.com/Siouan/frontend-gradle-plugin) @@ -65,7 +65,7 @@ This is the modern and recommended approach. ```groovy // build.gradle plugins { - id 'org.siouan.frontend' version '1.3.0' + id 'org.siouan.frontend' version '1.3.1' } ``` @@ -80,7 +80,7 @@ buildscript { url 'https://plugins.gradle.org/m2/' } dependencies { - classpath 'org.siouan:frontend-gradle-plugin:1.3.0' + classpath 'org.siouan:frontend-gradle-plugin:1.3.1' } } diff --git a/build.gradle b/build.gradle index 8cb7e15f..f9016e9c 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ dependencies { } group 'org.siouan' -version '1.3.0' +version '1.3.1' description 'Integrate your frontend Node/NPM/Yarn build into Gradle.' sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/gradlew b/gradlew old mode 100755 new mode 100644 diff --git a/sonar-project.properties b/sonar-project.properties index 39b9be8c..c1dae528 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.projectKey=Siouan_frontend-gradle-plugin sonar.projectName=frontend-gradle-plugin -sonar.projectVersion=1.3.0 +sonar.projectVersion=1.3.1 sonar.links.homepage=https://github.com/Siouan/frontend-gradle-plugin sonar.links.ci=https://travis-ci.com/Siouan/frontend-gradle-plugin From e3e911830f688ea7f21813450f6088ab2e265fca Mon Sep 17 00:00:00 2001 From: Vincent Bories-Azeau <5869062+vboriesazeau@users.noreply.github.com> Date: Thu, 12 Mar 2020 15:10:46 +0100 Subject: [PATCH 2/7] Marked Gradle wrapper executable --- gradlew | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 gradlew diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 From 1ee10b87fcc556ea597256d0ffeebfb07fc031de Mon Sep 17 00:00:00 2001 From: Vincent Bories-Azeau <5869062+vboriesazeau@users.noreply.github.com> Date: Thu, 12 Mar 2020 15:34:43 +0100 Subject: [PATCH 3/7] Switched CI to OpenJDK 11 for MacOS. --- .travis.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3cda25de..fb35347d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,19 @@ matrix: - os: osx osx_image: xcode9.4 - jdk: oraclejdk11 + jdk: openjdk11 + env: + # This is a convenience variable for shortening download commands + - GRAVIS="https://raw.githubusercontent.com/DanySK/Gravis-CI/master/" + # List any JDK you want to build your software with. + # You can see the list of supported environments by installing Jabba and using ls-remote: + # https://github.com/shyiko/jabba#usage + - JDK="openjdk@1.11" + before_install: + # Download the script, and download, install, configue the JDK, and export the configuration to the current shell + - curl "${GRAVIS}.install-jdk-travis.sh" --output ~/.install-jdk-travis.sh + - source ~/.install-jdk-travis.sh + - os: windows # Java is not yet supported on Windows, so the build would block. From c479db01bb05d7209f60c55fb12e7e94b4dffeae Mon Sep 17 00:00:00 2001 From: Vincent Bories-Azeau <5869062+vboriesazeau@users.noreply.github.com> Date: Thu, 12 Mar 2020 17:10:25 +0100 Subject: [PATCH 4/7] Fixed #74 (#75) --- .travis.yml | 1 - .../FrontendGradlePlugin.java | 41 +++++++++----- .../FrontendGradlePluginTest.java | 7 +-- .../tasks/AssembleTaskFuncTest.java | 41 +++++++------- .../tasks/CheckTaskFuncTest.java | 45 ++++++++-------- .../tasks/CleanTaskFuncTest.java | 41 +++++++------- .../tasks/InstallTaskFuncTest.java | 54 +++++++++---------- .../tasks/NodeInstallTaskFuncTest.java | 15 +++--- .../tasks/RunNodeTaskFuncTest.java | 12 ++--- .../tasks/RunScriptTaskFuncTest.java | 38 ++++++------- .../tasks/YarnInstallTaskFuncTest.java | 18 ++++--- .../frontendgradleplugin/util/Helper.java | 42 ++++++++++++++- 12 files changed, 209 insertions(+), 146 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb35347d..852be806 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,6 @@ matrix: - curl "${GRAVIS}.install-jdk-travis.sh" --output ~/.install-jdk-travis.sh - source ~/.install-jdk-travis.sh - - os: windows # Java is not yet supported on Windows, so the build would block. # You do not need any setup from Travis, use a plain bash build diff --git a/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java b/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java index 0b2b3d2d..ecebbefa 100644 --- a/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java +++ b/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java @@ -112,12 +112,11 @@ public void apply(final Project project) { projectTasks.register(CHECK_TASK_NAME, CheckTask.class, task -> configureCheckTask(task, extension)); projectTasks.register(ASSEMBLE_TASK_NAME, AssembleTask.class, task -> configureAssembleTask(task, extension)); + configureDependency(projectTasks, INSTALL_TASK_NAME, InstallTask.class, NODE_INSTALL_TASK_NAME, + NodeInstallTask.class); configureDependency(projectTasks, INSTALL_TASK_NAME, InstallTask.class, YARN_INSTALL_TASK_NAME, - YarnInstallTask.class, (installTask, yarnInstallTask) -> { - installTask.dependsOn(NODE_INSTALL_TASK_NAME); - return yarnInstallTask.isEnabled(); - }); - configureDependency(projectTasks, CLEAN_TASK_NAME, CleanTask.class, INSTALL_TASK_NAME, InstallTask.class, + YarnInstallTask.class); + configureDependency(projectTasks, CLEAN_TASK_NAME, CleanTask.class, INSTALL_TASK_NAME, InstallTask.class, (cleanTask, installTask) -> cleanTask.getCleanScript().isPresent()); configureDependency(projectTasks, ASSEMBLE_TASK_NAME, AssembleTask.class, INSTALL_TASK_NAME, InstallTask.class, (assembleTask, installTask) -> assembleTask.getAssembleScript().isPresent()); @@ -151,10 +150,10 @@ private void configureNodeInstallTask(final NodeInstallTask task, final Frontend * @param task Task. * @param extension Plugin extension. */ - private void configureYarnInstallTask(final YarnInstallTask task, FrontendExtension extension) { + private void configureYarnInstallTask(final YarnInstallTask task, final FrontendExtension extension) { task.setGroup(TASK_GROUP); task.setDescription("Downloads and installs a Yarn distribution."); - task.setEnabled(extension.getYarnEnabled().get()); + task.setOnlyIf(t -> extension.getYarnEnabled().get()); task.getYarnVersion().set(extension.getYarnVersion()); task.getYarnDistributionUrl().set(extension.getYarnDistributionUrl()); task.getYarnInstallDirectory().set(extension.getYarnInstallDirectory()); @@ -166,7 +165,7 @@ private void configureYarnInstallTask(final YarnInstallTask task, FrontendExtens * @param task Task. * @param extension Plugin extension. */ - private void configureInstallTask(final InstallTask task, FrontendExtension extension) { + private void configureInstallTask(final InstallTask task, final FrontendExtension extension) { task.setGroup(TASK_GROUP); task.setDescription("Installs/updates frontend dependencies."); task.getYarnEnabled().set(extension.getYarnEnabled()); @@ -181,7 +180,7 @@ private void configureInstallTask(final InstallTask task, FrontendExtension exte * @param task Task. * @param extension Plugin extension. */ - private void configureCleanTask(final CleanTask task, FrontendExtension extension) { + private void configureCleanTask(final CleanTask task, final FrontendExtension extension) { task.setGroup(TASK_GROUP); task.setDescription("Cleans frontend resources outside the build directory by running a specific script."); task.getYarnEnabled().set(extension.getYarnEnabled()); @@ -196,7 +195,7 @@ private void configureCleanTask(final CleanTask task, FrontendExtension extensio * @param task Task. * @param extension Plugin extension. */ - private void configureCheckTask(final CheckTask task, FrontendExtension extension) { + private void configureCheckTask(final CheckTask task, final FrontendExtension extension) { task.setGroup(TASK_GROUP); task.setDescription("Checks frontend by running a specific script."); task.getYarnEnabled().set(extension.getYarnEnabled()); @@ -211,7 +210,7 @@ private void configureCheckTask(final CheckTask task, FrontendExtension extensio * @param task Task. * @param extension Plugin extension. */ - private void configureAssembleTask(final AssembleTask task, FrontendExtension extension) { + private void configureAssembleTask(final AssembleTask task, final FrontendExtension extension) { task.setGroup(TASK_GROUP); task.setDescription("Assembles the frontend by running a specific script."); task.getYarnEnabled().set(extension.getYarnEnabled()); @@ -221,7 +220,25 @@ private void configureAssembleTask(final AssembleTask task, FrontendExtension ex } /** - * Configures a dynamic dependency between 2 tasks, based on a condition evaluation. + * Configures a static dependency between 2 tasks. + * + * @param taskContainer Task container. + * @param taskName Name of the task that may depend on another task. + * @param taskClass Task class. + * @param dependsOnTaskName Name of the depending task. + * @param dependsOnTaskClass Depending task class. + * @param Type of the dependent task. + * @param Type of the depending task. + */ + private void configureDependency(final TaskContainer taskContainer, + final String taskName, final Class taskClass, final String dependsOnTaskName, + final Class dependsOnTaskClass) { + taskContainer.named(taskName, taskClass, + task -> task.dependsOn(taskContainer.named(dependsOnTaskName, dependsOnTaskClass).getName())); + } + + /** + * Configures a dynamic dependency between 2 tasks, based on the evaluation of a condition. * * @param taskContainer Task container. * @param taskName Name of the task that may depend on another task. diff --git a/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java b/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java index 0488f8bf..20559043 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java @@ -56,7 +56,7 @@ void shouldRegisterTasksWithDefaultExtensionValuesWhenApplied() { final YarnInstallTask yarnInstallTask = project.getTasks() .named(FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, YarnInstallTask.class).get(); - assertThat(yarnInstallTask.isEnabled()).isEqualTo(extension.getYarnEnabled().get()); + assertThat(yarnInstallTask.getOnlyIf()).isNotNull(); assertThat(yarnInstallTask.getYarnVersion().isPresent()).isFalse(); assertThat(yarnInstallTask.getYarnDistributionUrl().isPresent()).isFalse(); assertThat(yarnInstallTask.getYarnInstallDirectory().get()) @@ -70,7 +70,8 @@ void shouldRegisterTasksWithDefaultExtensionValuesWhenApplied() { .isEqualTo(extension.getNodeInstallDirectory().get()); assertThat(frontendInstallTask.getYarnInstallDirectory().get()) .isEqualTo(extension.getYarnInstallDirectory().get()); - assertThat(frontendInstallTask.getDependsOn()).containsExactlyInAnyOrder(nodeInstallTask.getName()); + assertThat(frontendInstallTask.getDependsOn()) + .containsExactlyInAnyOrder(nodeInstallTask.getName(), yarnInstallTask.getName()); final CleanTask frontendCleanTask = project.getTasks() .named(FrontendGradlePlugin.CLEAN_TASK_NAME, CleanTask.class).get(); @@ -135,7 +136,7 @@ void shouldRegisterTasksWithCustomExtensionValuesWhenApplied() { final YarnInstallTask yarnInstallTask = project.getTasks() .named(FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, YarnInstallTask.class).get(); - assertThat(yarnInstallTask.isEnabled()).isEqualTo(extension.getYarnEnabled().get()); + assertThat(yarnInstallTask.getOnlyIf()).isNotNull(); assertThat(yarnInstallTask.getYarnVersion().get()).isEqualTo(extension.getYarnVersion().get()); assertThat(yarnInstallTask.getYarnDistributionUrl().get()).isEqualTo(extension.getYarnDistributionUrl().get()); assertThat(yarnInstallTask.getYarnInstallDirectory().get()) diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/AssembleTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/AssembleTaskFuncTest.java index b82152b9..0a95c411 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/AssembleTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/AssembleTaskFuncTest.java @@ -1,7 +1,9 @@ package org.siouan.frontendgradleplugin.tasks; import static org.siouan.frontendgradleplugin.util.Helper.assertTaskIgnored; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskOutcome; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSkipped; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSuccess; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskUpToDate; import static org.siouan.frontendgradleplugin.util.Helper.runGradle; import java.io.File; @@ -14,7 +16,6 @@ import java.util.Map; import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -52,7 +53,7 @@ void shouldDoNothingWhenScriptIsNotDefined() throws IOException, URISyntaxExcept assertTaskIgnored(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.ASSEMBLE_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.ASSEMBLE_TASK_NAME); } @Test @@ -70,7 +71,7 @@ void shouldAssembleWithoutFrontendTasks() throws IOException, URISyntaxException assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.ASSEMBLE_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME, TaskOutcome.UP_TO_DATE); + assertTaskUpToDate(result1, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME); } @Test @@ -85,17 +86,17 @@ void shouldAssembleFrontendWithNpmOrYarn() throws IOException, URISyntaxExceptio final BuildResult result1 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result1, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result1, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME); final BuildResult result2 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskIgnored(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result2, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result2, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result2, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME); Files.deleteIfExists(projectDirectory.resolve("package-lock.json")); Files.copy(new File(getClass().getClassLoader().getResource("package-yarn.json").toURI()).toPath(), @@ -108,16 +109,16 @@ void shouldAssembleFrontendWithNpmOrYarn() throws IOException, URISyntaxExceptio final BuildResult result3 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME); - assertTaskOutcome(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME); final BuildResult result4 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME); - assertTaskOutcome(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result4, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskUpToDate(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result4, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result4, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME); } } diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/CheckTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/CheckTaskFuncTest.java index ec7b9a46..1767940c 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/CheckTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/CheckTaskFuncTest.java @@ -1,7 +1,9 @@ package org.siouan.frontendgradleplugin.tasks; import static org.siouan.frontendgradleplugin.util.Helper.assertTaskIgnored; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskOutcome; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSkipped; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSuccess; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskUpToDate; import static org.siouan.frontendgradleplugin.util.Helper.runGradle; import java.io.File; @@ -14,7 +16,6 @@ import java.util.Map; import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -52,7 +53,7 @@ void shouldDoNothingWhenScriptIsNotDefined() throws IOException, URISyntaxExcept assertTaskIgnored(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.CHECK_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.CHECK_TASK_NAME); } @Test @@ -70,7 +71,7 @@ void shouldCheckWithoutFrontendTasks() throws IOException, URISyntaxException { assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.CHECK_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME, TaskOutcome.UP_TO_DATE); + assertTaskUpToDate(result1, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME); } @Test @@ -85,39 +86,39 @@ void shouldCheckFrontendWithNpmOrYarn() throws IOException, URISyntaxException { final BuildResult result1 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result1, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result1, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME); final BuildResult result2 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskIgnored(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result2, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result2, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result2, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME); Files.deleteIfExists(projectDirectory.resolve("package-lock.json")); Files.copy(new File(getClass().getClassLoader().getResource("package-yarn.json").toURI()).toPath(), projectDirectory.resolve("package.json"), StandardCopyOption.REPLACE_EXISTING); properties.put("yarnEnabled", true); properties.put("yarnVersion", "1.16.0"); - properties - .put("yarnDistributionUrl", getClass().getClassLoader().getResource("yarn-v1.16.0.tar.gz").toString()); + properties.put("yarnDistributionUrl", + getClass().getClassLoader().getResource("yarn-v1.16.0.tar.gz").toString()); Helper.createBuildFile(projectDirectory, properties); final BuildResult result3 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME); - assertTaskOutcome(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME); final BuildResult result4 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME); - assertTaskOutcome(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result4, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskUpToDate(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result4, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result4, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME); } } diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/CleanTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/CleanTaskFuncTest.java index f6573615..846bf9fe 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/CleanTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/CleanTaskFuncTest.java @@ -1,7 +1,9 @@ package org.siouan.frontendgradleplugin.tasks; import static org.siouan.frontendgradleplugin.util.Helper.assertTaskIgnored; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskOutcome; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSkipped; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSuccess; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskUpToDate; import static org.siouan.frontendgradleplugin.util.Helper.runGradle; import java.io.File; @@ -14,7 +16,6 @@ import java.util.Map; import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -52,7 +53,7 @@ void shouldDoNothingWhenScriptIsNotDefined() throws IOException, URISyntaxExcept assertTaskIgnored(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.CLEAN_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.CLEAN_TASK_NAME); } @Test @@ -70,7 +71,7 @@ void shouldCleanWithoutFrontendTasks() throws IOException, URISyntaxException { assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); assertTaskIgnored(result1, FrontendGradlePlugin.CLEAN_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME, TaskOutcome.UP_TO_DATE); + assertTaskUpToDate(result1, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME); } @Test @@ -85,17 +86,17 @@ void shouldCleanFrontendWithNpmOrYarn() throws IOException, URISyntaxException { final BuildResult result1 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result1, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result1, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME); final BuildResult result2 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskIgnored(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result2, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME, TaskOutcome.UP_TO_DATE); + assertTaskUpToDate(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result2, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskUpToDate(result2, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME); Files.deleteIfExists(projectDirectory.resolve("package-lock.json")); Files.copy(new File(getClass().getClassLoader().getResource("package-yarn.json").toURI()).toPath(), @@ -108,16 +109,16 @@ void shouldCleanFrontendWithNpmOrYarn() throws IOException, URISyntaxException { final BuildResult result3 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME); - assertTaskOutcome(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME); final BuildResult result4 = runGradle(projectDirectory, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME); - assertTaskOutcome(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result4, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME, TaskOutcome.UP_TO_DATE); + assertTaskUpToDate(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskUpToDate(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result4, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskUpToDate(result4, FrontendGradlePlugin.GRADLE_CLEAN_TASK_NAME); } } diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/InstallTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/InstallTaskFuncTest.java index cae9de8f..f6d810c9 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/InstallTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/InstallTaskFuncTest.java @@ -1,7 +1,8 @@ package org.siouan.frontendgradleplugin.tasks; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskIgnored; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskOutcome; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSkipped; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSuccess; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskUpToDate; import static org.siouan.frontendgradleplugin.util.Helper.runGradle; import java.io.File; @@ -14,7 +15,6 @@ import java.util.Map; import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -49,15 +49,15 @@ void shouldInstallFrontendWithNpmOrYarnAndDefaultScript() throws IOException, UR final BuildResult result1 = runGradle(projectDirectory, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); final BuildResult result2 = runGradle(projectDirectory, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskIgnored(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result2, FrontendGradlePlugin.INSTALL_TASK_NAME); Files.deleteIfExists(projectDirectory.resolve("package-lock.json")); Files.copy(new File(getClass().getClassLoader().getResource("package-yarn.json").toURI()).toPath(), @@ -70,15 +70,15 @@ void shouldInstallFrontendWithNpmOrYarnAndDefaultScript() throws IOException, UR final BuildResult result3 = runGradle(projectDirectory, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.INSTALL_TASK_NAME); final BuildResult result4 = runGradle(projectDirectory, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskUpToDate(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result4, FrontendGradlePlugin.INSTALL_TASK_NAME); } @Test @@ -93,15 +93,15 @@ void shouldInstallFrontendWithNpmOrYarnAndCustomScript() throws IOException, URI final BuildResult result1 = runGradle(projectDirectory, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); final BuildResult result2 = runGradle(projectDirectory, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskIgnored(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result2, FrontendGradlePlugin.INSTALL_TASK_NAME); Files.deleteIfExists(projectDirectory.resolve("package-lock.json")); Files.copy(new File(getClass().getClassLoader().getResource("package-yarn.json").toURI()).toPath(), @@ -114,14 +114,14 @@ void shouldInstallFrontendWithNpmOrYarnAndCustomScript() throws IOException, URI final BuildResult result3 = runGradle(projectDirectory, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.INSTALL_TASK_NAME); final BuildResult result4 = runGradle(projectDirectory, FrontendGradlePlugin.INSTALL_TASK_NAME); - assertTaskOutcome(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskUpToDate(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskUpToDate(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result4, FrontendGradlePlugin.INSTALL_TASK_NAME); } } diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/NodeInstallTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/NodeInstallTaskFuncTest.java index d20a4333..ff4d537a 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/NodeInstallTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/NodeInstallTaskFuncTest.java @@ -1,6 +1,8 @@ package org.siouan.frontendgradleplugin.tasks; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskOutcome; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskFailed; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSuccess; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskUpToDate; import static org.siouan.frontendgradleplugin.util.Helper.runGradle; import static org.siouan.frontendgradleplugin.util.Helper.runGradleAndExpectFailure; @@ -12,7 +14,6 @@ import java.util.Map; import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -42,7 +43,7 @@ void shouldFailInstallingNodeWhenVersionIsNotSet() throws IOException { final BuildResult result = runGradleAndExpectFailure(projectDirectory, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.FAILED); + assertTaskFailed(result, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); } @Test @@ -52,7 +53,7 @@ void shouldFailInstallingNodeWhenDistributionCannotBeDownloadedWithUnknownVersio final BuildResult result = runGradleAndExpectFailure(projectDirectory, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.FAILED); + assertTaskFailed(result, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); } @Test @@ -65,7 +66,7 @@ void shouldFailInstallingNodeWhenDistributionCannotBeDownloadedWithInvalidUrl() final BuildResult result = runGradleAndExpectFailure(projectDirectory, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.FAILED); + assertTaskFailed(result, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); } @Test @@ -77,10 +78,10 @@ void shouldInstallNodeFirstAndNothingMoreSecondly() throws IOException { final BuildResult result1 = runGradle(projectDirectory, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); final BuildResult result2 = runGradle(projectDirectory, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); + assertTaskUpToDate(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); } } diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/RunNodeTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/RunNodeTaskFuncTest.java index 40cee135..28946f0f 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/RunNodeTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/RunNodeTaskFuncTest.java @@ -1,6 +1,7 @@ package org.siouan.frontendgradleplugin.tasks; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskOutcome; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSuccess; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskUpToDate; import static org.siouan.frontendgradleplugin.util.Helper.runGradle; import java.io.File; @@ -12,7 +13,6 @@ import java.util.Map; import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -56,13 +56,13 @@ void shouldRunScriptFrontendWithNode() throws IOException { final BuildResult result1 = runGradle(projectDirectory, customTaskName); - assertTaskOutcome(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result1, customTaskName, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSuccess(result1, customTaskName); final BuildResult result2 = runGradle(projectDirectory, customTaskName); - assertTaskOutcome(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result2, customTaskName, TaskOutcome.SUCCESS); + assertTaskUpToDate(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSuccess(result2, customTaskName); } private void createScriptFile(final Path scriptPath) throws IOException { diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/RunScriptTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/RunScriptTaskFuncTest.java index d54bb637..af3ab980 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/RunScriptTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/RunScriptTaskFuncTest.java @@ -1,7 +1,8 @@ package org.siouan.frontendgradleplugin.tasks; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskIgnored; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskOutcome; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSkipped; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSuccess; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskUpToDate; import static org.siouan.frontendgradleplugin.util.Helper.runGradle; import java.io.File; @@ -14,7 +15,6 @@ import java.util.Map; import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -54,17 +54,17 @@ void shouldRunScriptFrontendWithNpmOrYarn() throws IOException, URISyntaxExcepti final BuildResult result1 = runGradle(projectDirectory, customTaskName); - assertTaskOutcome(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskIgnored(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result1, customTaskName, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result1, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result1, customTaskName); final BuildResult result2 = runGradle(projectDirectory, customTaskName); - assertTaskOutcome(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskIgnored(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result2, customTaskName, TaskOutcome.SUCCESS); + assertTaskUpToDate(result2, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSkipped(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result2, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result2, customTaskName); Files.deleteIfExists(projectDirectory.resolve("package-lock.json")); Files.copy(new File(getClass().getClassLoader().getResource("package-yarn.json").toURI()).toPath(), @@ -75,16 +75,16 @@ void shouldRunScriptFrontendWithNpmOrYarn() throws IOException, URISyntaxExcepti final BuildResult result3 = runGradle(projectDirectory, customTaskName); - assertTaskOutcome(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result3, customTaskName, TaskOutcome.SUCCESS); + assertTaskUpToDate(result3, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result3, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result3, customTaskName); final BuildResult result4 = runGradle(projectDirectory, customTaskName); - assertTaskOutcome(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); - assertTaskOutcome(result4, FrontendGradlePlugin.INSTALL_TASK_NAME, TaskOutcome.SUCCESS); - assertTaskOutcome(result4, customTaskName, TaskOutcome.SUCCESS); + assertTaskUpToDate(result4, FrontendGradlePlugin.NODE_INSTALL_TASK_NAME); + assertTaskUpToDate(result4, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); + assertTaskSuccess(result4, FrontendGradlePlugin.INSTALL_TASK_NAME); + assertTaskSuccess(result4, customTaskName); } } diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/YarnInstallTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/YarnInstallTaskFuncTest.java index 3d69aafb..a6f7e889 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/YarnInstallTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/YarnInstallTaskFuncTest.java @@ -1,6 +1,9 @@ package org.siouan.frontendgradleplugin.tasks; -import static org.siouan.frontendgradleplugin.util.Helper.assertTaskOutcome; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskFailed; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSkipped; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskSuccess; +import static org.siouan.frontendgradleplugin.util.Helper.assertTaskUpToDate; import static org.siouan.frontendgradleplugin.util.Helper.runGradle; import static org.siouan.frontendgradleplugin.util.Helper.runGradleAndExpectFailure; @@ -12,7 +15,6 @@ import java.util.Map; import org.gradle.testkit.runner.BuildResult; -import org.gradle.testkit.runner.TaskOutcome; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -41,7 +43,7 @@ void shouldSkipInstallWhenYarnIsNotEnabled() throws IOException { final BuildResult result = runGradle(projectDirectory, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.SKIPPED); + assertTaskSkipped(result, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); } @Test @@ -51,7 +53,7 @@ void shouldFailInstallingYarnWhenVersionIsNotSet() throws IOException { final BuildResult result = runGradleAndExpectFailure(projectDirectory, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.FAILED); + assertTaskFailed(result, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); } @Test @@ -64,7 +66,7 @@ void shouldFailInstallingYarnWhenDistributionCannotBeDownloadedWithUnknownVersio final BuildResult result = runGradleAndExpectFailure(projectDirectory, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.FAILED); + assertTaskFailed(result, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); } @Test @@ -78,7 +80,7 @@ void shouldFailInstallingYarnWhenDistributionCannotBeDownloadedWithInvalidUrl() final BuildResult result = runGradleAndExpectFailure(projectDirectory, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.FAILED); + assertTaskFailed(result, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); } @Test @@ -92,10 +94,10 @@ void shouldInstallYarnFirstAndNothingMoreSecondly() throws IOException { final BuildResult result1 = runGradle(projectDirectory, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.SUCCESS); + assertTaskSuccess(result1, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); final BuildResult result2 = runGradle(projectDirectory, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); - assertTaskOutcome(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME, TaskOutcome.UP_TO_DATE); + assertTaskUpToDate(result2, FrontendGradlePlugin.YARN_INSTALL_TASK_NAME); } } diff --git a/src/test/java/org/siouan/frontendgradleplugin/util/Helper.java b/src/test/java/org/siouan/frontendgradleplugin/util/Helper.java index 216a682e..8cf6be5c 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/util/Helper.java +++ b/src/test/java/org/siouan/frontendgradleplugin/util/Helper.java @@ -38,6 +38,46 @@ public static String getTaskId(final String taskName) { return ':' + taskName; } + /** + * Asserts a task was part of a build result, and was executed successfully. + * + * @param result Build result. + * @param taskName Task name. + */ + public static void assertTaskSuccess(final BuildResult result, final String taskName) { + assertTaskOutcome(result, taskName, TaskOutcome.SUCCESS); + } + + /** + * Asserts a task was part of a build result, and was not executed as it is already up-to-date. + * + * @param result Build result. + * @param taskName Task name. + */ + public static void assertTaskUpToDate(final BuildResult result, final String taskName) { + assertTaskOutcome(result, taskName, TaskOutcome.UP_TO_DATE); + } + + /** + * Asserts a task was part of a build result, and was skipped. + * + * @param result Build result. + * @param taskName Task name. + */ + public static void assertTaskSkipped(final BuildResult result, final String taskName) { + assertTaskOutcome(result, taskName, TaskOutcome.SKIPPED); + } + + /** + * Asserts a task was part of a build result, and failed. + * + * @param result Build result. + * @param taskName Task name. + */ + public static void assertTaskFailed(final BuildResult result, final String taskName) { + assertTaskOutcome(result, taskName, TaskOutcome.FAILED); + } + /** * Asserts a task was not part of a build. * @@ -55,7 +95,7 @@ public static void assertTaskIgnored(final BuildResult result, final String task * @param taskName Task name. * @param expectedOutcome Expected outcome. */ - public static void assertTaskOutcome(final BuildResult result, final String taskName, + private static void assertTaskOutcome(final BuildResult result, final String taskName, final TaskOutcome expectedOutcome) { assertThat(getBuildResultTask(result, taskName).map(BuildTask::getOutcome) .orElseThrow(() -> new RuntimeException("Task not found: " + taskName))).isEqualTo(expectedOutcome); From eff13f19323a3350dad42616507e58eceee1b9d9 Mon Sep 17 00:00:00 2001 From: Vincent Bories-Azeau <5869062+vboriesazeau@users.noreply.github.com> Date: Thu, 12 Mar 2020 20:39:28 +0100 Subject: [PATCH 5/7] Fixed #70 (#76) --- README.md | 110 +++++++++++------- .../FrontendExtension.java | 15 ++- .../FrontendGradlePlugin.java | 7 +- .../core/DistributionInstallerSettings.java | 1 + .../AbstractPredefinedRunScriptTask.java | 7 +- .../tasks/AbstractRunScriptTask.java | 15 ++- .../tasks/NodeInstallTask.java | 9 +- .../tasks/YarnInstallTask.java | 9 +- .../FrontendGradlePluginTest.java | 14 +-- .../tasks/RunNodeTaskFuncTest.java | 2 +- .../tasks/RunScriptTaskFuncTest.java | 4 +- 11 files changed, 108 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index 46b2d1aa..0bc34d4a 100644 --- a/README.md +++ b/README.md @@ -97,60 +97,63 @@ All settings are introduced hereafter, with default value for each property. // build.gradle frontend { // NODE SETTINGS - // Node version, used to build the URL to download the corresponding distribution, if the 'nodeDistributionUrl' - // property is not set. - nodeVersion = '12.13.1' - - // [OPTIONAL] Sets this property to force the download from a custom website. By default, this property is - // 'null', and the plugin attempts to download the distribution compatible with the current platform from - // Node's website. The version of the distribution is expected to be the same as the one set in the - // 'nodeVersion' property, or this may lead to unexpected results. + // Node version, used to build the URL to download the corresponding distribution, if the + // 'nodeDistributionUrl' property is not set. + nodeVersion = '12.16.1' + + // [OPTIONAL] Sets this property to force the download from a custom website. By default, this + // property is 'null', and the plugin attempts to download the distribution compatible with the + // current platform from Node's website. The version of the distribution is expected to be the + // same as the one set in the 'nodeVersion' property, or this may lead to unexpected results. nodeDistributionUrl = 'https://nodejs.org/dist/vX.Y.Z/node-vX.Y.Z-win-x64.zip' // [OPTIONAL] Install directory where the distribution archive shall be exploded. - nodeInstallDirectory = "${projectDir}/node" + nodeInstallDirectory = file("${projectDir}/node") // YARN SETTINGS - // [OPTIONAL] Whether Yarn shall be used instead of NPM when executing frontend tasks. Consequently, a Yarn - // distribution will be downloaded and installed by the plugin. If , the 'yarnVersion' version property - // must be set. + // [OPTIONAL] Whether Yarn shall be used instead of NPM when executing frontend tasks. + // Consequently, a Yarn distribution will be downloaded and installed by the plugin. If , + // the 'yarnVersion' version property must be set. yarnEnabled = false - // [OPTIONAL] Yarn version, used to build the URL to download the corresponding distribution, if the - // 'yarnDistributionUrl' property is not set. This property is mandatory when the 'yarnEnabled' property is - // true. - yarnVersion = '1.19.2' + // [OPTIONAL] Yarn version, used to build the URL to download the corresponding distribution, if + // the 'yarnDistributionUrl' property is not set. This property is mandatory when the + // 'yarnEnabled' property is true. + yarnVersion = '1.22.4' - // [OPTIONAL] Sets this property to force the download from a custom website. By default, this property is - // 'null', and the plugin attempts to download the distribution compatible with the current platform from - // Yarn's website. The version of the distribution is expected to be the same as the one set in the - // 'yarnVersion' property, or this may lead to unexpected results. + // [OPTIONAL] Sets this property to force the download from a custom website. By default, this + // property is 'null', and the plugin attempts to download the distribution compatible with the + // current platform from Yarn's website. The version of the distribution is expected to be the + // same as the one set in the 'yarnVersion' property, or this may lead to unexpected results. yarnDistributionUrl = 'https://github.com/yarnpkg/yarn/releases/download/vX.Y.Z/yarn-vX.Y.Z.tar.gz' // [OPTIONAL] Install directory where the distribution archive shall be exploded. - yarnInstallDirectory = "${projectDir}/yarn" + yarnInstallDirectory = file("${projectDir}/yarn") // OTHER SETTINGS - // Name of the NPM/Yarn scripts (see 'package.json' file) that shall be executed depending on the Gradle - // lifecycle task. The values below are passed as argument of the 'npm' or 'yarn' executables. + // Name of the NPM/Yarn scripts (see 'package.json' file) that shall be executed depending on + // the Gradle lifecycle task. The values below are passed as argument of the 'npm' or 'yarn' + // executables. - // [OPTIONAL] Use this property to customize the command line used to install frontend dependencies. This - // property is used by the 'installFrontend' task. + // [OPTIONAL] Use this property to customize the command line used to install frontend + // dependencies. This property is used by the 'installFrontend' task. installScript = 'install' // [OPTIONAL] Use this property only if frontend's compiled resources are generated out of the - // '${project.buildDir}' directory. Default value is . This property is used by the 'cleanFrontend' task. - // The task is also executed when the Gradle built-in 'clean' task is executed, if this property is set. + // '${project.buildDir}' directory. Default value is . This property is used by the + // 'cleanFrontend' task. The task is also executed when the Gradle built-in 'clean' task is + // executed, if this property is set. cleanScript = 'run clean' - // [OPTIONAL] Script called to build frontend's artifacts. Default value is . This property is used by - // the 'assembleFrontend' task. - // The task is also executed when the Gradle built-in 'assemble' task is executed, if this property is set. + // [OPTIONAL] Script called to build frontend's artifacts. Default value is . This + // property is used by the 'assembleFrontend' task. The task is also executed when the Gradle + // built-in 'assemble' task is executed, if this property is set. assembleScript = 'run assemble' - // [OPTIONAL] Script called to check the frontend. Default value is . This property is used by the - // 'checkFrontend' task. The task is run when the Gradle built-in 'check' task is run. - // The task is also executed when the Gradle built-in 'check' task is executed, if this property is set. + // [OPTIONAL] Script called to check the frontend. Default value is . This property is + // used by the 'checkFrontend' task. The task is run when the Gradle built-in 'check' task is + // run. The task is also executed when the Gradle built-in 'check' task is executed, if this + // property is set. checkScript = 'run check' } ``` @@ -225,20 +228,39 @@ in the [Gradle base plugin][gradle-base-plugin]. ### Install Node -The `installNode` task downloads a Node distribution and verifies its integrity. If the `distributionUrl` property is -ommitted, the URL is guessed using the `version` property. Use the property `nodeInstallDirectory` to set the directory -where the distribution shall be installed, which, by default is the `${projectDir}/node` directory. +The `installNode` task downloads a Node distribution and verifies its integrity. If the `nodeDistributionUrl` property +is ommitted, the URL is guessed using the `nodeVersion` property. Use the property `nodeInstallDirectory` to set the +directory where the distribution shall be installed, which by default is the `${projectDir}/node` directory. The task +takes advantage of [Gradle incremental build][gradle-incremental-build], and is not executed again unless at least one +of the events below occurs: + +- the plugins change in the project. +- the task is executed for the first time. +- At least one of the properties `nodeVersion`, `nodeDistributionUrl`, `nodeInstallDirectory` is modified. +- The content of the directory pointed by the `nodeInstallDirectory` is modified. + +In other cases, the task will be marked as _UP-TO-DATE_ during a Gradle build, and skipped. This task should not be executed directly. It will be called automatically by Gradle, if another task depends on it. - + ### Install Yarn -The `installYarn` task downloads a Yarn distribution, if `yarnEnabled` property is `true`. If the `distributionUrl` -property is ommitted, the URL is guessed using the `version` property. Use the property `yarnInstallDirectory` to set -the directory where the distribution shall be installed, which, by default is the `${projectDir}/yarn` directory. +The `installYarn` task downloads a Yarn distribution, if `yarnEnabled` property is `true`. If the `yarnInstallDirectory` +property is ommitted, the URL is guessed using the `yarnVersion` property. Use the property `yarnInstallDirectory` to +set the directory where the distribution shall be installed, which, by default is the `${projectDir}/yarn` directory. +The task takes advantage of [Gradle incremental build][gradle-incremental-build], and is not executed again unless at +least one of the events below occurs: + +- the plugins change in the project. +- the task is executed for the first time. +- At least one of the properties `yarnEnabled`, `yarnVersion`, `yarnDistributionUrl`, `yarnInstallDirectory` is +modified. +- The content of the directory pointed by the `yarnInstallDirectory` is modified. + +In other cases, the task will be marked as _UP-TO-DATE_ during a Gradle build, and skipped. This task should not be executed directly. It will be called automatically by Gradle, if another task depends on it. - + ### Install frontend dependencies Depending on the value of the `yarnEnabled` property, the `installFrontend` task issues either a `npm install` command @@ -281,8 +303,9 @@ instance, the code below added in the `build.gradle` file allows to run a JS `my ```groovy tasks.register('myCustomScript', org.siouan.frontendgradleplugin.tasks.RunNodeTask) { - // Choose whether Node only is required, or if additional dependencies located in the package.json file should - // be installed: make the task either depends on 'installNode' task or on 'installFrontend' task. + // Choose whether Node only is required, or if additional dependencies located in the + // package.json file should be installed: make the task either depends on 'installNode' task or + // on 'installFrontend' task. // dependsOn tasks.named('installNode') // dependsOn tasks.named('installFrontend') script = 'my-custom-script.js' @@ -394,6 +417,7 @@ actions of your choice. [gradle-base-plugin]: (Gradle Base plugin) [gradle-build-script-block]: (Gradle build script block) [gradle-dsl]: (Gradle DSL) +[gradle-incremental-build]: (Gradle incremental build) [gradle-java-plugin]: (Gradle Java plugin) [gradle-spring-boot-plugin]: (Gradle Spring Boot plugin) [jdk]: (Java Development Kit) diff --git a/src/main/java/org/siouan/frontendgradleplugin/FrontendExtension.java b/src/main/java/org/siouan/frontendgradleplugin/FrontendExtension.java index e9340684..ad59fea2 100644 --- a/src/main/java/org/siouan/frontendgradleplugin/FrontendExtension.java +++ b/src/main/java/org/siouan/frontendgradleplugin/FrontendExtension.java @@ -1,8 +1,7 @@ package org.siouan.frontendgradleplugin; -import java.io.File; - import org.gradle.api.Project; +import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.Property; /** @@ -23,7 +22,7 @@ public class FrontendExtension { /** * Directory where the Node distribution shall be installed. */ - private final Property nodeInstallDirectory; + private final DirectoryProperty nodeInstallDirectory; /** * URL to download the Node distribution. @@ -38,7 +37,7 @@ public class FrontendExtension { /** * Directory where the distribution shall be installed. */ - private final Property yarnInstallDirectory; + private final DirectoryProperty yarnInstallDirectory; /** * URL to download the distribution. @@ -68,10 +67,10 @@ public class FrontendExtension { public FrontendExtension(final Project project) { yarnEnabled = project.getObjects().property(Boolean.class); nodeVersion = project.getObjects().property(String.class); - nodeInstallDirectory = project.getObjects().property(File.class); + nodeInstallDirectory = project.getObjects().directoryProperty(); nodeDistributionUrl = project.getObjects().property(String.class); yarnVersion = project.getObjects().property(String.class); - yarnInstallDirectory = project.getObjects().property(File.class); + yarnInstallDirectory = project.getObjects().directoryProperty(); yarnDistributionUrl = project.getObjects().property(String.class); installScript = project.getObjects().property(String.class); cleanScript = project.getObjects().property(String.class); @@ -87,7 +86,7 @@ public Property getNodeVersion() { return nodeVersion; } - public Property getNodeInstallDirectory() { + public DirectoryProperty getNodeInstallDirectory() { return nodeInstallDirectory; } @@ -99,7 +98,7 @@ public Property getYarnVersion() { return yarnVersion; } - public Property getYarnInstallDirectory() { + public DirectoryProperty getYarnInstallDirectory() { return yarnInstallDirectory; } diff --git a/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java b/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java index ecebbefa..28049e65 100644 --- a/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java +++ b/src/main/java/org/siouan/frontendgradleplugin/FrontendGradlePlugin.java @@ -1,6 +1,5 @@ package org.siouan.frontendgradleplugin; -import java.io.File; import java.util.function.BiPredicate; import org.gradle.api.Plugin; @@ -97,9 +96,11 @@ public void apply(final Project project) { final FrontendExtension extension = project.getExtensions() .create(EXTENSION_NAME, FrontendExtension.class, project); - extension.getNodeInstallDirectory().convention(new File(project.getProjectDir(), DEFAULT_NODE_INSTALL_DIRNAME)); + extension.getNodeInstallDirectory() + .convention(project.getLayout().getProjectDirectory().dir(DEFAULT_NODE_INSTALL_DIRNAME)); extension.getYarnEnabled().convention(false); - extension.getYarnInstallDirectory().convention(new File(project.getProjectDir(), DEFAULT_YARN_INSTALL_DIRNAME)); + extension.getYarnInstallDirectory() + .convention(project.getLayout().getProjectDirectory().dir(DEFAULT_YARN_INSTALL_DIRNAME)); extension.getInstallScript().convention(DEFAULT_INSTALL_SCRIPT); final TaskContainer projectTasks = project.getTasks(); diff --git a/src/main/java/org/siouan/frontendgradleplugin/core/DistributionInstallerSettings.java b/src/main/java/org/siouan/frontendgradleplugin/core/DistributionInstallerSettings.java index 92a78efd..2c4a2dda 100644 --- a/src/main/java/org/siouan/frontendgradleplugin/core/DistributionInstallerSettings.java +++ b/src/main/java/org/siouan/frontendgradleplugin/core/DistributionInstallerSettings.java @@ -49,6 +49,7 @@ public class DistributionInstallerSettings { * * @param task Related Gradle task. * @param osName O/S name. + * @param temporaryDirectory Directory where the distribution being downloaded will be temporarily stored. * @param urlResolver Resolver of the download URL. * @param downloader Downloader. * @param validator Distribution validator. diff --git a/src/main/java/org/siouan/frontendgradleplugin/tasks/AbstractPredefinedRunScriptTask.java b/src/main/java/org/siouan/frontendgradleplugin/tasks/AbstractPredefinedRunScriptTask.java index 17d221cc..6664a0c7 100644 --- a/src/main/java/org/siouan/frontendgradleplugin/tasks/AbstractPredefinedRunScriptTask.java +++ b/src/main/java/org/siouan/frontendgradleplugin/tasks/AbstractPredefinedRunScriptTask.java @@ -1,7 +1,6 @@ package org.siouan.frontendgradleplugin.tasks; -import java.io.File; - +import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Internal; @@ -23,13 +22,13 @@ public Property getYarnEnabled() { @Internal @Optional - public Property getNodeInstallDirectory() { + public DirectoryProperty getNodeInstallDirectory() { return nodeInstallDirectory; } @Internal @Optional - public Property getYarnInstallDirectory() { + public DirectoryProperty getYarnInstallDirectory() { return yarnInstallDirectory; } } diff --git a/src/main/java/org/siouan/frontendgradleplugin/tasks/AbstractRunScriptTask.java b/src/main/java/org/siouan/frontendgradleplugin/tasks/AbstractRunScriptTask.java index 7a34222d..675900c4 100644 --- a/src/main/java/org/siouan/frontendgradleplugin/tasks/AbstractRunScriptTask.java +++ b/src/main/java/org/siouan/frontendgradleplugin/tasks/AbstractRunScriptTask.java @@ -1,8 +1,7 @@ package org.siouan.frontendgradleplugin.tasks; -import java.io.File; - import org.gradle.api.DefaultTask; +import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.TaskAction; import org.siouan.frontendgradleplugin.core.ExecutableNotFoundException; @@ -25,12 +24,12 @@ public abstract class AbstractRunScriptTask extends DefaultTask { /** * Directory where the Node distribution is installed. */ - final Property nodeInstallDirectory; + final DirectoryProperty nodeInstallDirectory; /** * Directory where the Yarn distribution is installed. */ - final Property yarnInstallDirectory; + final DirectoryProperty yarnInstallDirectory; /** * The script to run with NPM/Yarn. @@ -45,8 +44,8 @@ public abstract class AbstractRunScriptTask extends DefaultTask { AbstractRunScriptTask(boolean failOnMissingScriptEnabled) { yarnEnabled = getProject().getObjects().property(Boolean.class); - nodeInstallDirectory = getProject().getObjects().property(File.class); - yarnInstallDirectory = getProject().getObjects().property(File.class); + nodeInstallDirectory = getProject().getObjects().directoryProperty(); + yarnInstallDirectory = getProject().getObjects().directoryProperty(); script = getProject().getObjects().property(String.class); this.failOnMissingScriptEnabled = failOnMissingScriptEnabled; } @@ -65,8 +64,8 @@ protected Executor getExecutionType() { @TaskAction public void execute() throws MissingScriptException, ExecutableNotFoundException { if (script.isPresent()) { - new RunScriptJob(this, getExecutionType(), nodeInstallDirectory.get(), yarnInstallDirectory.get(), - script.get(), Utils.getSystemOsName()).run(); + new RunScriptJob(this, getExecutionType(), nodeInstallDirectory.getAsFile().get(), + yarnInstallDirectory.getAsFile().get(), script.get(), Utils.getSystemOsName()).run(); } else if (failOnMissingScriptEnabled) { throw new MissingScriptException(); } diff --git a/src/main/java/org/siouan/frontendgradleplugin/tasks/NodeInstallTask.java b/src/main/java/org/siouan/frontendgradleplugin/tasks/NodeInstallTask.java index 500bd4e1..3e24d062 100644 --- a/src/main/java/org/siouan/frontendgradleplugin/tasks/NodeInstallTask.java +++ b/src/main/java/org/siouan/frontendgradleplugin/tasks/NodeInstallTask.java @@ -4,6 +4,7 @@ import java.security.NoSuchAlgorithmException; import org.gradle.api.DefaultTask; +import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Optional; @@ -33,7 +34,7 @@ public class NodeInstallTask extends DefaultTask { /** * Directory where the Node distribution shall be installed. */ - private final Property nodeInstallDirectory; + private final DirectoryProperty nodeInstallDirectory; /** * URL to download the Node distribution. @@ -42,7 +43,7 @@ public class NodeInstallTask extends DefaultTask { public NodeInstallTask() { nodeVersion = getProject().getObjects().property(String.class); - nodeInstallDirectory = getProject().getObjects().property(File.class); + nodeInstallDirectory = getProject().getObjects().directoryProperty(); nodeDistributionUrl = getProject().getObjects().property(String.class); } @@ -59,7 +60,7 @@ public Property getNodeDistributionUrl() { @OutputDirectory @Optional - public Property getNodeInstallDirectory() { + public DirectoryProperty getNodeInstallDirectory() { return nodeInstallDirectory; } @@ -74,7 +75,7 @@ public Property getNodeInstallDirectory() { public void execute() throws DistributionInstallerException, NoSuchAlgorithmException { final String version = nodeVersion.get(); final String distributionUrl = nodeDistributionUrl.getOrNull(); - final File installDirectory = nodeInstallDirectory.get(); + final File installDirectory = nodeInstallDirectory.getAsFile().get(); final DistributionInstallerSettings settings = new DistributionInstallerSettings(this, Utils.getSystemOsName(), getTemporaryDir().toPath(), new NodeDistributionUrlResolver(version, distributionUrl), new DownloaderImpl(getTemporaryDir().toPath()), new NodeDistributionValidator(this, new DownloaderImpl(getTemporaryDir().toPath()), diff --git a/src/main/java/org/siouan/frontendgradleplugin/tasks/YarnInstallTask.java b/src/main/java/org/siouan/frontendgradleplugin/tasks/YarnInstallTask.java index df0a08cb..2e2618d1 100644 --- a/src/main/java/org/siouan/frontendgradleplugin/tasks/YarnInstallTask.java +++ b/src/main/java/org/siouan/frontendgradleplugin/tasks/YarnInstallTask.java @@ -3,6 +3,7 @@ import java.io.File; import org.gradle.api.DefaultTask; +import org.gradle.api.file.DirectoryProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Optional; @@ -29,7 +30,7 @@ public class YarnInstallTask extends DefaultTask { /** * Directory where the distribution shall be installed. */ - private final Property yarnInstallDirectory; + private final DirectoryProperty yarnInstallDirectory; /** * URL to download the distribution. @@ -38,7 +39,7 @@ public class YarnInstallTask extends DefaultTask { public YarnInstallTask() { yarnVersion = getProject().getObjects().property(String.class); - yarnInstallDirectory = getProject().getObjects().property(File.class); + yarnInstallDirectory = getProject().getObjects().directoryProperty(); yarnDistributionUrl = getProject().getObjects().property(String.class); } @@ -55,7 +56,7 @@ public Property getYarnDistributionUrl() { @OutputDirectory @Optional - public Property getYarnInstallDirectory() { + public DirectoryProperty getYarnInstallDirectory() { return yarnInstallDirectory; } @@ -69,7 +70,7 @@ public void execute() throws DistributionInstallerException { final DistributionInstallerSettings settings = new DistributionInstallerSettings(this, Utils.getSystemOsName(), getTemporaryDir().toPath(), new YarnDistributionUrlResolver(yarnVersion.get(), yarnDistributionUrl.getOrNull()), new DownloaderImpl(getTemporaryDir().toPath()), null, new ArchiverFactoryImpl(), - yarnInstallDirectory.map(File::toPath).getOrNull()); + yarnInstallDirectory.getAsFile().map(File::toPath).getOrNull()); new DistributionInstaller(settings).install(); } } diff --git a/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java b/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java index 20559043..3f25e6d9 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/FrontendGradlePluginTest.java @@ -2,8 +2,6 @@ import static org.assertj.core.api.Assertions.assertThat; -import java.io.File; - import org.gradle.api.Project; import org.gradle.testfixtures.ProjectBuilder; import org.junit.jupiter.api.BeforeEach; @@ -41,10 +39,10 @@ void shouldRegisterTasksWithDefaultExtensionValuesWhenApplied() { assertThat(extension).isNotNull(); assertThat(extension.getYarnEnabled().get()).isFalse(); - assertThat(extension.getNodeInstallDirectory().get()) - .isEqualTo(new File(project.getProjectDir(), FrontendGradlePlugin.DEFAULT_NODE_INSTALL_DIRNAME)); - assertThat(extension.getYarnInstallDirectory().get()) - .isEqualTo(new File(project.getProjectDir(), FrontendGradlePlugin.DEFAULT_YARN_INSTALL_DIRNAME)); + assertThat(extension.getNodeInstallDirectory().getAsFile().get()) + .isEqualTo(project.file(FrontendGradlePlugin.DEFAULT_NODE_INSTALL_DIRNAME)); + assertThat(extension.getYarnInstallDirectory().getAsFile().get()) + .isEqualTo(project.file(FrontendGradlePlugin.DEFAULT_YARN_INSTALL_DIRNAME)); final NodeInstallTask nodeInstallTask = project.getTasks() .named(FrontendGradlePlugin.NODE_INSTALL_TASK_NAME, NodeInstallTask.class).get(); @@ -117,11 +115,11 @@ void shouldRegisterTasksWithCustomExtensionValuesWhenApplied() { final FrontendExtension extension = project.getExtensions().findByType(FrontendExtension.class); extension.getNodeVersion().set("3.65.4"); extension.getNodeDistributionUrl().set("https://node"); - extension.getNodeInstallDirectory().set(new File(project.getProjectDir(), "node-dist")); + extension.getNodeInstallDirectory().set(project.file("node-dist")); extension.getYarnEnabled().set(true); extension.getYarnVersion().set("6.5.4"); extension.getYarnDistributionUrl().set("http://yarn"); - extension.getYarnInstallDirectory().set(new File(project.getProjectDir(), "yarn-dist")); + extension.getYarnInstallDirectory().set(project.file("yarn-dist")); extension.getCleanScript().set("clean"); extension.getAssembleScript().set("assemble"); extension.getCheckScript().set("test"); diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/RunNodeTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/RunNodeTaskFuncTest.java index 28946f0f..799ab40a 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/RunNodeTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/RunNodeTaskFuncTest.java @@ -42,7 +42,7 @@ void shouldRunScriptFrontendWithNode() throws IOException { final Path tmpScriptPath = tmpDirectory.toPath().resolve("script.js"); createScriptFile(tmpScriptPath); final Map properties = new HashMap<>(); - properties.put("nodeVersion", "12.13.1"); + properties.put("nodeVersion", "12.16.1"); final String customTaskName = "helloMyFriend"; final String customTaskDefinition = "tasks.register('" + customTaskName diff --git a/src/test/java/org/siouan/frontendgradleplugin/tasks/RunScriptTaskFuncTest.java b/src/test/java/org/siouan/frontendgradleplugin/tasks/RunScriptTaskFuncTest.java index af3ab980..c37ff779 100644 --- a/src/test/java/org/siouan/frontendgradleplugin/tasks/RunScriptTaskFuncTest.java +++ b/src/test/java/org/siouan/frontendgradleplugin/tasks/RunScriptTaskFuncTest.java @@ -42,7 +42,7 @@ void shouldRunScriptFrontendWithNpmOrYarn() throws IOException, URISyntaxExcepti Files.copy(new File(getClass().getClassLoader().getResource("package-npm.json").toURI()).toPath(), projectDirectory.resolve("package.json")); final Map properties = new HashMap<>(); - properties.put("nodeVersion", "12.13.1"); + properties.put("nodeVersion", "12.16.1"); final String customTaskName = "e2e"; final StringBuilder customTaskDefinition = new StringBuilder("tasks.register('"); customTaskDefinition.append(customTaskName); @@ -70,7 +70,7 @@ void shouldRunScriptFrontendWithNpmOrYarn() throws IOException, URISyntaxExcepti Files.copy(new File(getClass().getClassLoader().getResource("package-yarn.json").toURI()).toPath(), projectDirectory.resolve("package.json"), StandardCopyOption.REPLACE_EXISTING); properties.put("yarnEnabled", true); - properties.put("yarnVersion", "1.19.2"); + properties.put("yarnVersion", "1.22.4"); Helper.createBuildFile(projectDirectory, properties, customTaskDefinition.toString()); final BuildResult result3 = runGradle(projectDirectory, customTaskName); From 5e1fbbd5b79c97bdf5b1aa7302d5efbae294df5f Mon Sep 17 00:00:00 2001 From: Vincent Bories-Azeau <5869062+vboriesazeau@users.noreply.github.com> Date: Thu, 12 Mar 2020 22:22:59 +0100 Subject: [PATCH 6/7] Fixed #59 (#77) --- README.md | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 115 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0bc34d4a..5957734b 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ install/configure the plugin, and build your frontend application. ## Quick start guide +For convenience, configuration blocks in this guide are introduced with both Groovy and Kotlin syntaxes. + ### Requirements The plugin supports: @@ -62,6 +64,8 @@ The plugin is built and tested on Linux, Mac OS, Windows. For a full list of bui This is the modern and recommended approach. +- Groovy syntax: + ```groovy // build.gradle plugins { @@ -69,10 +73,21 @@ plugins { } ``` +- Kotlin syntax: + +```kotlin +// build.gradle.kts +plugins { + id("org.siouan.frontend") version "1.3.1" +} +``` + #### Using [Gradle build script block][gradle-build-script-block] This approach is the legacy way to resolve and apply plugins. +- Groovy syntax: + ```groovy // build.gradle buildscript { @@ -87,12 +102,30 @@ buildscript { apply plugin: 'org.siouan.frontend' ``` +- Kotlin syntax: + +```kotlin +// build.gradle.kts +buildscript { + repositories { + url = uri("https://plugins.gradle.org/m2/") + } + dependencies { + classpath("org.siouan:frontend-gradle-plugin:1.3.1") + } +} + +apply(plugin = "org.siouan.frontend") +``` + ### Configuration #### DSL reference All settings are introduced hereafter, with default value for each property. +- Groovy syntax: + ```groovy // build.gradle frontend { @@ -158,6 +191,25 @@ frontend { } ``` +- Kotlin syntax: + +```kotlin +// build.gradle.kts +frontend { + nodeVersion.set("12.16.1") + nodeDistributionUrl.set("https://nodejs.org/dist/vX.Y.Z/node-vX.Y.Z-win-x64.zip") + nodeInstallDirectory.set(project.layout.projectDirectory.dir("node")) + yarnEnabled.set(false) + yarnVersion.set("1.22.4") + yarnDistributionUrl.set("https://github.com/yarnpkg/yarn/releases/download/vX.Y.Z/yarn-vX.Y.Z.tar.gz") + yarnInstallDirectory.set(project.layout.projectDirectory.dir("yarn")) + installScript.set("install") + cleanScript.set("run clean") + assembleScript.set("run assemble") + checkScript.set("run check") +} +``` + #### Typical configuration with NPM ```groovy @@ -298,33 +350,61 @@ execute tests, and perform additional analysis tasks. This task depends on the ` ### Run custom Node script The plugin provides the task type `org.siouan.frontendgradleplugin.tasks.RunNodeTask` that allows creating a custom -task to launch a frontend script. The `script` property must be set with the corresponding Node command. For -instance, the code below added in the `build.gradle` file allows to run a JS `my-custom-script.js` with Node: +task to launch a frontend script. The `script` property must be set with the corresponding Node command. Then, choose +whether Node only is required, or if additional dependencies located in the `package.json` file should be installed: +make the task either depends on `installNode` task or on `installFrontend` task. + +The code below shows the configuration required to run a JS `my-custom-script.js` with Node: + +- Groovy syntax: ```groovy +// build.gradle tasks.register('myCustomScript', org.siouan.frontendgradleplugin.tasks.RunNodeTask) { - // Choose whether Node only is required, or if additional dependencies located in the - // package.json file should be installed: make the task either depends on 'installNode' task or - // on 'installFrontend' task. // dependsOn tasks.named('installNode') // dependsOn tasks.named('installFrontend') script = 'my-custom-script.js' } ``` +- Kotlin syntax: + +```kotlin +// build.gradle.kts +tasks.register("myCustomScript") { + // dependsOn(tasks.named("installNode")) + // dependsOn(tasks.named("installFrontend")) + script.set("my-custom-script.js") +} +``` + ### Run custom NPM/Yarn script The plugin provides the task type `org.siouan.frontendgradleplugin.tasks.RunScriptTask` that allows creating a custom -task to launch a frontend script. The `script` property must be set with the corresponding NPM/Yarn command. For -instance, the code below added in the `build.gradle` file allows to run frontend's end-to-end tests in a custom task: +task to launch a frontend script. The `script` property must be set with the corresponding NPM/Yarn command. + +The code below shows the configuration required to run frontend's end-to-end tests in a custom task: + +- Groovy syntax: ```groovy +// build.gradle tasks.register('e2e', org.siouan.frontendgradleplugin.tasks.RunScriptTask) { dependsOn tasks.named('installFrontend') script = 'run e2e' } ``` +- Kotlin syntax: + +```kotlin +// build.gradle.kts +tasks.register("e2e") { + dependsOn(tasks.named("installFrontend")) + script.set("run e2e") +} +``` + ## Usage guidelines ### How to assemble a frontend and a Java backend into a single artifact? @@ -358,9 +438,12 @@ gradlew taskTree --no-repeat assemble `${frontendBuildDir}` directory, these artifacts must be copied, generally in the `${project.buildDir}/resources/main/public` directory, so as they can be served by the backend. -Let's create a custom task for this. Add the following lines in the `build.gradle` file: +Let's create a custom task for this. + +- Groovy syntax: ```groovy +// build.gradle tasks.register('processFrontendResources', Copy) { description 'Process frontend resources' from "${frontendBuildDir}" @@ -369,6 +452,18 @@ tasks.register('processFrontendResources', Copy) { } ``` +- Kotlin syntax: + +```kotlin +// build.gradle.kts +tasks.register("processFrontendResources") { + description = "Process frontend resources" + from(file("${frontendBuildDir}")) + into(file("${project.buildDir}/resources/main/public")) + dependsOn(tasks.named("assembleFrontend")) +} +``` + Finally, you should: - Replace the `${frontendBuildDir}` variable by any relevant directory, depending on where the frontend artifacts are @@ -379,12 +474,24 @@ generated by your assembling script. Our recommendation is the `processResources` task depends on the `processFrontendResources` task. +- Groovy syntax: + ```groovy +// build.gradle tasks.named('processResources').configure { dependsOn tasks.named('processFrontendResources') } ``` +- Kotlin syntax: + +```kotlin +// build.gradle.kts +tasks.named("processResources").configure { + dependsOn(tasks.named("processFrontendResources")) +} +``` + The resulting task tree shall be as below: ```sh From a38b8ae86a415aa2efe7cea70b476d67f2fb6af6 Mon Sep 17 00:00:00 2001 From: Vincent Bories-Azeau <5869062+vboriesazeau@users.noreply.github.com> Date: Fri, 13 Mar 2020 09:13:08 +0100 Subject: [PATCH 7/7] Added special thanks section. (#78) --- CONTRIBUTING.md | 6 +++--- README.md | 19 +++++++++++++++++-- intellij-idea-128x128.png | Bin 0 -> 3657 bytes jetbrains-128x128.png | Bin 0 -> 2627 bytes 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 intellij-idea-128x128.png create mode 100644 jetbrains-128x128.png diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c7bf903..aad4956e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,11 +66,11 @@ repository. The configuration actually allows to build and test the plugin on th - Windows Server 2016 version 1803 / AdoptOpenJDK OpenJ9 1.8.0-232 64 bits Ubuntu Xenial is the reference environment, used to analyze the source code with SonarCloud. By now, the plugin has been -developed on Windows 10 Home with OracleJDK 1.8.0_202 64 bits and [JetBrains IntelliJ IDEA][intellij]. +developed on Windows 10 Home with OracleJDK 1.8.0_202 64 bits and [JetBrains IntelliJ IDEA][intellij-idea]. -*Note: continuous integration of Java projects on Windows is not supported by Travis yet.* +*Note: continuous integration of Java projects on Windows is at an early stage for the moment.* [apache-commons-compress]: (Apache Commons Compress) -[intellij]: (IntelliJ IDEA) +[intellij-idea]: (IntelliJ IDEA) [issues]: (Issues) [travis]: (Travis CI) diff --git a/README.md b/README.md index 5957734b..6449a88f 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ install/configure the plugin, and build your frontend application. - [Usage guidelines](#usage-guidelines) - [How to assemble a frontend and a Java backend into a single artifact?](#how-to-assemble-a-frontend-and-a-java-backend-into-a-single-artifact) - [What kind of script should I attach to the `checkFrontend` task?](#what-kind-of-script-should-i-attach-to-the-checkfrontend-task) +- [Special thanks](#special-thanks) - [Contributing][contributing] ## Quick start guide @@ -287,7 +288,6 @@ takes advantage of [Gradle incremental build][gradle-incremental-build], and is of the events below occurs: - the plugins change in the project. -- the task is executed for the first time. - At least one of the properties `nodeVersion`, `nodeDistributionUrl`, `nodeInstallDirectory` is modified. - The content of the directory pointed by the `nodeInstallDirectory` is modified. @@ -304,7 +304,6 @@ The task takes advantage of [Gradle incremental build][gradle-incremental-build] least one of the events below occurs: - the plugins change in the project. -- the task is executed for the first time. - At least one of the properties `yarnEnabled`, `yarnVersion`, `yarnDistributionUrl`, `yarnInstallDirectory` is modified. - The content of the directory pointed by the `yarnInstallDirectory` is modified. @@ -518,6 +517,18 @@ tests, or functional tests, or a linter, or any other verification action, or ev combination is even possible, since you can define a script in your `package.json` file that executes sequentially the actions of your choice. +## Special thanks + +The plugin is developed using [Intellij IDEA][intellij-idea], special thanks to [JetBrains][jetbrains] for this amazing +IDE, and their support to this project. + +![Jetbrains logo][jetbrains-logo] +![IntelliJ IDEA logo][intellij-idea-logo] + +With their feedback, plugin improvement is possible. Special thanks to: + +@andreaschiona, @byxor, @ChFlick, @ckosloski, @mike-howell, @rolaca11, @TapaiBalazs + [contributing]: (Contributing to this project) [frontend-maven-plugin]: (Frontend Maven plugin) [gradle]: (Gradle) @@ -527,7 +538,11 @@ actions of your choice. [gradle-incremental-build]: (Gradle incremental build) [gradle-java-plugin]: (Gradle Java plugin) [gradle-spring-boot-plugin]: (Gradle Spring Boot plugin) +[intellij-idea]: (IntelliJ IDEA) +[intellij-idea-logo]: (IntelliJ IDEA) [jdk]: (Java Development Kit) +[jetbrains]: (JetBrains) +[jetbrains-logo]: (JetBrains) [node]: (Node.js) [release-notes]: (Release notes) [spring-boot]: (Spring Boot) diff --git a/intellij-idea-128x128.png b/intellij-idea-128x128.png new file mode 100644 index 0000000000000000000000000000000000000000..ac6fdc311fd3634b1b5a1df35b409ebb4b34e3df GIT binary patch literal 3657 zcmeHK`8(8$|9!v5dze8*mPVGbg>G5PcC*YFYcvU|E<#e-8lh_$%gkt@7z!~sbiXJ70J|LQtzCXI z=|3QZe(yEbJstoE0nSctHd$F&Tl!vGo&Rj%g2jmIg5<)rBfg6m!X6TD)+kUiW|?Ig zilS_MJr*%+_4j8BB8oU?pZRYqmaG;z^;^p3&JSGzOOL=Z3Le1_C%3n^wTQ#=q($77 zey2;HT~mMf_%Q5pHvD{=>V|mke(iiua)8%cEz0bSUDO9m94AI9!na~NTAfcjJs5pt z{PeA;bLBeeJRV80BMLh@I-2N3H#Rm72?^mPYt!vhc@J&N9H?cdZsTdZkCU659oa>0 zxz8LkH~Z;1`0NMHc|{&iZ=HT|?^HqDnNr7?T5Jr{jMQU7{HRat(lQWA=5g0*^rNKV%fL7OAWgHB=nv23Oxvw}@95{QQ>8@nf{rE^_W#yj0YQs?#;%ULHno6H$?ia|QWYg8G zmYbCvHJ%|ipINcMJ?YQ>6b2b(up5hyXr*~~F+R=TL`v(k^O&@~@t{x-Q8+P>yZ$7E znEN3KBsc; zOf-er(wb-q@A@ttdVeNmiN_61)TKKWV9_V+^)AyFkEsxkA4C(*NWNH=uzx}@l25%< zQl0V!8sngz(Boow2T+-$GTnSj4w9G4>`Z7UeB=gIxhx^`QS+aoGIBkno%4-pyA|$~HAw1eNvoys^0QAq9bdvyh_|V=kekMep^bQe8D5o@9mU z|K%Y;?^W3rPxQ`0kb>Y5_PXWDS8jVh!F2X@6e_X>B~mOzm8tlGQC`mSuf+_B{)~;a zz>L1BLsD0y$VStbks}K@zLq+vV(CxF2{;IFaK53B(sV1SL^w&F&Up>IcE!-P_d+Jy z63X=1+hh3J92~6)&$=?WqHGj<=e2gdU5n7W)+Ky#;ShTuuhksPi3T)-!}9H|FC_z! z@-#LKYB{>7c&T@8EeZFcPzL-NUPgoi#Llk}zHceQs_=6zpio;GFJzwY2Xp7^6b>{D z{ZiU572rrBnlI;j=x|hMxtG81L1r%#&2i7Qo4l6wMAmZuA)JA}Zt$qn+t) z{=k>~@FZU?)*Rt{h=~i!GtfJbu6=!WkQSfgfge)w86u8Zd|N`_*%5}$56>FEj}G9- zFCz6UpeUTe(_S_T0CQqfV@4K6siTHui@Ot+?W41Z*>Kq0Uk!bMXSrTO5dRBxPVEjN z=Llx!Z4G@qz~>!ya%s`Gd?uSA&$P5KC9kT$LFuM9hQW)*QKf@U504Scko2{Vtqe5& z1^>z}Np)ED2w^_3q`dJ<#0fwg&oAyE?5gis$x$9PjLwSbaa@R_M808s$jO+JdP)+N z4p^QrUM-7g`lqN`<63Ab;MBn zcgI&bE<`S!r!eMB&!ANca2c{K{;-RbB~P+zMR>oGD56m~=Xz`fXK91u-Jls7&wtR{ zS_SQGn$bSU9!+5gIQyE3Ub|UW)(32$Zjr=2Zrk=SYe4Qwl|g(S@bE^$^0MDSnApy^ zl~1Sz4OEtLR##!07lyH!ED9=9h0aFXc_2}D9T&q7P0ClE75NE`t3l7Cxm$g2W&G`( zR{Ws-co=2qYwy}B)T!bOgu9V3?`_L#4blY&D;-ds*>QIPdc{JA@~_FJL*U$!pTr}D zSbKW5&@&k>P6ea_kzfG?D8xQ-WQB!DOPjvsPgu%KqC??E_wYirB#N#HV{ouK2yOxo*xl~fJ!D=TUu#>z9{40dTKua_ zMyvjEdU*5fl0xFIAdV?%FKKg1Jkvv#w=Y+M^6OVY5L^%0Yt}{ZzTh0uao1MGhG7cc z0o%P<`W4?eT6NynqYc%O^TtXcRicnHcrPj!{&Af1LDN~@1uFBBVyV;jd2p!%!my#% z@13S#iq$iJ8y2D7-%d2e^ETkepouU~$m>|u{p+qp5-2c^7MU%!JtlirebUr>+oY6g z`y=6R2e{VG*XuoBfYT^SU(|FS>E}p?zx`*zepv*DjT?gK;w@p2%~{@DX>BYFvQ$b{ zl%mawm~E4LY%nqhzK5C>DU0W))hocfMbpKx)mU;u`lcF3G*qT#7w)9SxkQ=$&RJX9+bY71tHJ)_+`r0p%z zGL~~Zge#(?@`yvDU$ zy_hZ#Mc?@ydee-pNoyjTLSk%p$Uf~xY_N!yU$Fe6@%r)f8`FOZPO1QhO;dX{+4+S% zdn)o1ntc6WoGy~Oj~LS8_>$(8wjBMDnwBnK3(+ta5*(dosW|{SU@D{xraGK=6vp%S zG<}QpUF#SQz6D(bRU6dMkAv-GPtf&WH_CWFGwfZpn3e_A^U{GpCulFrk&ori(S$=A z2?Rnqm_(XpB#MLM;^iKcPF(%vZu!EOf}70|`q=igndIBC`AK|khYv}Yzamw#lO)NI zOqXVsvKuxY<-M&Men?pkuylE*v)1rvfjwX|1sOe;P>Fz)UjeoHk&bC ze5~IL5MM%wn1L7Hg_eHZHk3Pgjuf!hQ4zz2@5C;PnS$>V7(I*RZXBRK?V~|&PPA;lmTX%$KAG3#jSlrH2A9c?#YR>+}KLDrnK&t~~)}D!0$f`+@V% zO>}P#tW8jp{5az%J_N4A&xdDK=OekLo-8_)K?+5oZru`-g(Mh?mW4DX1k#X@vg0} z5y^AbxUYlZ{cYSx0bH(Ip5d2ehX|R#ZuJN+e5fkpH{5b?nkutq4Rv*cCYdeTSb6fl zmYP&YVT&|yE=>)5nRpa#`Mp^Er1fPSOjW1|VKJj=KG-y)aoAu2k!RCc|8O-cWc|F0 aoWPRu_Hdn+aLAqiI)H->-nz`nhw?wcbME&5 literal 0 HcmV?d00001 diff --git a/jetbrains-128x128.png b/jetbrains-128x128.png new file mode 100644 index 0000000000000000000000000000000000000000..e6cd16ac444f2dafac2811b6c002424f76c3d07b GIT binary patch literal 2627 zcmeHIS6fqw7Cku$Ax1h#k&>VkL1_Xa5+HO$rAbu@L8XW^hbA>AC{;>81x7`{!cc~e z6qPoDI3i;lz;IDW0)v1e9D+iKkX-x=^K>8X{=T*Mw;tAB>)S6o+tt}Y6uTD-0D$Om zM_c!u3H<~HxzoR~3O4}&3Amp0umb?WvhU?(k8t?h<&`th%dSx{DQJas@vB4Z3ON7{ zATOUz;zooRE_`XRe)PP9Fr&(F@ze(IRVw5G5vpbqcSg@pzA-I$@Fp@tKM zEl#v=84mLD@|;BT;Nal3Oag1@j;`Hr;< zb^h0QjSpD2?nLwXr8hGvqMqVkL>i>oWu!(uW#{wImdct7nI)nmEP78`;iwu*W}kfA z2MZ5>?W4czFVTV3?o^xz`ZXYAuRK$!PjReR38ChTs41f%L-}tWpt;OKADJb_0Xs+M z)#VHOI>RkkPpCF>Q(0oWuD)P*`XS2~mw>fQ$)iT;sv7!AFT8Ig2R%bF##PB^mcB|} z1!YU6y|~|jZdsgPq1ORKAcd#)DeK1PkkPc|TzM1nxrcRI=--5 zh5r$yo&z&l>GoXumzbQABsV2gxlp=XVz7ED%b3=GtB!6qmC;jZsR%1$*2;nM+9S9# z8;>E&k^Oi?$3O|TGlg@>dY|!!4Nn2Y0F(8^K4z{ETa1WT{gCISyV{_Jt(2GrbAkZU zbPdLy9${cdhi|04V0WC#;Z|hyj~(jm%7Irc_690+oBpnds9WQ4N~YSOruY z^hO+cLj+qtEZNz^W1CuN!{FaC)=`+A+7f|B1A-(oI2gU6c?~MYKT^FO;D-pk?_#^L zDGp;5@yb07!zD3<61{@WtUv#`*Y^unKNEhQ57ikSt)<)tQQ|P|H~n2pLa;upb$zip z*{A|lo#e6W;8K63B$tyXvBW#i@eg^{)gLoj^yU16F`YUZn#iZ0kTP^^pzy49sN#S z3}1wf{@(0eOX93O1Se7?hGoJ;boJ)YcuLo~Nz6bK(%`@V+bwvea=UzZ-Kt-LZfR)> zhA6`Z7M}P2(0+iZ7WL7^<+FSdx%YVvH@F9obFlV43!?_1;&GvhNDs^eYr=4K&)DZZ zIHHtgCUD3eKhr0|c0{Urz0=MaQ|R<@2bePsue*~{E`rt)zhdQD(x^W5V+#5Xydno! znc7$&D}k5>qV~SlsXmYQDm+HT2!c%O&T$O}G!tFNiCG8c^-4_QK(GXoMWEh$ie8uP z?CSb+1=>nj_Yz}&{(PoDjp??jaOHtqWg_|?A{aR>6JfPYc&3e^TL!0(x}{v#a{Uhx zPpOgO-q#9xmI0Z9SVVkOcqCpQat95ox^*$<7Ew;%zJK=Iy6t5mF+;~RNOG?&ZSh`D z6cj;Zqerx=E9VQTG)mE2na#G(x%A8Y#$+PjLrUVM?1aKAm()%7JUnxd@mZH9`0{lr z03<_Zw1x{J_~TNSsma0~W0s@6jd@XGm<0)`t#*SZLe@znzSTDN8V@AXUK$}}YQpFc zph)&TS-A_*>|A8T)~ODqXF=R_R@CF$h9UMuwdP6cP0Uu#epjwEh6Tb{uU^T|yVd4u z2O4!~*6KBH@XI8CU86({9jBO6W4epCHM?v)Q$?xF!?~0^1gq6gV2r}JBs)PWwX^j? zEk?tSz>U0@DEnVE^;q35af>j8%h0&;UES z1^=y|E@ZWoii|iU`i%ni%5CJh zzdq0{6h14MUQti-S4oozxl8F~1Rj9J+VYqyqN%Eg1iiR--TCBTx&f6k`Epp#uEZrN zR(d&3XSOm2K|d98$f}M@DRgF}T-rUZ(Kc-n>#}zv0h<7Z&&J-407-)lusuI?&wAPF zC4`gI1fNpR$=kZbdnwj8t~-5?qGA(4Kg<+ik;-kg)7w`Ad)!?m+y0UhXQwNN;VAkD zU)V-&3keda`P>=Rvc?ElSh|8K?6)ee7;}q%0h|gGNTa7_7F`N&a)u>i-kQibr@h@X c$@?Zi%%%A!KD@bU^z%m_w{x~_uqLPd7jL=dr2qf` literal 0 HcmV?d00001