aboutsummaryrefslogtreecommitdiffstats
path: root/build.gradle.kts
blob: 3ec6ffe3828ef0e2096d17cd40f68dff7357b0e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */

import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn

plugins {
	alias(libs.plugins.versions)
	id("tools.refinery.gradle.eclipse")
	id("tools.refinery.gradle.frontend-worktree")
	id("tools.refinery.gradle.sonarqube")
}

val frontendFiles: FileCollection = files(
	"yarn.lock",
	"package.json",
	"tsconfig.json",
	"tsconfig.base.json",
	"eslintrc.cjs",
	"prettier.config.cjs",
	"vite.config.ts",
) + fileTree("scripts") {
	include("**/*.cjs")
}

val mavenRepositoryDir = layout.buildDirectory.map { it.dir("repo") }

tasks {
	val typeCheckFrontend by registering(RunYarn::class) {
		dependsOn(installFrontend)
		inputs.files(frontendFiles)
		outputs.dir(layout.buildDirectory.dir("typescript"))
		script.set("run typecheck")
		group = "verification"
		description = "Check for TypeScript type errors."
	}

	val lintFrontend by registering(RunYarn::class) {
		dependsOn(installFrontend)
		dependsOn(typeCheckFrontend)
		inputs.files(frontendFiles)
		outputs.file(layout.buildDirectory.file("eslint.json"))
		script.set("run lint")
		group = "verification"
		description = "Check for TypeScript lint errors and warnings."
	}

	register<RunYarn>("fixFrontend") {
		dependsOn(installFrontend)
		dependsOn(typeCheckFrontend)
		inputs.files(frontendFiles)
		script.set("run lint:fix")
		group = "verification"
		description = "Fix TypeScript lint errors and warnings."
	}

	check {
		dependsOn(typeCheckFrontend)
		dependsOn(lintFrontend)
	}
}

val cleanMavenRepository by tasks.registering(Delete::class) {
	delete(mavenRepositoryDir)
}

val mavenRepositoryTar by tasks.registering(Tar::class) {
	dependsOn(cleanMavenRepository)
	from(mavenRepositoryDir)
	archiveFileName = "refinery-maven-repository.tar"
	destinationDirectory = layout.buildDirectory
}

gradle.projectsEvaluated {
	mavenRepositoryTar.configure {
		for (subproject in rootProject.subprojects) {
			if (subproject.plugins.hasPlugin(JavaPlugin::class)) {
				dependsOn(subproject.tasks.named("publishMavenJavaPublicationToFileRepository"))
			}
		}
	}
}

sonarqube.properties {
	property("sonar.nodejs.executable", "${frontend.nodeInstallDirectory.get()}/bin/node")
	property("sonar.eslint.reportPaths", "${layout.buildDirectory.get()}/eslint.json")
}