|
1 | | -import org.incendo.cloudbuildlogic.javadoclinks.JavadocLinksExtension |
2 | | -import org.incendo.cloudbuildlogic.jmp |
3 | | -import java.nio.file.Files |
4 | | -import kotlin.io.path.copyTo |
5 | | -import kotlin.io.path.createDirectories |
6 | | -import kotlin.io.path.exists |
7 | | -import kotlin.io.path.invariantSeparatorsPathString |
8 | | -import kotlin.io.path.isDirectory |
9 | | - |
10 | 1 | plugins { |
11 | | - alias(libs.plugins.indra) |
12 | | - alias(libs.plugins.indraCheckstyle) |
13 | | - alias(libs.plugins.indraPublishing) |
14 | | - alias(libs.plugins.javadocLinks) |
15 | | -} |
16 | | - |
17 | | -allprojects { |
18 | | - plugins.apply("net.kyori.indra") |
19 | | - plugins.apply("net.kyori.indra.checkstyle") |
20 | | - plugins.apply("net.kyori.indra.publishing") |
21 | | - plugins.apply("org.incendo.cloud-build-logic.javadoc-links") |
22 | | - |
23 | | - indra { |
24 | | - javaVersions { |
25 | | - target(21) |
26 | | - strictVersions(true) |
27 | | - } |
28 | | - |
29 | | - publishSnapshotsTo("paperSnapshots", "https://artifactory.papermc.io/artifactory/snapshots/") |
30 | | - publishReleasesTo("paperReleases", "https://artifactory.papermc.io/artifactory/releases/") |
31 | | - signWithKeyFromProperties("signingKey", "signingPassword") |
32 | | - |
33 | | - apache2License() |
34 | | - |
35 | | - github("PaperMC", "asm-utils") { |
36 | | - ci(true) |
37 | | - } |
38 | | - |
39 | | - configurePublications { |
40 | | - pom { |
41 | | - developers { |
42 | | - jmp() |
43 | | - developer { |
44 | | - id = "Machine-Maker" |
45 | | - name = "Jake Potrebic" |
46 | | - url = "https://github.com/Machine-Maker" |
47 | | - } |
48 | | - developer { |
49 | | - id = "kennytv" |
50 | | - name = "Nassim Jahnke" |
51 | | - url = "https://github.com/kennytv" |
52 | | - } |
53 | | - } |
54 | | - } |
55 | | - } |
56 | | - } |
57 | | - |
58 | | - repositories { |
59 | | - mavenCentral() |
60 | | - } |
61 | | - |
62 | | - dependencies { |
63 | | - if ("-runtime" !in project.name) { |
64 | | - api(rootProject.libs.asm) |
65 | | - testImplementation(rootProject.libs.asm) |
66 | | - api(rootProject.libs.asmCommons) |
67 | | - testImplementation(rootProject.libs.asmCommons) |
68 | | - } |
69 | | - |
70 | | - compileOnlyApi(rootProject.libs.jspecify) |
71 | | - testCompileOnly(rootProject.libs.jspecify) |
72 | | - compileOnly(rootProject.libs.jetbrainsAnnotations) |
73 | | - testCompileOnly(rootProject.libs.jetbrainsAnnotations) |
74 | | - |
75 | | - testImplementation(rootProject.libs.jupiterApi) |
76 | | - testImplementation(rootProject.libs.jupiterParams) |
77 | | - testRuntimeOnly(rootProject.libs.jupiterEngine) |
78 | | - testRuntimeOnly(rootProject.libs.platformLauncher) |
79 | | - } |
80 | | - |
81 | | - javadocLinks { |
82 | | - override(startsWithAnyOf("org.ow2.asm:asm"), JavadocLinksExtension.LinkOverride.Simple("https://asm.ow2.io/javadoc")) |
83 | | - override(rootProject.libs.jspecify, "https://jspecify.dev/docs/api/") |
84 | | - } |
| 2 | + id("config-bytecode-testing") |
| 3 | + id("config-asm") |
85 | 4 | } |
86 | | -val mainForNewTargets = sourceSets.create("mainForNewTargets") |
87 | 5 |
|
88 | | -val testDataSet = sourceSets.create("testData") |
89 | | -val testDataNewTargets = sourceSets.create("testDataNewTargets") |
90 | | - |
91 | | -val filtered = tasks.register<FilterTestClasspath>("filteredTestClasspath") { |
92 | | - outputDir.set(layout.buildDirectory.dir("filteredTestClasspath")) |
93 | | - old.from(testDataSet.output) |
94 | | - new.from(testDataNewTargets.output) |
95 | | -} |
96 | | - |
97 | | -dependencies { |
98 | | - api(mainForNewTargets.output) |
99 | | - testRuntimeOnly(files(filtered.flatMap { it.outputDir })) // only have access to old targets at runtime, don't use them in actual tests |
100 | | - testImplementation(testDataNewTargets.output) |
101 | | - |
102 | | - testDataNewTargets.implementationConfigurationName(mainForNewTargets.output) |
103 | | -} |
104 | | - |
105 | | - |
106 | | -abstract class FilterTestClasspath : DefaultTask() { |
107 | | - @get:InputFiles |
108 | | - abstract val old: ConfigurableFileCollection |
109 | | - |
110 | | - @get:InputFiles |
111 | | - abstract val new: ConfigurableFileCollection |
112 | | - |
113 | | - @get:OutputDirectory |
114 | | - abstract val outputDir: DirectoryProperty |
115 | | - |
116 | | - @get:Inject |
117 | | - abstract val fsOps: FileSystemOperations |
118 | | - |
119 | | - @TaskAction |
120 | | - fun run() { |
121 | | - if (!outputDir.get().asFile.toPath().exists()) { |
122 | | - outputDir.get().asFile.mkdirs() |
123 | | - } else { |
124 | | - fsOps.delete { |
125 | | - delete(outputDir.get()) |
126 | | - } |
127 | | - outputDir.get().asFile.mkdirs() |
128 | | - } |
129 | | - |
130 | | - val newExisting = mutableListOf<String>() |
131 | | - for (file in new.files) { |
132 | | - if (file.exists()) { |
133 | | - Files.walk(file.toPath()).use { s -> |
134 | | - s.forEach { |
135 | | - if (it.isDirectory()) { |
136 | | - return@forEach |
137 | | - } |
138 | | - newExisting += file.toPath().relativize(it).invariantSeparatorsPathString |
139 | | - } |
140 | | - } |
141 | | - } |
142 | | - } |
143 | | - for (file in old.files) { |
144 | | - if (file.exists()) { |
145 | | - Files.walk(file.toPath()).use { s -> |
146 | | - s.forEach { |
147 | | - if (it.isDirectory()) { |
148 | | - return@forEach |
149 | | - } |
150 | | - val rel = file.toPath().relativize(it).invariantSeparatorsPathString |
151 | | - if (rel !in newExisting) { |
152 | | - it.copyTo(outputDir.get().asFile.toPath().resolve(rel).also { f -> f.parent.createDirectories() }) |
153 | | - } |
154 | | - } |
155 | | - } |
156 | | - } |
157 | | - } |
158 | | - } |
159 | | -} |
0 commit comments