mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 13:37:45 -05:00
Add support for mixin files outside of root in MixinRefmapHelper (#536)
* Add support for mixin files outside of root in MixinRefmapHelper * Fix checkstyle + Integration tests + Checks all srcDirs from sourceSet * Redid part that failed to save for last commit * Other issues fixed * Checkstyle again * Made getting root paths safer Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> * CodeNarc for test * Normalized all paths to fix issues on Windows * Removed debug line used to test return value of lamdba Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> Co-authored-by: modmuss50 <modmuss50@gmail.com>
This commit is contained in:
@@ -76,7 +76,7 @@ public class MixinExtensionImpl extends MixinExtensionApiImpl implements MixinEx
|
||||
protected PatternSet add0(SourceSet sourceSet, Provider<String> refmapName) {
|
||||
if (!super.getUseLegacyMixinAp().get()) throw new IllegalStateException("You need to set useLegacyMixinAp = true to configure Mixin annotation processor.");
|
||||
|
||||
PatternSet pattern = new PatternSet().setIncludes(Collections.singletonList("*.json"));
|
||||
PatternSet pattern = new PatternSet().setIncludes(Collections.singletonList("**/*.json"));
|
||||
MixinExtension.setMixinInformationContainer(sourceSet, new MixinExtension.MixinInformationContainer(sourceSet, refmapName, pattern));
|
||||
|
||||
isDefault = false;
|
||||
|
||||
@@ -136,12 +136,34 @@ public abstract class RemapJarTask extends AbstractRemapJarTask {
|
||||
MixinExtension.getMixinInformationContainer(sourceSet)
|
||||
);
|
||||
|
||||
String[] rootPaths = sourceSet.getResources().getSrcDirs().stream()
|
||||
.map(root -> {
|
||||
String rootPath = root.getAbsolutePath().replace("\\", "/");
|
||||
|
||||
if (rootPath.charAt(rootPath.length() - 1) != '/') {
|
||||
rootPath += '/';
|
||||
}
|
||||
|
||||
return rootPath;
|
||||
})
|
||||
.toArray(String[]::new);
|
||||
|
||||
final String refmapName = container.refmapNameProvider().get();
|
||||
final List<String> mixinConfigs = container.sourceSet().getResources()
|
||||
.matching(container.mixinConfigPattern())
|
||||
.getFiles()
|
||||
.stream()
|
||||
.map(File::getName)
|
||||
.map(file -> {
|
||||
String s = file.getAbsolutePath().replace("\\", "/");
|
||||
|
||||
for (String rootPath : rootPaths) {
|
||||
if (s.startsWith(rootPath)) {
|
||||
s = s.substring(rootPath.length());
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
})
|
||||
.filter(allMixinConfigs::contains)
|
||||
.toList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user