-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5b8b3e
commit c38bfc4
Showing
3 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
buildSrc/src/main/java/quilt/internal/task/setup/DownloadMojangMappingsTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package quilt.internal.task.setup; | ||
|
||
import org.gradle.api.DefaultTask; | ||
import org.gradle.api.file.RegularFileProperty; | ||
import org.gradle.api.tasks.OutputFile; | ||
import org.gradle.api.tasks.TaskAction; | ||
import org.quiltmc.launchermeta.version.v1.Downloads; | ||
import quilt.internal.constants.Groups; | ||
import quilt.internal.plugin.MinecraftJarsPlugin; | ||
import quilt.internal.task.VersionParserConsumingTask; | ||
import quilt.internal.util.DownloadUtil; | ||
|
||
/** | ||
* Downloads Mojang's client and server mappings for the passed {@linkplain #getVersionParser version}. | ||
* | ||
* @see <a href=https://minecraft.wiki/w/Obfuscation_map>Obfuscation map</a> | ||
* @see MinecraftJarsPlugin MinecraftJarsPlugin's configureEach | ||
*/ | ||
public abstract class DownloadMojangMappingsTask extends DefaultTask implements VersionParserConsumingTask { | ||
/** | ||
* {@linkplain org.gradle.api.tasks.TaskContainer#register Registered} by | ||
* {@link MinecraftJarsPlugin MinecraftJarsPlugin}. | ||
*/ | ||
public static final String DOWNLOAD_MOJANG_MAPPINGS_TASK_NAME = "downloadMojangMappings"; | ||
|
||
@OutputFile | ||
public abstract RegularFileProperty getClientMappings(); | ||
|
||
@OutputFile | ||
public abstract RegularFileProperty getServerMappings(); | ||
|
||
public DownloadMojangMappingsTask() { | ||
this.setGroup(Groups.SETUP); | ||
} | ||
|
||
@TaskAction | ||
public void download() { | ||
final Downloads downloads = this.getVersionParser().get().get().getDownloads(); | ||
|
||
downloads.getClientMappings().ifPresentOrElse( | ||
clientMappings -> DownloadUtil.download( | ||
clientMappings.getUrl(), | ||
this.getClientMappings().get().getAsFile(), | ||
false, this.getLogger() | ||
), | ||
() -> this.getLogger().warn("No client mappings available") | ||
); | ||
|
||
downloads.getServerMappings().ifPresentOrElse( | ||
serverMappings -> DownloadUtil.download( | ||
serverMappings.getUrl(), | ||
this.getServerMappings().get().getAsFile(), | ||
false, this.getLogger() | ||
), | ||
() -> this.getLogger().warn("No server mappings available") | ||
); | ||
} | ||
} |