Skip to content

Commit

Permalink
fix: fixes serialization issues and compliance with Gradle configurat…
Browse files Browse the repository at this point in the history
…ion cache

Fixes #217
  • Loading branch information
v1nc3n4 committed Jun 8, 2024
1 parent d342389 commit f4e937d
Show file tree
Hide file tree
Showing 158 changed files with 1,435 additions and 1,640 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ frontend {
}

tasks.register<RunNode>("nodeVersion") {
dependsOn("installNode")
script.set("-v")
}

Expand Down
18 changes: 11 additions & 7 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ version = fgpVersion
description = fgpDescription

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withJavadocJar()
withSourcesJar()
}
Expand Down Expand Up @@ -102,12 +103,12 @@ tasks.named<Task>("check") {
tasks.named<JacocoReport>("jacocoTestReport") {
dependsOn(tasks.named("test"), tasks.named("integrationTest"))
executionData.setFrom(
file("${project.buildDir}/jacoco/test.exec"),
file("${project.buildDir}/jacoco/integrationTest.exec")
file("${project.layout.buildDirectory}/jacoco/test.exec"),
file("${project.layout.buildDirectory}/jacoco/integrationTest.exec")
)
reports {
xml.required.set(true)
xml.outputLocation.set(file("${buildDir}/reports/jacoco/report.xml"))
xml.outputLocation.set(file("${project.layout.buildDirectory}/reports/jacoco/report.xml"))
}
}

Expand All @@ -118,6 +119,8 @@ idea {
// Force integration test source set as test folder
testSources.from(project.sourceSets.getByName("intTest").java.srcDirs)
testResources.from(project.sourceSets.getByName("intTest").resources.srcDirs)
isDownloadJavadoc = true
isDownloadSources = true
}
}

Expand Down Expand Up @@ -158,13 +161,14 @@ sonarqube {
property("sonar.java.binaries", "build/classes/java/main")
property("sonar.java.test.binaries", "build/classes/java/test,build/classes/java/intTest")
property("sonar.junit.reportPaths", "build/test-results/test/,build/test-results/integrationTest/")
property("sonar.jacoco.xmlReportPaths", "${buildDir}/reports/jacoco/report.xml")
property("sonar.jacoco.xmlReportPaths", "${project.layout.buildDirectory}/reports/jacoco/report.xml")
property("sonar.java.test.binaries", "build/classes/java/test,build/classes/java/intTest")
property("sonar.verbose", true)

// Irrelevant duplications detected on task inputs
property(
"sonar.cpd.exclusions",
"**/org/siouan/frontendgradleplugin/domain/model/*.java,**/org/siouan/frontendgradleplugin/domain/usecase/Get*ExecutablePath.java"
"**/org/siouan/frontendgradleplugin/domain/model/*.java,**/org/siouan/frontendgradleplugin/domain/usecase/Resolve*ExecutablePath.java,**/org/siouan/frontendgradleplugin/infrastructure/gradle/FrontendExtension.java"
)
}
}
5 changes: 3 additions & 2 deletions plugin/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies {
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
1 change: 1 addition & 0 deletions plugin/lombok.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
lombok.log.fieldName=LOGGER
10 changes: 5 additions & 5 deletions plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ val fgpArtifactId: String by extra

pluginManagement {
plugins {
id("com.gradle.enterprise") version "3.17.4"
id("com.gradle.develocity") version "3.17.4"
id("com.gradle.plugin-publish") version "1.2.1"
id("org.sonarqube") version "5.0.0.4638"
}
}

plugins {
id("com.gradle.enterprise")
id("com.gradle.develocity")
}

rootProject.name = fgpArtifactId

gradleEnterprise {
develocity {
buildScan {
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use")
termsOfUseAgree.set("yes")
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package org.siouan.frontendgradleplugin.infrastructure.gradle;

import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.ASSEMBLE_TASK_NAME;
import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME;
import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertAssembleTaskOutcomes;
import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile;
import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle;
import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SKIPPED;
import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SUCCESS;
import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.UP_TO_DATE;
import static org.siouan.frontendgradleplugin.test.Resources.getResourcePath;
import static org.siouan.frontendgradleplugin.test.Resources.getResourceUrl;

Expand All @@ -14,16 +19,14 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.siouan.frontendgradleplugin.FrontendGradlePlugin;
import org.siouan.frontendgradleplugin.test.FrontendMapBuilder;
import org.siouan.frontendgradleplugin.test.PluginTaskOutcome;

/**
* Functional tests to verify the {@link AssembleTask} integration in a Gradle build. Test cases uses fake Node/Yarn
* distributions, to avoid the download overhead. The 'yarn' and 'npm' executables in these distributions simply call
* the 'node' executable with the same arguments.
* Functional tests to verify the {@link AssembleTask} integration in a Gradle build. Test cases uses fake
* Node/NPM/PNPM/Yarn distributions, to avoid the download overhead. The 'npm', 'pnpm', 'yarn' executables in these
* distributions simply call the 'node' executable with the same arguments.
*/
class AssembleTaskFuncTest {
class AssembleFrontedTaskFuncTest {

@TempDir
Path projectDirectoryPath;
Expand All @@ -36,23 +39,21 @@ void setUp() throws IOException {
}

@Test
void should_skip_task_when_package_json_file_is_not_a_file() throws IOException {
void should_skip_task_when_package_json_file_does_not_exist() throws IOException {
final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder()
.nodeVersion("18.17.1")
.nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip"))
.assembleScript("run assemble")
.packageJsonDirectory(packageJsonDirectoryPath);
createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap());

final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.ASSEMBLE_TASK_NAME);
final BuildResult result1 = runGradle(projectDirectoryPath, ASSEMBLE_TASK_NAME);

assertAssembleTaskOutcomes(result1, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED,
PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SKIPPED, null);
assertAssembleTaskOutcomes(result1, SUCCESS, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null);

final BuildResult result2 = runGradle(projectDirectoryPath, FrontendGradlePlugin.ASSEMBLE_TASK_NAME);
final BuildResult result2 = runGradle(projectDirectoryPath, ASSEMBLE_TASK_NAME);

assertAssembleTaskOutcomes(result2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SKIPPED,
PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SKIPPED, null);
assertAssembleTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null);
}

@Test
Expand All @@ -64,15 +65,13 @@ void should_skip_task_when_script_is_not_defined() throws IOException {
.packageJsonDirectory(packageJsonDirectoryPath);
createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap());

final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.ASSEMBLE_TASK_NAME);
final BuildResult result1 = runGradle(projectDirectoryPath, ASSEMBLE_TASK_NAME);

assertAssembleTaskOutcomes(result1, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS,
PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED, null);
assertAssembleTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null);

final BuildResult result2 = runGradle(projectDirectoryPath, FrontendGradlePlugin.ASSEMBLE_TASK_NAME);
final BuildResult result2 = runGradle(projectDirectoryPath, ASSEMBLE_TASK_NAME);

assertAssembleTaskOutcomes(result2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE,
PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED, null);
assertAssembleTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null);
}

