|
| 1 | +/* |
| 2 | + * Copyright (c) 2021 Abex |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions are met: |
| 7 | + * |
| 8 | + * 1. Redistributions of source code must retain the above copyright notice, this |
| 9 | + * list of conditions and the following disclaimer. |
| 10 | + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | + * this list of conditions and the following disclaimer in the documentation |
| 12 | + * and/or other materials provided with the distribution. |
| 13 | + * |
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 15 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 | + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 18 | + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 | + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 23 | + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | + */ |
| 25 | +plugins { |
| 26 | + java |
| 27 | + jacoco |
| 28 | +} |
| 29 | + |
| 30 | +repositories { |
| 31 | + maven { |
| 32 | + url = uri("https://repo.runelite.net") |
| 33 | + } |
| 34 | + mavenCentral() |
| 35 | +} |
| 36 | + |
| 37 | +val testCore by sourceSets.creating |
| 38 | +val testPlugin by sourceSets.creating { |
| 39 | + compileClasspath += testCore.output |
| 40 | +} |
| 41 | + |
| 42 | +dependencies { |
| 43 | + implementation(libs.slf4j.simple) |
| 44 | + implementation(libs.findbugs.jsr305) |
| 45 | + implementation(libs.guava) |
| 46 | + implementation(libs.asm) |
| 47 | + implementation(libs.gson) |
| 48 | + |
| 49 | + testImplementation(libs.junit) |
| 50 | + |
| 51 | + compileOnly(libs.lombok) |
| 52 | + annotationProcessor(libs.lombok) |
| 53 | + testCompileOnly(libs.lombok) |
| 54 | + testAnnotationProcessor(libs.lombok) |
| 55 | +} |
| 56 | + |
| 57 | +tasks.withType<JavaCompile>().configureEach { |
| 58 | + // we can't use -release here because we need to --add-exports for the javac |
| 59 | + // internal apis |
| 60 | + sourceCompatibility = "11" |
| 61 | + targetCompatibility = "11" |
| 62 | +} |
| 63 | + |
| 64 | +tasks.named<JavaCompile>("compileJava") { |
| 65 | + options.compilerArgs.addAll(listOf( |
| 66 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", |
| 67 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", |
| 68 | + )) |
| 69 | +} |
| 70 | + |
| 71 | +val testCoreJar = tasks.register<Jar>("testCoreJar") { |
| 72 | + archiveBaseName.set("test-core") |
| 73 | + from(sourceSets.getByName("testCore").output) |
| 74 | +} |
| 75 | + |
| 76 | +val testClassApiFile = project.layout.buildDirectory.file("testCoreApi").get().asFile |
| 77 | + |
| 78 | +val testCoreApi = tasks.register<JavaExec>("testCoreApi") { |
| 79 | + inputs.file(testCoreJar.get().archiveFile) |
| 80 | + outputs.file(testClassApiFile) |
| 81 | + classpath = sourceSets.main.get().runtimeClasspath |
| 82 | + mainClass.set("net.runelite.pluginhub.apirecorder.ClassRecorder") |
| 83 | + args(testClassApiFile, testCoreJar.get().archiveFile.get().asFile) |
| 84 | +} |
| 85 | + |
| 86 | +tasks.named<Test>("test") { |
| 87 | + inputs.files(testCoreApi.get().outputs) |
| 88 | + inputs.files(testPlugin.allSource) |
| 89 | + |
| 90 | + jvmArgs( |
| 91 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED", |
| 92 | + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", |
| 93 | + ) |
| 94 | + |
| 95 | + systemProperties(mapOf( |
| 96 | + "runelite.apirecorder.test.classpath" to testPlugin.compileClasspath.files.joinToString(File.pathSeparator), |
| 97 | + "runelite.apirecorder.test.sourcepath" to testPlugin.allJava.files.joinToString(File.pathSeparator), |
| 98 | + )) |
| 99 | +} |
| 100 | + |
| 101 | +tasks.named<JacocoReport>("jacocoTestReport") { |
| 102 | + dependsOn(tasks.test) |
| 103 | + reports { |
| 104 | + xml.required.set(true) |
| 105 | + html.required.set(true) |
| 106 | + } |
| 107 | +} |
0 commit comments