2018-12-18 22:36:22 +00:00
|
|
|
/*
|
|
|
|
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016, 2017, 2018 FabricMC
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package net.fabricmc.loom.task;
|
|
|
|
|
2019-11-02 20:23:27 +00:00
|
|
|
import java.io.File;
|
|
|
|
|
2018-12-22 13:37:16 +00:00
|
|
|
import org.gradle.api.tasks.Input;
|
2019-06-24 10:20:28 +00:00
|
|
|
import org.gradle.api.tasks.InputFile;
|
2020-06-27 19:18:32 +00:00
|
|
|
import org.gradle.api.tasks.Internal;
|
2019-04-21 09:29:19 +00:00
|
|
|
import org.gradle.api.tasks.OutputFile;
|
2018-12-18 22:36:22 +00:00
|
|
|
import org.gradle.api.tasks.TaskAction;
|
|
|
|
|
2019-11-02 20:23:27 +00:00
|
|
|
import net.fabricmc.loom.util.SourceRemapper;
|
2018-12-22 13:37:16 +00:00
|
|
|
|
2019-05-10 22:53:50 +00:00
|
|
|
public class RemapSourcesJarTask extends AbstractLoomTask {
|
|
|
|
private Object input;
|
|
|
|
private Object output;
|
|
|
|
private String direction = "intermediary";
|
2020-06-27 19:18:32 +00:00
|
|
|
private SourceRemapper sourceRemapper = null;
|
2021-03-15 23:31:18 +00:00
|
|
|
private boolean preserveFileTimestamps = true;
|
|
|
|
private boolean reproducibleFileOrder = false;
|
2020-12-21 19:47:08 +00:00
|
|
|
|
|
|
|
public RemapSourcesJarTask() {
|
|
|
|
}
|
2019-04-21 09:29:19 +00:00
|
|
|
|
2018-12-18 22:36:22 +00:00
|
|
|
@TaskAction
|
|
|
|
public void remap() throws Exception {
|
2020-06-27 19:18:32 +00:00
|
|
|
if (sourceRemapper == null) {
|
2021-03-15 23:31:18 +00:00
|
|
|
SourceRemapper.remapSources(getProject(), getInput(), getOutput(), direction.equals("named"), reproducibleFileOrder, preserveFileTimestamps);
|
2020-06-27 19:18:32 +00:00
|
|
|
} else {
|
2021-03-15 23:31:18 +00:00
|
|
|
sourceRemapper.scheduleRemapSources(getInput(), getOutput(), reproducibleFileOrder, preserveFileTimestamps);
|
2020-06-27 19:18:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Internal
|
|
|
|
public SourceRemapper getSourceRemapper() {
|
|
|
|
return sourceRemapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
public RemapSourcesJarTask setSourceRemapper(SourceRemapper sourceRemapper) {
|
|
|
|
this.sourceRemapper = sourceRemapper;
|
|
|
|
return this;
|
2018-12-18 22:36:22 +00:00
|
|
|
}
|
2019-05-10 22:53:50 +00:00
|
|
|
|
2019-06-24 10:20:28 +00:00
|
|
|
@InputFile
|
2019-11-02 20:23:27 +00:00
|
|
|
public File getInput() {
|
|
|
|
return getProject().file(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
@OutputFile
|
|
|
|
public File getOutput() {
|
|
|
|
return getProject().file(output == null ? input : output);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Input
|
|
|
|
public String getTargetNamespace() {
|
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setInput(Object input) {
|
|
|
|
this.input = input;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOutput(Object output) {
|
|
|
|
this.output = output;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTargetNamespace(String value) {
|
|
|
|
this.direction = value;
|
|
|
|
}
|
2021-03-15 23:31:18 +00:00
|
|
|
|
|
|
|
@Input
|
|
|
|
public boolean isPreserveFileTimestamps() {
|
|
|
|
return preserveFileTimestamps;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPreserveFileTimestamps(boolean preserveFileTimestamps) {
|
|
|
|
this.preserveFileTimestamps = preserveFileTimestamps;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Input
|
|
|
|
public boolean isReproducibleFileOrder() {
|
|
|
|
return reproducibleFileOrder;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setReproducibleFileOrder(boolean reproducibleFileOrder) {
|
|
|
|
this.reproducibleFileOrder = reproducibleFileOrder;
|
|
|
|
}
|
2018-12-18 22:36:22 +00:00
|
|
|
}
|