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:
val = int(1)
2021-12-29 23:16:13 +01:00
committed by GitHub
parent 63f2b51b2c
commit 7611e3a632
6 changed files with 57 additions and 2 deletions

View File

@@ -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;

View File

@@ -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();