Skip to content

Commit c7c1f04

Browse files
committed
Update gradle to 8.8 and refactor the allJar task to support the configuration cache and also support caching the output of intermediary steps
1 parent f535fd4 commit c7c1f04

File tree

9 files changed

+313
-263
lines changed

9 files changed

+313
-263
lines changed

annotation-processor/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of("${java_version}")
88

99
repositories {
1010
def repo = maven {
11-
name = 'CraftTweaker'
11+
name = 'ZenCode'
1212
url = 'https://maven.blamejared.com'
1313
}
1414
exclusiveContent {

build.gradle

Lines changed: 65 additions & 53 deletions
Large diffs are not rendered by default.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package mekanism
2+
3+
import org.gradle.api.file.DirectoryProperty
4+
import org.gradle.api.file.FileCollection
5+
import org.gradle.api.file.ProjectLayout
6+
import org.gradle.api.file.RegularFileProperty
7+
import org.gradle.api.tasks.InputFile
8+
import org.gradle.api.tasks.InputFiles
9+
import org.gradle.api.tasks.Internal
10+
import org.gradle.api.tasks.TaskAction
11+
import org.gradle.api.tasks.util.PatternFilterable
12+
import org.gradle.jvm.tasks.Jar
13+
14+
import javax.inject.Inject
15+
16+
abstract class AllJar extends Jar {
17+
18+
//TODO: Should this be declared as some sort of input?
19+
@Internal
20+
final DirectoryProperty generatedDir
21+
22+
@InputFile
23+
final RegularFileProperty pathsToExclude
24+
@InputFiles
25+
abstract FileCollection apiOutput
26+
@InputFiles
27+
abstract FileCollection mainOutput
28+
@InputFiles
29+
FileCollection secondaryModuleOutputs
30+
31+
@Inject
32+
AllJar(ProjectLayout projectLayout) {
33+
generatedDir = objectFactory.directoryProperty().convention(projectLayout.buildDirectory.dir('generated'))
34+
pathsToExclude = objectFactory.fileProperty()
35+
secondaryModuleOutputs = objectFactory.fileCollection()
36+
}
37+
38+
@Override
39+
@TaskAction
40+
protected void copy() {
41+
//copy all the files except for ones we are going to include from the merged intersection
42+
from(apiOutput)
43+
44+
//Note: We have to use from(FileCollection) as we want to ensure the pathsToExclude gets lazily evaluated, trying to lazily configure it
45+
// via a closure causes an additional spec to be added to this task at execution time, which causes it to error out. The easiest way for
46+
// us to do it, is to turn collections into file trees, and then use a matching block on them as that allows it to lazily evaluate the
47+
// filter as the collection is defined to stay up to date if the backing collection changes
48+
from(filterFiles(mainOutput, 'crafttweaker_parameter_names.json'))
49+
from(filterFiles(secondaryModuleOutputs, 'logo.png', 'pack.mcmeta'))
50+
51+
//And finally copy over the generated files
52+
from(generatedDir.asFileTree.matching({ PatternFilterable pf ->
53+
pf.include(pathsToExclude.get().asFile.text.split('\n'))
54+
}))
55+
56+
super.copy()
57+
}
58+
59+
private FileCollection filterFiles(FileCollection collection, String... extraExclusions) {
60+
return collection.asFileTree.matching({ PatternFilterable pf ->
61+
pf.exclude(pathsToExclude.get().asFile.text.split('\n'))
62+
pf.exclude(extraExclusions)
63+
})
64+
}
65+
}

buildSrc/src/main/groovy/mekanism/MergeJars.groovy

Lines changed: 0 additions & 204 deletions
This file was deleted.

0 commit comments

Comments
 (0)