Skip to content

Commit 1f98558

Browse files
authored
Move filament into the yarn repo. (#3296)
This will make further developments a lot easier.
1 parent 18a44f9 commit 1f98558

36 files changed

+86391
-6
lines changed

.editorconfig

+5
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
[*.{gradle,mapping,unpick}]
22
indent_style = tab
3+
4+
[*.java]
5+
indent_style = tab
6+
ij_continuation_indent_size = 8
7+
ij_java_imports_layout = $*,|,java.**,|,javax.**,|,*,|,net.fabricmc.**

.github/workflows/build.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
strategy:
66
matrix:
77
java: [17-jdk, 18-jdk]
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
99
container:
1010
image: openjdk:${{ matrix.java }}
1111
options: --user root
@@ -20,3 +20,13 @@ jobs:
2020
with:
2121
name: Artifacts
2222
path: build/libs/
23+
24+
test-build-logic:
25+
runs-on: ubuntu-22.04
26+
container:
27+
image: openjdk:18-jdk
28+
options: --user root
29+
steps:
30+
- uses: actions/checkout@v2
31+
- uses: gradle/wrapper-validation-action@v1
32+
- run: ./gradlew :filament:build

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ concurrency: ci-${{ github.ref }}
44
jobs:
55
publish:
66
if: ${{ github.repository_owner == 'FabricMC' }}
7-
runs-on: ubuntu-20.04
7+
runs-on: ubuntu-22.04
88
container:
99
image: openjdk:18-jdk
1010
options: --user root

.github/workflows/update-base.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
update:
99
if: ${{ github.event.label.name == 'update-base' }}
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
1111
steps:
1212
- uses: FabricMC/fabric-action-scripts@v1
1313
with:

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ plugins {
2424
id 'de.undercouch.download' version '4.1.2'
2525
id 'maven-publish'
2626
id "com.diffplug.spotless" version "6.4.2"
27-
id 'net.fabricmc.filament' version '0.3.0'
27+
id 'net.fabricmc.filament'
2828
}
2929

3030
def minecraft_version = "1.19.2"

filament/build.gradle

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
plugins {
2+
id 'java-library'
3+
id 'java-gradle-plugin'
4+
id 'checkstyle'
5+
}
6+
7+
group = 'net.fabricmc'
8+
9+
def properties = new Properties()
10+
file('../gradle.properties').newInputStream().withCloseable {
11+
properties.load(it)
12+
}
13+
14+
repositories {
15+
maven {
16+
name "Fabric Repository"
17+
url 'https://maven.fabricmc.net'
18+
}
19+
mavenCentral()
20+
}
21+
22+
dependencies {
23+
implementation "org.ow2.asm:asm:${properties.asm_version}"
24+
implementation "org.ow2.asm:asm-tree:${properties.asm_version}"
25+
implementation "cuchaz:enigma:$properties.enigma_version"
26+
implementation "net.fabricmc.unpick:unpick:$properties.unpick_version"
27+
implementation "net.fabricmc.unpick:unpick-format-utils:$properties.unpick_version"
28+
implementation "net.fabricmc:tiny-mappings-parser:$properties.tiny_mappings_parser_version"
29+
30+
testImplementation platform("org.junit:junit-bom:$properties.junit_version")
31+
testImplementation 'org.junit.jupiter:junit-jupiter'
32+
testImplementation "org.assertj:assertj-core:$properties.assertj_version"
33+
}
34+
35+
tasks.withType(JavaCompile) {
36+
options.encoding = "UTF-8"
37+
options.release = 17
38+
}
39+
40+
test {
41+
useJUnitPlatform()
42+
}
43+
44+
checkstyle {
45+
configFile = file('checkstyle.xml')
46+
toolVersion = '10.3.3'
47+
}
48+
49+
gradlePlugin {
50+
plugins {
51+
filament {
52+
id = 'net.fabricmc.filament'
53+
implementationClass = 'net.fabricmc.filament.FilamentGradlePlugin'
54+
}
55+
}
56+
}

filament/checkstyle.xml

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
3+
<module name="Checker">
4+
<property name="charset" value="UTF-8"/>
5+
<property name="fileExtensions" value="java"/>
6+
<property name="localeLanguage" value="en"/>
7+
<property name="localeCountry" value="US"/>
8+
9+
<module name="NewlineAtEndOfFile"/>
10+
11+
<!-- disallow trailing whitespace -->
12+
<module name="RegexpSingleline">
13+
<property name="format" value="\s+$"/>
14+
<property name="message" value="trailing whitespace"/>
15+
</module>
16+
17+
<!-- note: RegexpMultiline shows nicer messages than Regexp, but has to be outside TreeWalker -->
18+
<!-- disallow multiple consecutive blank lines -->
19+
<module name="RegexpMultiline">
20+
<property name="format" value="\n[\t ]*\r?\n[\t ]*\r?\n"/>
21+
<property name="message" value="adjacent blank lines"/>
22+
</module>
23+
24+
<!-- disallow blank after { -->
25+
<module name="RegexpMultiline">
26+
<property name="format" value="\{[\t ]*\r?\n[\t ]*\r?\n"/>
27+
<property name="message" value="blank line after '{'"/>
28+
</module>
29+
30+
<!-- disallow blank before } -->
31+
<module name="RegexpMultiline">
32+
<property name="format" value="\n[\t ]*\r?\n[\t ]*\}"/>
33+
<property name="message" value="blank line before '}'"/>
34+
</module>
35+
36+
<!-- require blank before { in the same indentation level -->
37+
<module name="RegexpMultiline">
38+
<!-- the regex works as follows:
39+
It matches (=fails) for \n<indentation><something>\n<same indentation><control statement>[...]{\n
40+
while <something> is a single line comment, it'll look for a blank line one line earlier
41+
if <something> is a space, indicating a formatting error or ' */', it'll ignore the instance
42+
if <something> is a tab, indicating a continued line, it'll ignore the instance
43+
<control statement> is 'if', 'do', 'while', 'for', 'try' or nothing (instance initializer block)
44+
45+
- first \n: with positive lookbehind (?<=\n) to move the error marker to a more reasonable place
46+
- capture tabs for <indentation>, later referenced via \1
47+
- remaining preceding line as a non-comment (doesn't start with '/', '//', ' ' or '\t') or multiple lines where all but the first are a single line comment with the same indentation
48+
- new line
49+
- <indentation> as captured earlier
50+
- <control statement> as specified above
51+
- { before the next new line -->
52+
<property name="format" value="(?&lt;=\n)([\t]+)(?:[^/\r\n \t][^\r\n]*|/[^/\r\n][^\r\n]*|[^/\r\n][^\r\n]*(\r?\n\1//[^\r\n]*)+)\r?\n\1(|(if|do|while|for|try)[^\r\n]+)\{[\t ]*\r?\n"/>
53+
<property name="message" value="missing blank line before block at same indentation level"/>
54+
</module>
55+
56+
<!-- require blank after } in the same indentation level -->
57+
<module name="RegexpMultiline">
58+
<!-- \n<indentation>}\n<same indentation><whatever unless newline, '}' or starting with cas(e) or def(ault)> -->
59+
<property name="format" value="(?&lt;=\n)([\t]+)\}\r?\n\1(?:[^\r\n\}cd]|c[^\r\na]|ca[^\r\ns]|d[^\r\ne]|de[^\r\nf])"/>
60+
<property name="message" value="missing blank line after block at same indentation level"/>
61+
</module>
62+
63+
<module name="TreeWalker">
64+
<!-- Ensure all imports are ship shape -->
65+
<module name="AvoidStarImport"/>
66+
<module name="IllegalImport"/>
67+
<module name="RedundantImport"/>
68+
<module name="UnusedImports"/>
69+
70+
<module name="ImportOrder">
71+
<property name="groups" value="java,javax,*,net.minecraft,net.fabricmc"/>
72+
<property name="ordered" value="false"/><!-- the plugin orders alphabetically without considering separators.. -->
73+
<property name="separated" value="true"/>
74+
<property name="option" value="top"/>
75+
<property name="sortStaticImportsAlphabetically" value="true"/>
76+
</module>
77+
78+
<!-- Ensures braces are at the end of a line -->
79+
<module name="LeftCurly"/>
80+
<module name="RightCurly"/>
81+
82+
<!-- single line statements on one line, -->
83+
<module name="NeedBraces">
84+
<property name="tokens" value="LITERAL_IF,LITERAL_FOR,LITERAL_WHILE"/>
85+
<property name="allowSingleLineStatement" value="true"/>
86+
</module>
87+
<module name="NeedBraces">
88+
<property name="tokens" value="LITERAL_ELSE,LITERAL_DO"/>
89+
<property name="allowSingleLineStatement" value="false"/>
90+
</module>
91+
92+
<module name="EmptyLineSeparator">
93+
<property name="allowNoEmptyLineBetweenFields" value="true"/>
94+
<property name="allowMultipleEmptyLines" value="false"/>
95+
<!-- exclude METHOD_DEF and VARIABLE_DEF -->
96+
<property name="tokens" value="PACKAGE_DEF,IMPORT,STATIC_IMPORT,CLASS_DEF,INTERFACE_DEF,ENUM_DEF,STATIC_INIT,INSTANCE_INIT,CTOR_DEF"/>
97+
</module>
98+
99+
<module name="OperatorWrap"/>
100+
<module name="SeparatorWrap">
101+
<property name="tokens" value="DOT,ELLIPSIS,AT"/>
102+
<property name="option" value="nl"/>
103+
</module>
104+
<module name="SeparatorWrap">
105+
<property name="tokens" value="COMMA,SEMI"/>
106+
<property name="option" value="eol"/>
107+
</module>
108+
109+
<module name="Indentation">
110+
<property name="basicOffset" value="8"/>
111+
<property name="caseIndent" value="0"/>
112+
<property name="throwsIndent" value="8"/>
113+
<property name="arrayInitIndent" value="8"/>
114+
<property name="lineWrappingIndentation" value="16"/>
115+
</module>
116+
117+
<module name="ParenPad"/>
118+
<module name="NoWhitespaceBefore"/>
119+
<module name="NoWhitespaceAfter">
120+
<!-- allow ARRAY_INIT -->
121+
<property name="tokens" value="AT,INC,DEC,UNARY_MINUS,UNARY_PLUS,BNOT,LNOT,DOT,ARRAY_DECLARATOR,INDEX_OP"/>
122+
</module>
123+
<module name="WhitespaceAfter"/>
124+
<module name="WhitespaceAround">
125+
<!-- Allow PLUS, MINUS, MUL, DIV as they may be more readable without spaces in some cases -->
126+
<property name="tokens" value="ASSIGN,BAND,BAND_ASSIGN,BOR,BOR_ASSIGN,BSR,BSR_ASSIGN,BXOR,BXOR_ASSIGN,COLON,DIV_ASSIGN,DO_WHILE,EQUAL,GE,GT,LAMBDA,LAND,LCURLY,LE,LITERAL_CATCH,LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_FOR,LITERAL_IF,LITERAL_RETURN,LITERAL_SWITCH,LITERAL_SYNCHRONIZED,LITERAL_TRY,LITERAL_WHILE,LOR,LT,MINUS_ASSIGN,MOD,MOD_ASSIGN,NOT_EQUAL,PLUS_ASSIGN,QUESTION,RCURLY,SL,SLIST,SL_ASSIGN,SR,SR_ASSIGN,STAR,STAR_ASSIGN,LITERAL_ASSERT,TYPE_EXTENSION_AND"/>
127+
</module>
128+
<module name="SingleSpaceSeparator"/>
129+
<module name="GenericWhitespace"/>
130+
<module name="CommentsIndentation"/>
131+
132+
<module name="ArrayTypeStyle"/>
133+
<module name="DefaultComesLast">
134+
<property name="skipIfLastAndSharedWithCase" value="true"/>
135+
</module>
136+
<module name="SimplifyBooleanExpression"/>
137+
<module name="SimplifyBooleanReturn"/>
138+
<module name="StringLiteralEquality"/>
139+
140+
<module name="ModifierOrder"/>
141+
<module name="RedundantModifier"/>
142+
143+
<module name="AnnotationLocation"/>
144+
<module name="MissingOverride"/>
145+
146+
<!-- By default this allows catch blocks with only comments -->
147+
<module name="EmptyCatchBlock"/>
148+
149+
<!-- Enforce tabs -->
150+
<module name="RegexpSinglelineJava">
151+
<property name="format" value="^\t* ([^*]|\*[^ /])"/>
152+
<property name="message" value="non-tab indentation"/>
153+
</module>
154+
155+
<module name="OuterTypeFilename"/>
156+
157+
<!--<module name="InvalidJavadocPosition"/>-->
158+
<module name="JavadocParagraph"/>
159+
<module name="JavadocStyle"/>
160+
<module name="AtclauseOrder">
161+
<property name="tagOrder" value="@param,@return,@throws,@deprecated"/>
162+
</module>
163+
</module>
164+
</module>

filament/settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'fabric-filament'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package net.fabricmc.filament;
2+
3+
import org.gradle.api.Plugin;
4+
import org.gradle.api.Project;
5+
6+
import net.fabricmc.filament.task.CombineUnpickDefinitionsTask;
7+
import net.fabricmc.filament.task.GeneratePackageInfoMappingsTask;
8+
import net.fabricmc.filament.task.JavadocLintTask;
9+
import net.fabricmc.filament.task.RemapUnpickDefinitionsTask;
10+
11+
public final class FilamentGradlePlugin implements Plugin<Project> {
12+
@Override
13+
public void apply(Project project) {
14+
project.getTasks().register("generatePackageInfoMappings", GeneratePackageInfoMappingsTask.class);
15+
project.getTasks().register("javadocLint", JavadocLintTask.class);
16+
17+
var combineUnpickDefinitions = project.getTasks().register("combineUnpickDefinitions", CombineUnpickDefinitionsTask.class);
18+
project.getTasks().register("remapUnpickDefinitionsIntermediary", RemapUnpickDefinitionsTask.class, task -> {
19+
task.dependsOn(combineUnpickDefinitions);
20+
task.getInput().set(combineUnpickDefinitions.flatMap(CombineUnpickDefinitionsTask::getOutput));
21+
task.getSourceNamespace().set("named");
22+
task.getTargetNamespace().set("intermediary");
23+
});
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package net.fabricmc.filament.task;
2+
3+
import java.io.File;
4+
import java.io.FileInputStream;
5+
import java.io.IOException;
6+
import java.io.UncheckedIOException;
7+
import java.util.ArrayList;
8+
import java.util.Comparator;
9+
import java.util.List;
10+
11+
import javax.inject.Inject;
12+
13+
import daomephsta.unpick.constantmappers.datadriven.parser.v2.UnpickV2Reader;
14+
import daomephsta.unpick.constantmappers.datadriven.parser.v2.UnpickV2Writer;
15+
import org.gradle.api.DefaultTask;
16+
import org.gradle.api.file.DirectoryProperty;
17+
import org.gradle.api.file.RegularFileProperty;
18+
import org.gradle.api.tasks.InputDirectory;
19+
import org.gradle.api.tasks.OutputFile;
20+
import org.gradle.api.tasks.TaskAction;
21+
import org.gradle.workers.WorkAction;
22+
import org.gradle.workers.WorkParameters;
23+
import org.gradle.workers.WorkQueue;
24+
import org.gradle.workers.WorkerExecutor;
25+
26+
import net.fabricmc.filament.util.FileUtil;
27+
import net.fabricmc.filament.util.UnpickUtil;
28+
29+
public abstract class CombineUnpickDefinitionsTask extends DefaultTask {
30+
@InputDirectory
31+
public abstract DirectoryProperty getInput();
32+
33+
@OutputFile
34+
public abstract RegularFileProperty getOutput();
35+
36+
@Inject
37+
protected abstract WorkerExecutor getWorkerExecutor();
38+
39+
@TaskAction
40+
public void run() {
41+
WorkQueue workQueue = getWorkerExecutor().noIsolation();
42+
workQueue.submit(CombineAction.class, parameters -> {
43+
parameters.getInput().set(getInput());
44+
parameters.getOutput().set(getOutput());
45+
});
46+
}
47+
48+
public interface CombineParameters extends WorkParameters {
49+
@InputDirectory
50+
DirectoryProperty getInput();
51+
52+
@OutputFile
53+
RegularFileProperty getOutput();
54+
}
55+
56+
public abstract static class CombineAction implements WorkAction<CombineParameters> {
57+
@Inject
58+
public CombineAction() {
59+
}
60+
61+
@Override
62+
public void execute() {
63+
try {
64+
File output = getParameters().getOutput().getAsFile().get();
65+
FileUtil.deleteIfExists(output);
66+
67+
UnpickV2Writer writer = new UnpickV2Writer();
68+
69+
// Sort inputs to get reproducible outputs (also for testing)
70+
List<File> files = new ArrayList<>(getParameters().getInput().getAsFileTree().getFiles());
71+
files.sort(Comparator.comparing(File::getName));
72+
73+
for (File file : files) {
74+
if (!file.getName().endsWith(".unpick")) {
75+
continue;
76+
}
77+
78+
try (UnpickV2Reader reader = new UnpickV2Reader(new FileInputStream(file))) {
79+
reader.accept(writer);
80+
}
81+
}
82+
83+
FileUtil.write(output, UnpickUtil.getLfOutput(writer));
84+
} catch (IOException e) {
85+
throw new UncheckedIOException(e);
86+
}
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)