-
Notifications
You must be signed in to change notification settings - Fork 1
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
560f96c
commit d7580d3
Showing
5 changed files
with
87 additions
and
52 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
src/main/java/net/legacyfabric/legacylooming/LegacyLoomingExtensionAPI.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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
package net.legacyfabric.legacylooming; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.provider.Property; | ||
|
||
public interface LegacyLoomingExtensionAPI { | ||
static LegacyLoomingExtensionAPI get(Project project) { | ||
return project.getExtensions().findByType(LegacyLoomingExtensionAPI.class); | ||
} | ||
|
||
Property<Integer> getIntermediaryVersion(); | ||
|
||
@Deprecated | ||
Property<Boolean> useLFIntermediary(); | ||
} |
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
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
32 changes: 29 additions & 3 deletions
32
...va/net/legacyfabric/legacylooming/providers/LegacyFabricIntermediaryMappingsProvider.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 |
---|---|---|
@@ -1,14 +1,40 @@ | ||
package net.legacyfabric.legacylooming.providers; | ||
|
||
import net.fabricmc.loom.LoomGradleExtension; | ||
import net.fabricmc.loom.api.LoomGradleExtensionAPI; | ||
import net.fabricmc.loom.configuration.providers.mappings.IntermediaryMappingsProvider; | ||
import org.gradle.api.provider.Property; | ||
import net.legacyfabric.legacylooming.Constants; | ||
import net.legacyfabric.legacylooming.LegacyLoomingExtensionAPI; | ||
import org.gradle.api.Project; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public abstract class LegacyFabricIntermediaryMappingsProvider extends IntermediaryMappingsProvider { | ||
public abstract Property<String> getNameProperty(); | ||
private String name; | ||
private String defaultUrl = ""; | ||
|
||
@Override | ||
public @NotNull String getName() { | ||
return this.getNameProperty().get(); | ||
String defaultUrl = this.defaultUrl; | ||
String url = getIntermediaryUrl().get(); | ||
|
||
if (!defaultUrl.equals(url)) { | ||
// make sure the name is changed when the user defines a | ||
// custom intermediary url, to ensure the default cache | ||
// file does not get corrupted with other intermediaries | ||
return name += "-" + Integer.toHexString(url.hashCode()); | ||
} | ||
|
||
return this.name; | ||
} | ||
|
||
public void configure(Project project, LegacyLoomingExtensionAPI api, LoomGradleExtensionAPI loom) { | ||
this.name = api.getIntermediaryVersion().map(Constants::getIntermediaryName).get(); | ||
this.defaultUrl = loom.getIntermediaryUrl().get(); | ||
|
||
this.getIntermediaryUrl() | ||
.convention(api.getIntermediaryVersion().map(Constants::getIntermediaryURL)) | ||
.finalizeValueOnRead(); | ||
|
||
this.getRefreshDeps().set(project.provider(() -> LoomGradleExtension.get(project).refreshDeps())); | ||
} | ||
} |