1+ /*
2+ * Copyright (c) 2026 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+ import de.undercouch.gradle.tasks.download.Download
26+ import de.undercouch.gradle.tasks.download.Verify
27+
28+ plugins {
29+ id(" de.undercouch.download" ) version " 5.7.0"
30+ }
31+
32+ val distURL = " https://services.gradle.org/distributions/gradle-8.10-bin.zip"
33+ val distSHA = " 5b9c5eb3f9fc2c94abaea57d90bd78747ca117ddbbf96c859d3741181a12bf2a"
34+
35+ val wrapperZip = layout.buildDirectory.file(" gradle.zip" )
36+ val downloadGradle = tasks.create<Download >(" downloadGradle" ) {
37+ src(distURL)
38+ dest(wrapperZip)
39+ }
40+ val verifyGradle = tasks.create<Verify >(" verifyGradle" ) {
41+ dependsOn(downloadGradle)
42+ src(wrapperZip)
43+ algorithm(" SHA-256" )
44+ checksum(distSHA)
45+ }
46+
47+ val rtCopy = copySpec {
48+ from(arrayOf(" :apirecorder" , " :package" , " :upload" ).map {
49+ project(it).tasks.getByName<Jar >(" shadowJar" ).archiveFile
50+ })
51+ from(file(" src/main/resources" ))
52+ from(zipTree(wrapperZip)) {
53+ eachFile {
54+ relativePath.segments[0 ] = " gradle"
55+ }
56+ includeEmptyDirs = false
57+ }
58+ }
59+ var rtDeps = arrayOf(verifyGradle)
60+
61+ var tar = tasks.create<Tar >(" tar" ) {
62+ archiveFileName = archiveBaseName.get() + " ." + archiveExtension.get()
63+
64+ dependsOn(rtDeps)
65+ with (rtCopy)
66+ }
67+ var rtDir = layout.buildDirectory.dir(" test_runtime" ).get()
68+ var testRTSync = tasks.create<Sync >(" testRuntimeSync" ) {
69+ into(rtDir)
70+
71+ dependsOn(rtDeps)
72+ with (rtCopy)
73+ from(file(" src/test/resources" ))
74+ }
75+
76+ repositories {
77+ mavenLocal()
78+ maven {
79+ setUrl(" https://repo.runelite.net" )
80+ content {
81+ includeGroupByRegex(" net\\ .runelite.*" )
82+ }
83+ }
84+ mavenCentral()
85+ }
86+
87+ val runelite = configurations.create(" runelite" ) {
88+ isCanBeConsumed = false
89+ isCanBeResolved = true
90+ isTransitive = false
91+ }
92+ dependencies {
93+ runelite(" net.runelite:client:latest.release" )
94+ }
95+
96+ var rlVersion = tasks.create(" rlVersion" ) {
97+ dependsOn(testRTSync, runelite)
98+ doLast {
99+ val version = runelite.incoming.resolutionResult.allComponents
100+ .mapNotNull { it.id as ? ModuleComponentIdentifier }
101+ .single { it.group == " net.runelite" && it.module == " client" }
102+ .version
103+
104+ rtDir.file(" plugin-hub/runelite.version" ).asFile.writeText(" $version \n " )
105+ }
106+ }
107+
108+ var testVerificationMetadata = tasks.create<Exec >(" testVerificationMetadata" ) {
109+ val verTmplDir = rtDir.file(" plugin-hub/package/verification-template" )
110+ dependsOn(testRTSync, rlVersion)
111+ inputs.dir(verTmplDir)
112+ commandLine(
113+ rtDir.file(" gradle/bin/gradle" ),
114+ " --no-daemon" ,
115+ " --project-dir" ,
116+ verTmplDir,
117+ " --write-verification-metadata" ,
118+ " sha256" ,
119+ " :verifyCore" ,
120+ )
121+ workingDir(rtDir)
122+ }
123+
124+ var preparer = tasks.create<Exec >(" preparer" ) {
125+ dependsOn(testRTSync, rlVersion)
126+ commandLine(rtDir.file(" prepare.sh" ))
127+ workingDir(rtDir)
128+ }
129+
130+ val testRuntime = configurations.create(" testRuntime" ) {
131+ isCanBeConsumed = true
132+ isCanBeResolved = false
133+ }
134+ var rtArtifact = artifacts.add(" testRuntime" , rtDir) {
135+ builtBy(testRTSync, preparer, rlVersion, testVerificationMetadata)
136+ }
137+
138+ tasks.build {
139+ dependsOn(rtArtifact, tar)
140+ }
0 commit comments