aboutsummaryrefslogtreecommitdiffstats
path: root/buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts')
-rw-r--r--buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts96
1 files changed, 96 insertions, 0 deletions
diff --git a/buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts b/buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts
new file mode 100644
index 00000000..2d5ce8b5
--- /dev/null
+++ b/buildSrc/src/main/kotlin/refinery-java-conventions.gradle.kts
@@ -0,0 +1,96 @@
1import org.gradle.accessors.dm.LibrariesForLibs
2import org.gradle.plugins.ide.eclipse.model.EclipseModel
3import org.gradle.plugins.ide.eclipse.model.ProjectDependency
4import tools.refinery.buildsrc.EclipseUtils
5
6plugins {
7 jacoco
8 java
9}
10
11apply(plugin = "refinery-eclipse")
12
13repositories {
14 mavenCentral()
15 maven {
16 url = uri("https://repo.eclipse.org/content/groups/releases/")
17 }
18}
19
20val libs = the<LibrariesForLibs>()
21
22dependencies {
23 compileOnly(libs.jetbrainsAnnotations)
24 testCompileOnly(libs.jetbrainsAnnotations)
25 testImplementation(libs.hamcrest)
26 testImplementation(libs.junit.api)
27 testRuntimeOnly(libs.junit.engine)
28 testImplementation(libs.junit.params)
29 testImplementation(libs.mockito.core)
30 testImplementation(libs.mockito.junit)
31}
32
33java.toolchain {
34 languageVersion.set(JavaLanguageVersion.of(19))
35}
36
37tasks.withType(JavaCompile::class) {
38 options.release.set(17)
39}
40
41val test = tasks.named<Test>("test")
42
43val jacocoTestReport = tasks.named<JacocoReport>("jacocoTestReport")
44
45test.configure {
46 useJUnitPlatform {
47 excludeTags("slow")
48 }
49 finalizedBy(jacocoTestReport)
50}
51
52jacocoTestReport.configure {
53 dependsOn(test)
54 reports {
55 xml.required.set(true)
56 }
57}
58
59tasks.named<org.gradle.jvm.tasks.Jar>("jar") {
60 manifest {
61 attributes(
62 "Bundle-SymbolicName" to "${project.group}.${project.name}",
63 "Bundle-Version" to project.version
64 )
65 }
66}
67
68val generateEclipseSourceFolders by tasks.registering
69
70tasks.register("prepareEclipse") {
71 dependsOn(generateEclipseSourceFolders)
72 dependsOn(tasks.named("eclipseJdt"))
73}
74
75tasks.named("eclipseClasspath") {
76 dependsOn(generateEclipseSourceFolders)
77}
78
79configure<EclipseModel> {
80 EclipseUtils.patchClasspathEntries(this) { entry ->
81 if (entry.path.endsWith("-gen")) {
82 entry.entryAttributes["ignore_optional_problems"] = true
83 }
84 // If a project has a main dependency on a project and a test dependency on the testFixtures of a project,
85 // it will be erroneously added as a test-only dependency to Eclipse. As a workaround, we add all project
86 // dependencies as main dependencies (we do not deliberately use test-only project dependencies).
87 if (entry is ProjectDependency) {
88 entry.entryAttributes.remove("test")
89 }
90 }
91
92 jdt.file.withProperties {
93 // Allow @SuppressWarnings to suppress SonarLint warnings
94 this["org.eclipse.jdt.core.compiler.problem.unhandledWarningToken"] = "ignore"
95 }
96}