@Test
Expand All @@ -84,17 +83,13 @@ void should_skip_task_when_running_gradle_task_and_script_is_not_defined() throw
.packageJsonDirectory(packageJsonDirectoryPath);
createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap());

final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME);
final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_ASSEMBLE_TASK_NAME);

assertAssembleTaskOutcomes(result1, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS,
PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED,
PluginTaskOutcome.UP_TO_DATE);
assertAssembleTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, UP_TO_DATE);

final BuildResult result2 = runGradle(projectDirectoryPath, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME);
final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_ASSEMBLE_TASK_NAME);

assertAssembleTaskOutcomes(result2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE,
PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED,
PluginTaskOutcome.UP_TO_DATE);
assertAssembleTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE);
}

@Test
Expand All @@ -107,15 +102,12 @@ void should_assemble_frontend() throws IOException {
.assembleScript("run assemble");
createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap());

final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME);
final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_ASSEMBLE_TASK_NAME);

assertAssembleTaskOutcomes(result1, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS,
PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS);
assertAssembleTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS);

final BuildResult result2 = runGradle(projectDirectoryPath, FrontendGradlePlugin.GRADLE_ASSEMBLE_TASK_NAME);
final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_ASSEMBLE_TASK_NAME);

assertAssembleTaskOutcomes(result2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE,
PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS,
PluginTaskOutcome.SUCCESS);
assertAssembleTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package org.siouan.frontendgradleplugin.infrastructure.gradle;

import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.CHECK_TASK_NAME;
import static org.siouan.frontendgradleplugin.FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME;
import static org.siouan.frontendgradleplugin.test.GradleBuildAssertions.assertCheckTaskOutcomes;
import static org.siouan.frontendgradleplugin.test.GradleBuildFiles.createBuildFile;
import static org.siouan.frontendgradleplugin.test.GradleHelper.runGradle;
import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SKIPPED;
import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.SUCCESS;
import static org.siouan.frontendgradleplugin.test.PluginTaskOutcome.UP_TO_DATE;
import static org.siouan.frontendgradleplugin.test.Resources.getResourcePath;
import static org.siouan.frontendgradleplugin.test.Resources.getResourceUrl;

Expand All @@ -13,37 +18,33 @@
import org.gradle.testkit.runner.BuildResult;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.siouan.frontendgradleplugin.FrontendGradlePlugin;
import org.siouan.frontendgradleplugin.test.FrontendMapBuilder;
import org.siouan.frontendgradleplugin.test.PluginTaskOutcome;

