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