/**
* Functional tests to verify the {@link CheckTask} integration in a Gradle build. Test cases uses fake Node/Yarn
* distributions, to avoid the download overhead. The 'yarn' and 'npm' executables in these distributions simply call
* the 'node' executable with the same arguments.
* Functional tests to verify the {@link CheckTask} integration in a Gradle build. Test cases uses fake
* Node/NPM/PNPM/Yarn distributions, to avoid the download overhead. The 'npm', 'pnpm', 'yarn' executables in these
* distributions simply call the 'node' executable with the same arguments.
*/
class CheckFrontendTaskFuncTest {

@TempDir
Path projectDirectoryPath;

@Test
void should_skip_task_when_package_json_file_is_not_a_file() throws IOException {
void should_skip_task_when_package_json_file_does_not_exist() throws IOException {
final FrontendMapBuilder frontendMapBuilder = new FrontendMapBuilder()
.nodeVersion("18.17.1")
.nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip"))
.checkScript("run check");
createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap());

final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.CHECK_TASK_NAME);
final BuildResult result1 = runGradle(projectDirectoryPath, CHECK_TASK_NAME);

assertCheckTaskOutcomes(result1, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED,
PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SKIPPED, null);
assertCheckTaskOutcomes(result1, SUCCESS, SUCCESS, SKIPPED, SKIPPED, SKIPPED, null);

final BuildResult result2 = runGradle(projectDirectoryPath, FrontendGradlePlugin.CHECK_TASK_NAME);
final BuildResult result2 = runGradle(projectDirectoryPath, CHECK_TASK_NAME);

assertCheckTaskOutcomes(result2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SKIPPED,
PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SKIPPED, PluginTaskOutcome.SKIPPED, null);
assertCheckTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, SKIPPED, SKIPPED, SKIPPED, null);
}

@Test
Expand All @@ -54,15 +55,13 @@ void should_skip_task_when_script_is_not_defined() throws IOException {
.nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip"));
createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap());

final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.CHECK_TASK_NAME);
final BuildResult result1 = runGradle(projectDirectoryPath, CHECK_TASK_NAME);

assertCheckTaskOutcomes(result1, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS,
PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED, null);
assertCheckTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, null);

final BuildResult result2 = runGradle(projectDirectoryPath, FrontendGradlePlugin.CHECK_TASK_NAME);
final BuildResult result2 = runGradle(projectDirectoryPath, CHECK_TASK_NAME);

assertCheckTaskOutcomes(result2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE,
PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED, null);
assertCheckTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, null);
}

@Test
Expand All @@ -73,17 +72,13 @@ void should_skip_task_when_running_gradle_task_and_script_is_not_defined() throw
.nodeDistributionUrl(getResourceUrl("node-v18.17.1.zip"));
createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap());

final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME);
final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_CHECK_TASK_NAME);

assertCheckTaskOutcomes(result1, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS,
PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED,
PluginTaskOutcome.UP_TO_DATE);
assertCheckTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SKIPPED, UP_TO_DATE);

final BuildResult result2 = runGradle(projectDirectoryPath, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME);
final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_CHECK_TASK_NAME);

assertCheckTaskOutcomes(result2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE,
PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SKIPPED,
PluginTaskOutcome.UP_TO_DATE);
assertCheckTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SKIPPED, UP_TO_DATE);
}

@Test
Expand All @@ -95,15 +90,12 @@ void should_check_frontend() throws IOException {
.checkScript("run check");
createBuildFile(projectDirectoryPath, frontendMapBuilder.toMap());

final BuildResult result1 = runGradle(projectDirectoryPath, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME);
final BuildResult result1 = runGradle(projectDirectoryPath, GRADLE_CHECK_TASK_NAME);

assertCheckTaskOutcomes(result1, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS,
PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS);
assertCheckTaskOutcomes(result1, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS, SUCCESS);

final BuildResult result2 = runGradle(projectDirectoryPath, FrontendGradlePlugin.GRADLE_CHECK_TASK_NAME);
final BuildResult result2 = runGradle(projectDirectoryPath, GRADLE_CHECK_TASK_NAME);

assertCheckTaskOutcomes(result2, PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.UP_TO_DATE,
PluginTaskOutcome.UP_TO_DATE, PluginTaskOutcome.SUCCESS, PluginTaskOutcome.SUCCESS,
PluginTaskOutcome.SUCCESS);
assertCheckTaskOutcomes(result2, UP_TO_DATE, UP_TO_DATE, UP_TO_DATE, SUCCESS, SUCCESS, SUCCESS);
}
}
Loading

0 comments on commit f4e937d

Please sign in to comment.